iFXAnalyser_v1
Download scriptThe iFXAnalyser is a specialized technical analysis tool designed to help traders understand the underlying momentum and "health" of a market trend by calculating the relationship between two different moving averages. Instead of just looking at price, this script analyzes the mathematical differences, changes, and speeds behind the price action.
Here is a breakdown of how the logic works:
The Core Concept: Moving Average Interaction
The tool operates by comparing two distinct "Moving Averages" (MAs). One acts as a Fast indicator (reacting quickly to recent price changes), while the other acts as a Slow indicator (smoothing out the noise to show the broader trend). By looking at how these two interact, the script reveals hidden dynamics in the market.
The Three Layers of Analysis
The logic processes the data into three distinct layers, which are displayed in a separate window below your main chart:
1. Divergence (The Gap) The first layer calculates the simple difference between the Fast and Slow moving averages.
- What it tells you: It shows the current distance between short-term momentum and long-term trends. A widening gap suggests that the price is pulling away from its average, while a shrinking gap may indicate a loss of steam.
2. Slope (The Rate of Change) The second layer looks at how the "Divergence" calculated above is changing from one moment to the next.
- What it tells you: This measures the "tilt" or direction of the trend. If the gap between the two averages is expanding rapidly, the slope will be steep. If it is flattening out, the slope decreases. This helps identify if a move is accelerating or starting to tire out.
3. Acceleration (The Slope of the Slope) The third layer provides the deepest analysis by calculating the change in the "Slope" itself.
- What it tells you: This is essentially the "speedometer" of the market. It reveals whether the trend is accelerating, decelerating, or reaching a point of exhaustion. By measuring the rate at which the slope changes, traders can often spot potential turning points before they become obvious on the price chart.
Summary for Traders
Instead of just telling you where the price is, this script helps you see how the price is moving. By providing three levels of depth—Difference, Slope, and Acceleration—it allows you to identify whether a trend is gaining strength, losing momentum, or potentially about to reverse based on the underlying mathematical pressure of the market.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| iFXAnalyser.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
#property indicator_color3 Green
//---- indicator parameters
extern int MA_Shift=0;
extern int FastMA=4;
extern int SlowMA=6;
extern int Fast_MAMode = PRICE_CLOSE;
extern int Slow_MAMode = PRICE_OPEN;
string short_name = "iFXAnalyser";
//---- indicator buffers
double ind_buffer0[];
double ind_buffer1[];
double ind_buffer2[];
//----
int counted_bars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetLevelStyle(STYLE_DOT,1,Black);
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,"Div");
SetIndexLabel(1,"Slope");
SetIndexLabel(2,"Acel");
//---- indicator buffers mapping
if(!SetIndexBuffer(0,ind_buffer0) && !SetIndexBuffer(1,ind_buffer1) && !SetIndexBuffer(2,ind_buffer2))
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));
//---- Shaun's Slope of Slope counted in the 3-3d buffer
for(i=0; i<limit-2; i++)
ind_buffer2[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))
-(iMA(NULL,0,FastMA,0,MODE_SMA,Fast_MAMode,i+1)
-iMA(NULL,0,SlowMA,0,MODE_SMA,Slow_MAMode,i+1))
-(iMA(NULL,0,FastMA,0,MODE_SMA,Fast_MAMode,i+2)
-iMA(NULL,0,SlowMA,0,MODE_SMA,Slow_MAMode,i+2)));
//---- done
return(0);
}
Comments