5 bar reversal v0[1][1].5_v2
Download scriptThis script is designed as a visual trading indicator for the MetaTrader platform. Its primary purpose is to identify specific price action patterns on a chart by comparing the movement of current price candles against a historical window of data.
Instead of relying on complex mathematical formulas, the logic focuses on "Price Action Reversals" based on the following mechanics:
Core Logic Overview
The indicator scans the market history to find moments where the price makes a significant shift in direction. It does this by looking at two distinct windows of time: a "Current Window" (the most recent 5 bars) and a "Previous Window" (a block of bars further back in time).
By comparing these two periods, the script looks for specific discrepancies in high and low prices to predict where a trend might be turning.
How it Identifies Signals
The script generates two types of visual signals on your chart:
1. Sell Signals (Red Arrows) The tool looks for a "Bearish Reversal." It triggers a signal when the following conditions are met simultaneously:
- The highest price reached in the current window is significantly higher than the highest price in the previous window.
- However, the closing price of the current candle is lower than the lowest price recorded in that previous window.
- Essentially, it identifies a "spike" followed by a sharp drop, suggesting that buyers may be exhausted and sellers are taking over.
2. Buy Signals (Yellow Arrows) The tool looks for a "Bullish Reversal." It triggers a signal when the following conditions are met simultaneously:
- The lowest price reached in the current window is significantly lower than the lowest price in the previous window.
- However, the closing price of the current candle is higher than the highest price recorded in that previous window.
- This identifies a "dip" followed by a sharp recovery, suggesting that sellers are exhausted and buyers are pushing the price back up.
Visual Execution
When these specific conditions are met, the script automatically places an arrow on your chart:
- Red Arrows appear above the price to signal potential selling opportunities.
- Yellow Arrows appear below the price to signal potential buying opportunities.
The indicator is designed to help traders filter out market noise by highlighting only those moments where the price action suggests a significant shift in momentum between two different time periods.
/*-----------------------------+
| |
| 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;
//+------------------------------------------------------------------+
//| 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