Author: Copyright � 2008, Bookkeeper
BO

This custom indicator is designed to analyze market momentum by measuring the relative positioning of price action against moving averages. It provides a visual representation of trend strength, helping traders identify shifts in market direction through a histogram display.

How the Logic Works

The tool operates by comparing two different timeframes (short-term and long-term) simultaneously. It calculates the boundaries of the price movement using high and low price averages for both periods.

1. The Core Calculation The script looks at where the current "middle" price sits relative to these upper and lower boundaries. By calculating the difference between these positions, it determines a specific value that represents the intensity of the current trend. If the price is moving more aggressively toward the upper boundary of the short-term average compared to the long-term one, the value adjusts accordingly.

2. Handling Stable Markets To ensure the indicator remains smooth and doesn't provide erratic data during periods of zero volatility (where high and low prices are identical), the script includes a "buffer" logic. If the market is flat, it simply carries over the previous calculation to maintain a continuous line.

3. Trend Identification and Visualization The final output is translated into a visual histogram that distinguishes between upward and downward momentum:

  • Upward Momentum: When the calculated value is rising, the indicator highlights this as a positive trend.
  • Downward Momentum: When the value begins to drop, the indicator switches its visual signal to reflect a bearish move.

Summary for Traders

Essentially, this tool acts as a "momentum gauge." Instead of just showing you where the price is, it calculates how hard the price is pushing against established averages. By looking at the resulting histogram, you can quickly see whether the current trend is gaining strength or beginning to lose steam, allowing for a clearer understanding of market sentiment.

Indicators Used
Moving average indicator
13 Views
0 Downloads
0 Favorites
BO
//+-------------------------------------------------------------------+
//|                                                            BO.mq4 |
//+-------------------------------------------------------------------+
//  Íåîáõîäèìî íàëè÷èå NavelSMA.mq4
//  Presence NavelSMA.mq4 is necessary 
//---------------------------------------------------------------------
#property copyright "Copyright © 2008, Bookkeeper"
#property link      "yuzefovich@gmail.com"
//----
#property indicator_separate_window

#property indicator_buffers 3
#property indicator_color1  Blue
#property indicator_color2  Green
#property indicator_color3  Red
#property indicator_level1  1
#property indicator_level2 -1
#property indicator_levelcolor SlateGray


//----
extern int  Period1=5; 
extern int  Period2=34; 
//----                                      
double      BO[];
double      ExtBuffer1[];
double      ExtBuffer2[];
//---------------------------------------------------------------------
void deinit()
{
  return;
}
//---------------------------------------------------------------------
int init()
{
   string short_name="BO ("+Period1+","+Period2+")";
   IndicatorBuffers  (3);
   SetIndexBuffer    (0,BO);
   SetIndexBuffer    (1,ExtBuffer1);
   SetIndexBuffer    (2,ExtBuffer2);
   SetIndexStyle     (0,DRAW_NONE);
   SetIndexStyle     (1,DRAW_HISTOGRAM);
   SetIndexStyle     (2,DRAW_HISTOGRAM);
   SetIndexLabel     (1,NULL);
   SetIndexLabel     (2,NULL);
   IndicatorShortName(short_name);
   return(0);
}
//---------------------------------------------------------------------
int start()
{
   int ExtCountedBars=IndicatorCounted();
   if (ExtCountedBars<0) return(-1);
   if (ExtCountedBars>0) ExtCountedBars--;
   int i, pos=Bars-ExtCountedBars;
   if(pos<Period1) pos=Period1;
   pos++;
   int limit=pos;
   while(pos>=0)
   {
      double h0=iMA(NULL,0,Period1,0,MODE_SMA,PRICE_HIGH,pos);
      double l0=iMA(NULL,0,Period1,0,MODE_SMA,PRICE_LOW,pos);
      double h2=iMA(NULL,0,Period2,0,MODE_SMA,PRICE_HIGH,pos);
      double l2=iMA(NULL,0,Period2,0,MODE_SMA,PRICE_LOW,pos);
      double n=iCustom(NULL,0,"NavelSMA",Period1,0,0,pos);
      if(h0==l0 || h2==l2) BO[pos]=BO[pos+1];
      else BO[pos]=(n-l2)/(h2-l2)-(n-l0)/(h0-l0);
      pos--;
   }   
   bool up=true;
   double prev,current;
   for(i=limit-1; i>=0; i--)
     {
      current=BO[i];
      prev=BO[i+1];
      if(current>prev)  up=true;
//    if(current<prev) up=false;
                  else  up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
     }
   return(0);
}
//---------------------------------------------------------------------

Comments