Author: Copyright � 2008, Bookkeeper
BO_v1

This custom indicator is designed to provide a visual representation of market momentum and trend direction by analyzing the relationship between different moving averages and a specialized external data source.

Core Logic Overview

The script functions by calculating the relative position of price action within specific "envelopes." It compares two different timeframes (defined by the user as Period 1 and Period 2) to determine how the current market sentiment is shifting. By measuring where the price sits in relation to these moving averages, the tool generates a numerical value that represents the intensity of the current trend.

How it Works

The logic follows a three-step process:

1. Data Collection The script looks at four specific data points simultaneously:

  • The high and low average prices for the short term (Period 1).
  • The high and low average prices for the long term (Period 2).
  • A specialized custom value provided by an external component called "NavelSMA."

2. Trend Calculation For every candle on the chart, the script calculates a "Relative Position Score." It determines where the current price sits between the high and low boundaries of both the short-term and long-term periods. By subtracting these two relative positions from one another, it creates a unique value that highlights whether the market is favoring the upside or the downside. If the price boundaries are flat (no movement), the script carries over the previous value to ensure a smooth transition.

3. Visual Representation The final output is displayed as a histogram in a separate window below your main chart:

  • Trend Tracking: The script compares each new calculated value to the one immediately preceding it.
  • Dynamic Color Coding: If the current trend value is increasing, the indicator highlights the movement in one color (representing an upward bias). If the value decreases, it switches to another color (representing a downward bias).
  • Visual Clarity: By using a histogram format, the tool allows traders to quickly see the strength of the trend at a glance, with the colors providing an immediate signal of whether the momentum is accelerating or cooling off.

Summary for the User

Essentially, this tool acts as a "momentum compass." It takes complex calculations involving multiple moving averages and simplifies them into a color-coded visual map, helping you identify whether the market's current strength is pushing upward or pulling downward based on the interaction between short-term and long-term price dynamics.

Indicators Used
Moving average indicator
9 Views
0 Downloads
0 Favorites
BO_v1
//+-------------------------------------------------------------------+
//|                                                            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
//----
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;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
     }
   return(0);
}
//---------------------------------------------------------------------

Comments