5_bar_sig
Download scriptThis tool is designed as a visual market indicator that identifies specific price action patterns to help traders spot potential buying and selling opportunities. It operates by analyzing the relationship between recent price movements and past price levels over a defined window of time.
Core Logic Overview
The script scans your trading chart to compare the current "price action" against a historical reference point (specifically looking back at 5 bars). It looks for instances where the market has broken out of a previous range in a significant way, suggesting a shift in momentum.
How it Identifies Opportunities
The tool monitors two primary conditions to generate signals:
- Sell Signals: The logic looks for a situation where the current price's highest point is higher than the high of the previous 5-bar period, while the current closing price is lower than the low of that same previous period. Essentially, it detects a "breakout" movement that suggests the price might be ready to reverse or retreat.
- Buy Signals: Conversely, the tool looks for instances where the current price's lowest point is lower than the historical low of the previous 5-bar period, while the current closing price is higher than the previous high. This identifies a bullish move where the price is pushing upward beyond its recent boundaries.
Visual Representation
Instead of showing standard lines or moving averages, this script uses a histogram format in a separate window below your main chart. When the specific mathematical conditions mentioned above are met, it plots distinct visual markers:
- Red Markers: These represent the identified "Sell" conditions.
- Yellow Markers: These represent the identified "Buy" conditions.
By providing these visual cues, the script simplifies the process of spotting momentum shifts, allowing you to see at a glance where the price action has breached previous boundaries based on the defined 5-bar window.
//+------------------------------------------------------------------+
//| 5 Bars.mq4 |
//| Copyright © 2006, EvgeniX |
//|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, EvgeniX"
#property link "EvgeniX"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 1
#property indicator_color2 Yellow
#property indicator_width2 1
#property indicator_level1 0
extern int NrOfBars=500;
extern int bars1 = 5;
//---- 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_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,EMPTY_VALUE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,EMPTY_VALUE);
//----
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<=NrOfBars;i++)
{
shigh=High[iHighest(NULL, 0,2,bars1,i)];
slow=Low[iLowest(NULL,0,1,bars1,i)];
sclose=Close[i];
fhigh=High[iHighest(NULL, 0, 2, bars1, (i+bars1))];
flow=Low[iLowest(NULL,0,1,bars1,(i+bars1))];
fclose=Close[i+bars1];
if ((shigh>fhigh) && (sclose<flow))
{//SELL
ExtMapBuffer1[i+5]=-1;//High[i+5]+0.0005;
}
if ((slow<flow) && (sclose>fhigh))
{//BUY
ExtMapBuffer1[i+5]=1;//Low[i+5]-0.0005;
}
// Print(ExtMapBuffer2[i+5]);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments