iAnchMom_v2

iAnchMom_v2

This technical indicator is designed to provide traders with a visual representation of relative momentum, specifically by comparing the speed of short-term price movement against longer-term averages. Instead of looking at raw price alone, it interprets the "health" of a trend by measuring the gap between two different types of moving averages.

How the Logic Works

The script operates by analyzing two specific mathematical layers of price data:

1. Short-Term Trend Analysis (EMA) The tool first calculates an Exponential Moving Average (EMA). This is designed to react more quickly to recent price changes, giving a "fast" look at where the market is heading in the immediate moment.

2. Long-Term Baseline Analysis (SMA) Simultaneously, the tool calculates a Simple Moving Average (SMA) based on a significantly longer timeframe. This acts as a baseline or the "anchor," representing the broader, more stable direction of the market over an extended period.

3. The Momentum Calculation The core logic of the indicator lies in the relationship between these two averages. Rather than simply showing the values of the averages, the script performs a percentage calculation:

  • It takes the Short-Term average and divides it by the Long-Term "anchor" average.
  • It then converts this ratio into a percentage of deviation.

Visual Representation

The result is displayed as a histogram in a separate window on your chart.

  • Positive Values: When the short-term price action is moving significantly faster or higher than the long-term anchor, the histogram will rise above the zero line, indicating bullish momentum.
  • Negative Values: When the short-term price action falls behind the long-term anchor, the histogram dips below the zero line, signaling bearish momentum.

By using this percentage-based approach, the indicator allows traders to see how much "strength" a current move has relative to historical norms, making it easier to identify when a trend is accelerating or losing steam.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
iAnchMom_v2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                    iAnchMom.mq4  |
//|                                                                  |
//+------------------------------------------------------------------+


#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Teal

//---- input parameters
extern int EMA_period=34;
extern int MomPeriod=120;
//---- buffers
double MomBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(1);
   SetIndexBuffer(0, MomBuffer);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Teal);
   SetIndexDrawBegin(0,MomPeriod + MomPeriod + 1);
//---- name for DataWindow and indicator subwindow label
   short_name="iAnchMom("+MomPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| AnchMom                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
   double a,b;
   int SMA_Period = MomPeriod + MomPeriod + 1;

   if(Bars<=SMA_Period) return(0);

//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=SMA_Period;i++) MomBuffer[Bars-i]=0.0;
//----
   i=Bars-SMA_Period-1;
   if(counted_bars>=SMA_Period) i=Bars-counted_bars-1;
   while(i>=0)
     {
      a = iMA(NULL,0,EMA_period,0, MODE_EMA,PRICE_CLOSE, i);
      b = iMA(NULL,0,SMA_Period,0, MODE_SMA, PRICE_CLOSE, i);
      MomBuffer[i]= 100*((a / b)-1);
                          

      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments