Author: Copyright � 2005, MetaQuotes Software Corp.
XO_003

This tool is designed to track the momentum of price movements by identifying and counting consecutive "breakouts" in a specific direction. Instead of simply looking at whether the price is going up or down, it measures the strength and persistence of a trend by monitoring how far the price pushes beyond established boundaries.

How the Logic Works

1. Trend Tracking and Boundary Setting The script establishes dynamic high and low boundaries based on the current market price. It uses a user-defined sensitivity parameter (the "KirPER" value) to determine how much of a price move is required to be considered a significant shift.

2. Identifying Upward Momentum When the market price moves significantly higher than the established boundary, the script recognizes this as an upward trend. It then:

  • Increments a counter to track how many consecutive "up" moves have occurred.
  • Updates the boundaries to reflect the new price level.
  • Visualizes this strength as a positive signal (XO Up).

3. Identifying Downward Momentum Conversely, if the price drops significantly below the established boundary, the script recognizes a downward trend. It then:

  • Increments a separate counter for downward moves.
  • Adjusts the boundaries to accommodate the lower price points.
  • Visualizes this strength as a negative signal (XO Down).

4. Resetting and Re-evaluating The logic is designed to "reset" when the momentum shifts. If the price stops moving in one direction and begins pushing strongly in the opposite direction, the script clears the previous count and starts tracking the new trend from scratch.

Summary for Traders

Essentially, this indicator acts as a momentum counter. It filters out minor price fluctuations and only triggers a signal when the price makes a substantial move that breaks through a calculated threshold.

  • XO Up: Represents the persistence of bullish movement.
  • XO Down: Represents the persistence of bearish movement.

By looking at these signals, you can visually identify which direction has the most "weight" or "strength" at any given time, helping to distinguish between a minor price twitch and a sustained trend.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
XO_003
//+------------------------------------------------------------------+
//|                                                           XO.mq4 |
//|                                   Original Author SHARIPOV AINUR |
//|               Conversion to MT4 and modification only adoleh2000 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Lime  //XO up
#property  indicator_color2  Red  //XO down

extern double KirPER=10;
double cb,valuel,valueh,CurrentBar;
double Kir ,Hi, Lo, KirUp, KirDn,mode,cnt,cnt1,cur,kr,no;
double ExtMapBuffer1[]; // XO up
double ExtMapBuffer2[]; // Xo down
int loopbegin;




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
     IndicatorBuffers(2);   
//---- drawing settings
      
   SetIndexBuffer(0,ExtMapBuffer1);//bbMacd line
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   
   
   SetIndexBuffer(1,ExtMapBuffer2);//Upperband line
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   
  IndicatorShortName("XO ("+KirPER+"), "+valueh+","+valuel);
  SetIndexLabel(0,"XO Up");
  SetIndexLabel(1,"XO Down");


//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
      int limit;
   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--;
         
      loopbegin = Bars-1;
      for(int i = loopbegin; i >= 0; i--)
      {         

if (Kir<1)
{
Hi=Close[i];
Lo=Close[i];
Kir=1;
}


cur=(Close[i]);


if (cur > (Hi+KirPER * Point)) 
{
Kir=Kir+1;
Hi=cur;
Lo=cur-KirPER*Point;
KirUp=1;
KirDn=0;
kr=kr+1;
no=0;
}

if (cur < (Lo-KirPER*Point)) 
{
Lo=cur;
Hi=cur+KirPER*Point;
KirUp=0;
KirDn=1;
Kir=Kir+1;
no=no+1;
kr=0;
}

valueh=kr;
ExtMapBuffer1[i]=valueh;//XO up

if (valueh < 0)
{
ExtMapBuffer1[i] = 0;
} 
if (valueh > 0)
{
ExtMapBuffer1[i] = 1;
} 

valuel=0-no;
ExtMapBuffer2[i]=valuel;// XO down

if (valuel > 0)
{
ExtMapBuffer2[i] = 0;
} 
if (valuel < 0)
{
ExtMapBuffer2[i] = -1;
} 


      
}

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

Comments