5 day breakout_001

Download script
Author: Bill Sica
5 day breakout_001

This tool is designed to help traders identify significant price boundaries by automatically calculating and displaying the highest and lowest price points over a specific period of time. By visualizing these levels, it allows for a clearer understanding of market structure and potential breakout zones.

Core Logic Overview

The script focuses on analyzing historical daily price data to establish two key horizontal reference lines on your trading chart:

  • High Range Identification: The tool looks back at a user-defined number of previous days (for example, the last 5 days) to find the highest price reached during that timeframe.
  • Low Range Identification: Similarly, it scans the same historical period to pinpoint the lowest price reached.

How It Works on Your Chart

Instead of requiring you to manually scan through past candles to find old peaks and valleys, the script performs this calculation automatically every time the chart updates:

  1. Data Collection: The tool pulls the "High" and "Low" values from the Daily timeframe.
  2. Comparison: It compares these values across the requested number of days to determine the absolute maximum and minimum prices.
  3. Visual Mapping: Once it identifies these two points, it draws two horizontal lines directly on your current chart:
    • A Lime-colored dashed line represents the highest price level of the period.
    • A Magenta-colored dashed line represents the lowest price level of the period.

Trading Application

By providing these visual boundaries, the script helps traders see where the "ceiling" and "floor" of recent price action are located. This is particularly useful for identifying support and resistance levels, as well as spotting moments when the market might break out of a consolidated range into new territory.

13 Views
0 Downloads
0 Favorites
5 day breakout_001
//+------------------------------------------------------------------+
//|                                                 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=1;
//+------------------------------------------------------------------+
//| 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];
   }
}



ObjectDelete("5dayHigh");
ObjectDelete("5dayLow");

ObjectCreate("5dayHigh", OBJ_HLINE,0, CurTime(),phigh);
ObjectSet("5dayHigh",OBJPROP_COLOR,Lime);
ObjectSet("5dayHigh",OBJPROP_STYLE,STYLE_DASH);

ObjectCreate("5dayLow", OBJ_HLINE,0, CurTime(),plow);
ObjectSet("5dayLow",OBJPROP_COLOR,Magenta);
ObjectSet("5dayLow",OBJPROP_STYLE,STYLE_DASH);

ObjectsRedraw();

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

Comments