5 bar reversal v0[1][1].5_v1
Download scriptThis technical tool is designed to analyze price action by comparing the relative highs and lows of specific historical periods on a trading chart. Its primary objective is to identify potential trend reversals by detecting significant "extremes" in price movement over short intervals.
How the Logic Works
The script operates by scanning back through the price history to compare two distinct segments of data simultaneously. It looks at current price behavior and measures it against what occurred just slightly earlier in time.
1. Identifying Key Benchmarks For every point on the chart, the tool calculates four specific price boundaries:
- The highest peak reached in a recent 5-bar window.
- The lowest valley reached in a recent 5-bar window.
- The corresponding "past" high and low from a previous period.
- The closing price of the current candle.
2. Detecting Reversal Signals The script looks for specific mathematical contradictions between these benchmarks to signal a potential change in market direction:
- Sell Signals (Bearish): The tool looks for a situation where the current high peak is significantly higher than the past peak, but the current closing price has dropped below the previous valley. This suggests that while the price reached a new high, it is now losing momentum and retreating aggressively.
- Buy Signals (Bullish): Conversely, it looks for instances where the current low valley is lower than the previous valley, yet the current closing price is holding above the previous high peak. This indicates that even though the price dipped, it has "rejected" that lower level and is showing strength.
Visual Representation
When these specific conditions are met, the script places visual markers (arrows) on your chart:
- Red Arrows: Appear at the top of a candle to indicate a potential downward move (Sell).
- Yellow Arrows: Appear at the bottom of a candle to indicate a potential upward move (Buy).
Essentially, this tool filters out standard market noise by highlighting moments where price action breaks out of its previous "boundaries" while simultaneously showing signs of exhaustion or rejection in the opposite direction.
//+------------------------------------------------------------------+
//| 5 Bars.mq4 |
//| Copyright © 2006, EvgeniX |
//|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, EvgeniX"
#property link "EvgeniX"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 3
#property indicator_color2 Yellow
#property indicator_width2 3
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double fhigh;
double flow;
double fclose;
double shigh;
double slow;
double sclose;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,4);
SetIndexArrow(0,218);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW,4);
SetIndexArrow(1,217);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
for(int i=1 ;i<=500;i++)
{
Comment (i);
shigh=High[Highest(NULL, 0,2,5,i)];
slow=Low[Lowest(NULL,0,1,5,i)];
sclose=Close[i];
fhigh=High[Highest(NULL, 0, 2, 5, (i+5))];
flow=Low[Lowest(NULL,0,1,5,(i+5))];
fclose=Close[i+9];
//ExtMapBuffer2[i+5]=High[i]+0.0005;
//ExtMapBuffer1[i]=High[i]+0.0005;
if ((shigh>fhigh) && (sclose<flow))
{
ExtMapBuffer1[i+5]=High[i+5]+0.0005;
// if (i==500)Alert ("5Bar Reverse S E L L ", Symbol()," M",Period());
}
if ((slow<flow) && (sclose>fhigh))
{
ExtMapBuffer2[i+5]=Low[i+5]-0.0005;
// if (i==500) Alert ("5Bar Reverse B U Y ", Symbol()," M",Period());
}
// Comment(Close[i+4]+" "+" "+DoubleToStr(i,1)+" "+TimeToStr(Time[i],TIME_MINUTES)+
// "\n"+" "+shigh+" "+slow+" "+sclose+
// "\n"+" "+fhigh+" "+flow+" "+fclose);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments