TSD_PP_MACD_FORCE_Ind_v11
Download scriptThis technical tool is designed to help traders identify specific high-probability market shifts by analyzing the relationship between long-term momentum and short-term price pressure. Rather than looking at simple price movements, it cross-references data from two different timeframes—Weekly and Daily—to spot "forced" trend reversals.
How the Logic Works
The script functions by comparing three distinct layers of market data:
1. Weekly Momentum (The MACD Component) The tool first looks at the Weekly chart to determine the overarching trend. It uses a Modified Moving Average Convergence Divergence (MACD) calculation to see if the momentum is currently moving upward or downward on a macro scale. This tells the script whether the "big picture" is bullish or bearish.
2. Daily Price Pressure (The Force Component) Simultaneously, the tool calculates a "Force" value based on Daily price action. This measures the immediate intensity of buying or selling pressure over the last few days. It identifies whether the current daily price is being pushed aggressively in one direction or the other.
3. The Convergence Logic (The Signal) The core intelligence of the script lies in how it combines these two factors. It specifically looks for "contradictions" between the weekly trend and daily pressure:
- Bullish Signal: If the Weekly momentum is moving upward (positive direction) but the Daily "Force" shows strong selling pressure (negative force), the tool flags a specific signal. This suggests that while the long-term trend is up, there is a significant amount of downward pressure being applied.
- Bearish Signal: Conversely, if the Weekly momentum is moving downward (negative direction) but the Daily "Force" shows strong buying pressure (positive force), it flags a signal indicating that despite the long-term downtrend, immediate buying intensity is high.
Visual Representation
The results are displayed in a separate window as a histogram:
- Green Bars: Represent the points where the specific bullish criteria are met.
- Red Bars: Represent the points where the specific bearish criteria are met.
In summary, this script doesn't just tell you what price is doing right now; it alerts you to moments where short-term market "force" is clashing with the long-term weekly trend, allowing traders to identify potential turning points or high-tension zones in the market.
//+------------------------------------------------------------------+
//| 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