5 day breakout_v1

Download script
Author: Bill Sica
5 day breakout_v1

This tool is designed to help traders identify key price boundaries by automatically calculating and visualizing the highest and lowest price points reached over a specific recent timeframe—in this case, the last 5 trading days. By establishing these "breakout" levels, the script provides a clear visual reference for identifying significant support and resistance areas on your chart.

How the Logic Works

1. Data Collection The script begins by looking back at the historical daily price data of the specific financial instrument you are viewing. It ignores the current, unfinished day and focuses exclusively on completed trading sessions to ensure the data remains stable and reliable.

2. Identifying Extremes Once it has gathered the data for the selected period (the 5-day window), the script performs two separate scans:

  • The Low Point: It searches through the daily "Low" prices to find the absolute lowest price reached during that timeframe.
  • The High Point: It searches through the daily "High" prices to find the absolute highest price reached during that timeframe.

3. Visualizing the Boundaries After determining these two critical values, the script draws two horizontal lines directly onto your trading chart:

  • The High Line: Displayed in a bright green color, this line marks the ceiling of the recent 5-day range.
  • The Low Line: Displayed in red, this line marks the floor of the recent 5-day range.

4. Real-Time Updates The script is designed to refresh automatically. As new days conclude and new price data becomes available, it recalculates these extremes and moves the lines accordingly. This ensures that you are always looking at the most current 5-day boundary without having to perform any manual calculations.

Practical Application

By providing these automated levels, the script allows traders to see at a glance where the "breakout" points are. When the price moves outside of these green and red lines, it often signals a shift in market momentum, potentially indicating a new trend or a significant expansion in volatility.

9 Views
0 Downloads
0 Favorites
5 day breakout_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                 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