5 day breakout

Download script
Author: Bill Sica
5 day breakout

This script is designed to provide traders with a visual representation of the price boundaries established over a specific period—in this case, the last five trading days. By identifying these key levels, it helps traders recognize significant "breakout" zones where the market might be preparing to move in a new direction.

How the Logic Works

The script follows a straightforward process to identify and display these price levels:

1. Data Collection The tool begins by looking back at the daily historical data for the current currency pair or asset. It specifically isolates the "High" and "Low" prices for each of the last five days.

2. Identifying Extremes Once it has gathered the high and low points for those five days, the script performs a comparison:

  • The 5-Day Low: It scans through the data to find the absolute lowest price reached during that period.
  • The 5-Day High: It scans the data to find the absolute highest price reached during that period.

By focusing on these two extremes, the script ignores minor fluctuations within the week and focuses only on the outer boundaries of the recent price action.

3. Visual Mapping After determining these two values, the script automatically draws two horizontal lines directly onto your trading chart:

  • The High Boundary: Displayed as a solid Spring Green line at the highest point reached over the last five days.
  • The Low Boundary: Displayed as a solid Red line at the lowest point reached over the last five days.

Purpose for the Trader

The goal of this logic is to provide an immediate visual cue of the current "trading range." When the market price stays between these two lines, it is considered to be consolidating. If the price breaks above the Green line or below the Red line, it signals a potential breakout, alerting the trader that the market may be entering a new trend.

7 Views
0 Downloads
0 Favorites
5 day breakout
//+------------------------------------------------------------------+
//|                                                 5dayBreakout.mq4 |
//|                                                        Bill Sica |
//|                                         http://www.tetsuyama.com |
//+------------------------------------------------------------------+
#property copyright "Bill Sica"
#property link      "http://www.tetsuyama.com"

#property indicator_chart_window
//---- input parameters
extern int       DAYS=5;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
  {
//---- indicators

//---- indicators

   

//----
   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double daily_high[20];
   double daily_low[20];
   double yesterday_close;
   double phigh,plow;
   int i=1;

//---- 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();

   return(0);
  }
//+------------------------------------------------------------------

Comments