TSD_PP_MACD_FORCE_Ind_v1
Download scriptThis technical indicator is designed to analyze market trends by synchronizing data from two different timeframes: the Weekly and Daily charts. By combining these perspectives, the tool aims to identify specific moments where price momentum shifts in a way that suggests a potential reversal or a significant trend change.
Core Logic and Components
The script operates by evaluating two distinct market signals simultaneously:
1. The Weekly Momentum (MACD) The indicator looks at the Weekly timeframe to determine the primary long-term direction. It uses the MACD (Moving Average Convergence Divergence) calculation to see if the weekly trend is moving upward or downward.
- If the current weekly value is higher than the previous one, it marks an upward direction.
- If it is lower, it marks a downward direction.
2. The Daily "Force" Component Simultaneously, the script analyzes the Daily timeframe to measure the "Force" of the price action. It looks at an Exponential Moving Average (EMA) to determine whether the current daily force is positive or negative.
How the Signals Interact
The unique logic of this script lies in identifying contradictions between these two timeframes. Instead of simply following the trend, it highlights specific "Force" conditions:
- Bullish Signal (Green): This occurs when the Weekly momentum is moving upward, but the Daily "Force" is currently negative. The indicator plots a green histogram to highlight this discrepancy.
- Bearish Signal (Red): This occurs when the Weekly momentum is moving downward, but the Daily "Force" is currently positive. The indicator plots a red histogram to highlight this situation.
Summary of Functionality
Essentially, the tool acts as a filter to find instances where the short-term daily force is running counter to the long-term weekly trend. By visualizing these moments on a separate window in your trading platform, it helps traders spot potential "overextended" price movements or significant shifts in market sentiment that may not be obvious by looking at a single timeframe alone.
//+------------------------------------------------------------------+
//| TSD_PP_MACD_FORCE_Ind_v1.mq4 |
//| (From Elders Book) |
//| Copyright ® 2005 Bob O'Brien / Barcode |
//| TSD Indicator by Pedro Puado |
//| TSD Indicator version 1 |
//+------------------------------------------------------------------+
#property copyright "Pedro Puado (From Elders Book)"
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- input parameters
extern int Force=2;
extern int FastMA=12;
extern int SlowMA=26;
extern int Signal=9;
extern int MaxBars=1000;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,"Up");
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexLabel(1,"Down");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
double MacdPrevious, MacdPrevious2, force, ForcePos, ForceNeg;
int Direction;
//----
int i,k, nDay, nWeek;
i=Bars-1;
if(counted_bars>0) i=Bars-counted_bars+0;
i = MathMin(i, MaxBars);
while (i >=0)
{
nWeek = GetWeekIndex(i);
MacdPrevious = iMACD(Symbol(),PERIOD_W1,SlowMA,FastMA,Signal,PRICE_CLOSE,MODE_MAIN,nWeek+1);
MacdPrevious2 = iMACD(Symbol(),PERIOD_W1,SlowMA,FastMA,Signal,PRICE_CLOSE,MODE_MAIN,nWeek+2);
if (MacdPrevious > MacdPrevious2) Direction = 1;
if (MacdPrevious < MacdPrevious2) Direction = -1;
if (MacdPrevious == MacdPrevious2) Direction = 0;
nDay = GetDayIndex(i);
force = iForce(Symbol(),PERIOD_D1,Force,MODE_EMA,PRICE_CLOSE,nDay+1);
ForcePos = force > 0;
ForceNeg = force < 0;
Print(nWeek, " - ", Direction, " - ", nDay, " - ", Force);
if(Direction == 1 && ForceNeg)
{
ExtMapBuffer1[i] = 1;
ExtMapBuffer2[i] = 0.0;
}
if(Direction == -1 && ForcePos)
{
ExtMapBuffer1[i] = 0.0;
ExtMapBuffer2[i] = -1;
}
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int GetWeekIndex(int x)
{
datetime dSun = StrToTime(TimeToStr(Time[x]-(TimeDayOfWeek(Time[x])*86400),TIME_DATE));
return (((iTime(Symbol(),PERIOD_W1,0)-dSun)/86400)/7);
}
//+------------------------------------------------------------------+
int GetDayIndex(int x)
{
if (Period() == PERIOD_D1) return (x);
int nWeek = GetWeekIndex(x)*5; //number of days since
datetime dSun = StrToTime(TimeToStr(Time[x],TIME_DATE));
int i = MathAbs((iTime(Symbol(),PERIOD_D1,nWeek)-dSun)/86400);
return (nWeek-i);
}
//+------------------------------------------------------------------+
Comments