Author: Copyright � 2005, MetaQuotes Software Corp.
XO_v3

The XO indicator is a specialized technical analysis tool designed to track and visualize specific trends in price movement by identifying "breakout" behavior. Instead of following every small fluctuation in the market, this script focuses on significant shifts in momentum, categorizing the market activity into two distinct directions: upward pressure and downward pressure.

Core Logic and Mechanism

The indicator operates by establishing a dynamic threshold based on a user-defined sensitivity level (the "KirPER" value). It monitors the price of each new candle to determine if the market is making a significant move forward or pulling back.

1. Trend Identification The script continuously compares the current price against the previous established "high" and "low" points.

  • Upward Momentum: If the price climbs above a specific distance from the previous high, the tool recognizes this as an upward trend. It then updates its internal markers to reflect this new peak.
  • Downward Momentum: Conversely, if the price drops below a specific distance from the previous low, it registers a downward movement and adjusts its internal markers to track the new bottom.

2. Visual Representation The indicator translates these mathematical movements into a visual histogram displayed in a separate window on your chart. It uses two primary components to communicate market sentiment:

  • XO Up: This represents positive momentum. When the price successfully breaks upward beyond the defined threshold, it triggers a visual signal indicating an active bullish trend.
  • XO Down: This represents negative momentum. When the price breaches the downward threshold, it triggers a visual signal indicating an active bearish trend.

How It Helps Traders

By filtering out "market noise"—the minor, insignificant price wiggles that often mislead traders—this tool highlights the primary direction of the price action. It allows you to see at a glance whether the current market sentiment is leaning towards growth or decline, providing a clearer picture of the underlying trend based on sustained price breaks rather than momentary fluctuations.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
XO_v3
//+------------------------------------------------------------------+
//|                                                           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