I_XO_A_H_v2
Download scriptThis technical indicator is designed to track and visualize significant price movements by monitoring the "momentum" or directional shifts in a market's price action. Instead of reacting to every small fluctuation, the script focuses on identifying substantial price jumps that exceed a specific threshold defined by the user.
How the Logic Works
1. Setting the Threshold (The "Box Size") The core of this script relies on a user-defined parameter called the "Box Size." Think of this as a sensitivity filter. It establishes a minimum distance that a price must travel before the indicator considers it a meaningful move. If the price moves only a tiny amount, the indicator ignores it; if it moves beyond this "Box Size," the script triggers a signal.
2. Tracking Highs and Lows The script constantly monitors the closing price of each candle on your chart. It keeps track of the most recent significant high and low points. By comparing the current price to these previous benchmarks, the tool determines whether the market is making a new "breakout" in either direction.
3. Identifying Breakouts The logic follows a simple "if/then" progression:
- Upward Movement: If the current price rises higher than the previous significant high by more than the specified Box Size, the script registers an upward trend signal.
- Downward Movement: Conversely, if the current price drops lower than the previous significant low by more than the Box Size, it registers a downward trend signal.
4. Visual Representation The indicator translates these movements into a visual histogram at the bottom of your trading platform:
- Green Histograms: These represent consecutive upward breakouts. The script counts how many times the price has pushed higher in a row.
- Red Histograms: These represent consecutive downward breakouts. Similarly, it tracks how many times the price has dropped below previous levels.
Summary for Traders
Essentially, this tool acts as a momentum tracker. It filters out "noise" (minor price vibrations) and highlights sustained trends. By looking at the height of the histograms, you can see the strength of a trend: a growing histogram indicates that the market is consistently breaking through new levels in one direction, while a change in color signals that the momentum has shifted toward the opposite direction.
//+------------------------------------------------------------------+
//| Amir.mq4 |
//| Copyright © 2005, Amir |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Amir"
#property link ""
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- input parameters
extern int BoxSize=15;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int Cur=0;
int KirUp=0;
int KirDn=0;
int kr=0;
int no=0;
double valueh=0;
double valuel=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,"XOUP");
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexLabel(1,"XODOWN");
IndicatorShortName("I-XO-A-H");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int CurrentBar;
double Hi,Lo,Curb;
int counted_bars=IndicatorCounted();
//---- TODO: add your code here
//----Calculation---------------------------
for(int i=0;i<=Bars;i++)
{
CurrentBar=Bars-i;
if (Cur<1)
{
Hi=Close[CurrentBar];
Lo=Close[CurrentBar];
Cur=1;
}
Curb=Close[CurrentBar];
if (Curb>(Hi+BoxSize*Point))
{
Cur+=1;
Hi=Curb;
Lo=Curb-BoxSize*Point;
KirUp=1;
KirDn=0;
kr+=1;
no=0;
}
if (Curb<(Lo-BoxSize*Point))
{
Cur+=1;
Lo=Curb;
Hi=Curb+BoxSize*Point;
KirUp=0;
KirDn=1;
no+=1;
kr=0;
}
valueh=kr;
valuel=0-no;
ExtMapBuffer1[CurrentBar]=valueh;
ExtMapBuffer2[CurrentBar]=valuel;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments