XO_v1
Download scriptThis technical indicator is designed to track and visualize market momentum by identifying sustained trends in price action. Instead of simply looking at whether the price is going up or down in a single moment, the logic focuses on "breakout" behavior—detecting when the price pushes significantly beyond previous highs or lows over a specific distance.
Core Mechanics
The script functions by monitoring two primary boundaries: a high-water mark and a low-water mark. It uses a user-defined sensitivity setting (the period) to determine how much movement is required to register as a "significant" trend change.
How it identifies trends:
- Upward Momentum: The script tracks the highest price reached during a specific move. If the current market price exceeds that high by more than the defined threshold, the indicator registers an upward push. It essentially counts how many consecutive times the price has successfully "broken out" to new highs. This is visualized as an upward signal on your chart.
- Downward Momentum: Conversely, the script monitors the lowest price reached. If the current market price drops below that low by more than the defined threshold, it registers a downward push. It tracks these consecutive breakdowns to create a downward signal.
Visual Output
The indicator provides a clear, binary visual representation of market sentiment:
- Positive Signal: When the price consistently breaks higher thresholds, it generates an "XO Up" signal.
- Negative Signal: When the price consistently breaks lower thresholds, it generates an "XO Down" signal.
By quantifying these consecutive breakouts, the tool helps traders distinguish between minor market noise and sustained directional moves, allowing for a clearer view of which way the momentum is currently pulling.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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