5 Day BreakOut_v2
Download scriptThis script is designed to help traders identify significant price boundaries by automatically calculating and displaying the highest and lowest price points reached over a specific timeframe—in this case, the last 5 trading days. By visualizing these levels, it helps users see whether the current market price is approaching a major historical "ceiling" or "floor."
How the Logic Works
1. Data Collection The script begins by looking back at the daily chart data. It specifically gathers the "High" and "Low" prices for each day over a period defined by the user (set to 5 days by default).
2. Identifying Key Boundaries Instead of just showing today's price, the logic scans through those 5 days of history to find two specific values:
- The 5-Day High: The highest price reached at any point during that 5-day window.
- The 5-Day Low: The lowest price reached at any point during that 5-day window.
3. Visual Feedback on the Chart Once these two boundaries are identified, the script draws two solid horizontal lines directly onto your trading screen:
- A Green Line: Represents the 5-day High level.
- A Red Line: Represents the 5-day Low level.
Additionally, the script displays a text comment on the chart showing the exact numerical values of these high and low levels so you can track them precisely as the market moves.
4. Real-Time Monitoring The script constantly monitors the "Live" market price (the Bid price). It is designed to recognize when the current price touches or crosses these significant boundaries:
- If the price drops to or below the Red Line, it signifies the market has hit a 5-day low.
- If the price rises to or above the Green Line, it signifies the market has hit a 5-day high.
Purpose for the Trader
The goal of this logic is to provide immediate visual clarity. Rather than manually calculating historical highs and lows, the script automates this process, allowing you to see instantly if the market is experiencing a "breakout" (moving past a previous boundary) or a "bounce" (reacting when it hits a previous boundary).
//+------------------------------------------------------------------+
//| 5 Day BreakOut.mq4 |
//| Copyright © 2007, Bill Sica |
//| http://www.tetsuyam a.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Bill Sica"
#property link "http://www.tetsuyam a.com"
#property indicator_chart_window
//---- input parameters
extern int DAYS=5;
//---- Variables
double yesterday_close,Current_price;
double phigh,plow,plownew;
int i=1;
//---- Buffers
double daily_high[20] ;
double daily_low[20] ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
Current_price= MarketInfo( Symbol(), MODE_BID);
//---- TODO: add your code here
ArrayResize( daily_high, DAYS);
ArrayResize( daily_low, DAYS);
ArrayInitialize( daily_high, 0);
ArrayInitialize( daily_low, 0);
ArrayCopySeries( daily_low, MODE_LOW, Symbol(), PERIOD_D1);
ArrayCopySeries( daily_high, MODE_HIGH, Symbol(), PERIOD_D1);
/* initialise */
plow = daily_low[ 1];
phigh = daily_high[1];
for(i=1;i<DAYS; i++)
{
if(plow > daily_low[i])
{
plow = daily_low[i] ;
}
}
for(i=1;i<DAYS; i++)
{
if(phigh < daily_high[i])
{
phigh = daily_high[ i];
}
}
Comment("\n5dayH ",phigh,"\n5dayL ",plow);
ObjectDelete( "5dayHigh" );
ObjectDelete( "5dayLow" );
ObjectCreate( "5dayHigh" , OBJ_HLINE,0, CurTime(),phigh) ;
ObjectSet("5dayHigh ",OBJPROP_COLOR,SpringGreen);
ObjectSet("5dayHigh ",OBJPROP_STYLE,STYLE_SOLID);
ObjectCreate( "5dayLow" , OBJ_HLINE,0, CurTime(),plow) ;
ObjectSet("5dayLow" ,OBJPROP_COLOR,Red) ;
ObjectSet("5dayLow" ,OBJPROP_STYLE,STYLE_SOLID);
ObjectsRedraw( );
if (Bid <= plow)
{
// Alert(Symbol( ), " has hit a 5 day LOW. Bounce or Breakout?"," -",plow);
}
if (Bid >= phigh)
{
//Alert(Symbol( ), " has hit a 5 day HIGH. Bounce or Breakout?"," -",phigh);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments