iFXAnalyser_H4-Open
Download scriptThis tool is designed as a technical analysis indicator for the MetaTrader platform. Its primary purpose is to help traders visualize the momentum and "health" of a currency pair or asset by analyzing the relationship between two different moving averages. Instead of looking at price directly, this script focuses on the mathematical distance and speed between these averages to identify market trends.
The logic functions through three distinct layers of calculation:
1. The Core Difference (Divergence)
The foundation of this tool is the comparison between a "Fast" moving average and a "Slow" moving average. By subtracting the value of the slow average from the fast one, the script identifies the gap between short-term price action and long-term trends.
- When this gap widens significantly, it indicates strong momentum in one direction.
- When the gap narrows or flips, it suggests a potential change in the market's trend.
2. The Slope Analysis
Beyond just knowing the distance between the two averages, the script calculates the "Slope." This represents the rate of change in that difference from one moment to the next. Essentially, it tells the trader not just how far apart the averages are, but whether that gap is growing larger or smaller as time moves forward. This helps in identifying whether a trend is accelerating or losing steam.
3. Acceleration
By measuring the change in the slope, the tool provides a glimpse into the "Acceleration." This is a secondary layer of logic that tracks how quickly the rate of change itself is moving. It acts as a momentum-of-momentum indicator, helping to detect when a price move is becoming exhausted or gaining explosive power before it becomes obvious on a standard chart.
Summary for the Trader
In practical terms, this script transforms raw price data into a smoother, more readable visual representation of market behavior. Instead of just seeing where the price is, it helps you see:
- Trend Strength: How much "push" there is behind the current move.
- Momentum Shifts: When the strength of a move begins to tilt or weaken.
- Early Warnings: Identifying changes in acceleration that can signal a trend might be about to reverse or stall.
//+------------------------------------------------------------------+
//| 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;
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-1)
-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-1)
-iMA(NULL,0,SlowMA,0,MODE_SMA,Slow_MAMode,i))
-(iMA(NULL,0,FastMA,0,MODE_SMA,Fast_MAMode,i+1-1)
-iMA(NULL,0,SlowMA,0,MODE_SMA,Slow_MAMode,i+1));
//---- done
return(0);
}
Comments