iFXAnalyser_H4-Open1
Download scriptThis tool is designed to help traders analyze market trends by measuring the relationship between two different moving averages. Instead of looking at raw price action alone, it focuses on the "momentum" and "acceleration" behind the trend, making it easier to visualize how strongly a market is moving in a particular direction.
Core Logic Overview
The script operates by comparing two specific moving averages: a Fast average (which reacts quickly to recent price changes) and a Slow average (which tracks the broader, long-term trend). By looking at the interaction between these two, the tool calculates three key pieces of information:
1. The Difference (Divergence)
The first primary calculation determines the distance between the Fast moving average and the Slow moving average. Think of this as the "gap." When this gap widens, it suggests that short-term price action is pulling away from the long-term trend. When the gap narrows, it may indicate that the current momentum is cooling off.
2. The Slope
The script then takes that "gap" and calculates its change over time. This tells you whether the distance between the two averages is growing or shrinking.
- If the slope is positive, the fast average is moving further away from the slow average (increasing momentum).
- If the slope is negative, the fast average is moving back toward the slow average (decreasing momentum).
3. The Acceleration
By measuring the change in the slope, the tool identifies how quickly the momentum itself is changing. This helps traders identify "turning points"—moments where a trend might be exhausting or where a new, stronger move is beginning to take hold.
Summary for Traders
Rather than just telling you what the price is doing, this indicator tells you how much force is behind the current move. It filters out some of the "noise" of individual price ticks to show you the underlying health of a trend, helping you visualize whether a market move is gaining steam, losing power, or preparing for a potential reversal.
//+------------------------------------------------------------------+
//| iFXAnalyser_H4.mq4 |
//| Copyright © 2006, Renato P. dos Santos |
//| inspired on 4xtraderCY's and SchaunRSA's ideas |
//| http://www.strategybuilderfx.com/forums/showthread.php?t=16086 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Renato P. dos Santos"
#property link "http://www.strategybuilderfx.com/forums/showthread.php?t=16086"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
//---- indicator parameters
extern int MA_Shift=0;
//---- indicator buffers
double ind_buffer0[];
double ind_buffer1[];
int FastMA=4;
int SlowMA=6;
int Fast_MAMode = PRICE_OPEN;//close
int Slow_MAMode = PRICE_OPEN;
//----
int counted_bars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name = "iFXAnalyser_H4-open";
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetLevelStyle(STYLE_DOT,1,Black);
SetLevelValue(1,15*Point);
SetLevelValue(2,-15*Point);
SetIndexShift(0,MA_Shift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
draw_begin=FastMA-1;
SetIndexDrawBegin(0,draw_begin);
//---- indicator short name
IndicatorShortName(short_name+"("+FastMA+","+SlowMA+")");
SetIndexLabel(0,short_name+"Div");
SetIndexLabel(1,short_name+"Slope");
SetIndexLabel(2,short_name+"Accel");
//---- indicator buffers mapping
if(!SetIndexBuffer(0,ind_buffer0) && !SetIndexBuffer(1,ind_buffer1))
Alert("cannot set indicator buffer!");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Shaun's 2MA difference |
//+------------------------------------------------------------------+
int start()
{
if(Bars<=MathMax(FastMA,SlowMA)) return(0);
int counted_bars=IndicatorCounted();
//---- check for possible errors
if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
if (counted_bars>0) counted_bars--;
//---- Shaun's Divergence counted in the 1-st buffer
int limit=Bars-counted_bars;
int i;
for(i=0; i<limit; i++)
ind_buffer0[i]=iMA(NULL,0,FastMA,0,MODE_SMA,Fast_MAMode,i)
-iMA(NULL,0,SlowMA,0,MODE_SMA,Slow_MAMode,i);
//---- Shaun's Slope counted in the 2-nd buffer
for(i=0; i<limit-1; i++)
ind_buffer1[i]=(iMA(NULL,0,FastMA,0,MODE_SMA,Fast_MAMode,i)
-iMA(NULL,0,SlowMA,0,MODE_SMA,Slow_MAMode,i))
-(iMA(NULL,0,FastMA,0,MODE_SMA,Fast_MAMode,i+1)
-iMA(NULL,0,SlowMA,0,MODE_SMA,Slow_MAMode,i+1));
//---- done
return(0);
}
Comments