iAnchMom

This tool is designed as a visual aid for traders to help identify momentum and relative strength within a financial market. It creates a historical histogram in a separate window, allowing you to see how the price is behaving over time compared to its longer-term average.

How the Logic Works

The indicator operates by comparing two different types of moving averages to determine the "velocity" of the current price trend. Here is the step-by-step breakdown of its logic:

1. Data Processing The script looks at two specific timeframes based on settings you provide:

  • A faster Exponential Moving Average (EMA), which reacts more quickly to recent price changes.
  • A slower Simple Moving Average (SMA), which represents the broader, long-term trend of the asset.

2. The Momentum Calculation Instead of just showing you the price, the tool calculates the mathematical distance between these two averages. It takes the faster average (EMA) and divides it by the slower average (SMA). By subtracting 1 from this result, it determines the percentage difference between the short-term trend and the long-term trend.

3. Visual Output The final result is multiplied by 100 to create a clean percentage value. This value is then plotted as a teal-colored histogram:

  • When the histogram moves above zero, it suggests that the short-term price momentum is stronger than the long-term average (bullish sentiment).
  • When the histogram moves below zero, it suggests that the short-term price momentum is weaker than the long-term average (bearish sentiment).

Summary for the Trader

Essentially, this script acts as a "momentum gauge." Rather than looking at raw price fluctuations, it translates the relationship between fast and slow trends into a single percentage. This helps you visualize whether the current market move has significant strength behind it or if it is losing steam relative to its historical average.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
iAnchMom
//+------------------------------------------------------------------+
//|                                                    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