5 bar reversal v1[real][1].5_v2
Download scriptThis technical tool is designed to identify potential trend reversals on a trading chart by analyzing price action patterns over specific historical intervals. Rather than following standard moving averages, it focuses on comparing the relationship between "highs" and "lows" across two different windows of time.
Core Logic and Methodology
The script scans back through your price history (specifically looking at 500 bars) to evaluate the current market structure against a previous benchmark. It performs a comparative analysis between:
- Current Price Action: The highest peaks and lowest valleys achieved in the most recent 5-bar window.
- Historical Benchmark: The highest peaks and lowest valleys from a slightly older 5-bar window (offsetting back by several bars).
By comparing these two windows, the script looks for specific "breakout" behaviors that suggest the market momentum is shifting.
Signal Identification
The tool provides two distinct types of alerts based on price behavior:
1. Sell Signals (Bearish Reversal) The script identifies a potential "Sell" opportunity when the following two conditions occur simultaneously:
- The highest price in the recent window is significantly higher than the historical benchmark's high.
- The current closing price has dropped below the historical benchmark's low.
- Visual: When triggered, it places a red arrow on the chart and sends an alert to your platform.
2. Buy Signals (Bullish Reversal) The script identifies a potential "Buy" opportunity when these conditions are met:
- The lowest price in the recent window is significantly lower than the historical benchmark's low.
- The current closing price has risen above the historical benchmark's high.
- Visual: When triggered, it places a yellow arrow on the chart and sends an alert to your platform.
Summary of User Experience
Instead of requiring you to manually track every peak and valley, this script automates that comparison. It acts as a "reversal detector," highlighting moments where price action has moved aggressively enough to break out of previous historical boundaries. When these specific criteria are met on the most recent bar, the tool provides an immediate visual cue (an arrow) and a pop-up notification to inform you of the potential trend change.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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;
double ttfn;
//+------------------------------------------------------------------+
//| 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++)
for(int i=500; i>0; 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;
Comment (i);
if ((shigh>fhigh) && (sclose<flow))
{
ExtMapBuffer1[i]=High[i+5]+0.0005;
if (i==1 && !ttfn )Alert ("5Bar Reverse S E L L ", Symbol()," M",Period());
{
ttfn=Time[0];
}
}
if ((slow<flow) && (sclose>fhigh))
{
ExtMapBuffer2[i]=Low[i+5]-0.0005;
{
if (i==1 && !ttfn ) Alert ("5Bar Reverse B U Y ", Symbol()," M",Period());
ttfn=Time[0];
}
}
// Comment(Close[i+4]+" "+" "+DoubleToStr(i,1)+" "+TimeToStr(Time[i],TIME_MINUTES)+
// "\n"+" "+shigh+" "+slow+" "+sclose+
// "\n"+" "+fhigh+" "+flow+" "+fclose);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments