DYNAMIC_Breakout_Daily_Range_v11

Download script
Author: Copyright � 2006, Ogeima
DYNAMIC_Breakout_Daily_Range_v11

This tool is designed to provide traders with a sophisticated mathematical overview of market volatility and price movement potential. Rather than relying on simple guesswork, it calculates the "trading room" available for a specific currency or asset by analyzing historical data across multiple timeframes simultaneously.

Core Functionality

The logic operates by measuring the distance between the highest and lowest prices (the "range") over several distinct periods. It specifically looks at:

  • Short-term volatility: The previous single day.
  • Medium-term volatility: The average range over the past 5 days (weekly) and 20 days (monthly).
  • Long-term volatility: The average range over the past 240 days (yearly).

By aggregating these different time horizons, the tool creates a comprehensive "Average Daily Range." This helps a trader understand if the current market is behaving normally compared to its history over weeks, months, and years.

Dynamic Analysis & Risk Management

Beyond just showing historical averages, the script performs real-time calculations based on the current market price:

  • Price Positioning: It identifies how much "room" remains for the price to move up or down before it hits the average volatility limits.
  • Targeted Risk Assessment: Using a customizable Risk-to-Reward ratio, the tool automatically calculates potential Stop-Loss levels. It does this by taking the remaining "room" in the market and dividing it by your desired reward multiplier.
  • Trade Symmetry: It provides specific price points for both long (buy) and short (sell) positions, ensuring that your risk is always mathematically proportional to the expected movement of the market.

User Interface

The script simplifies complex data into a clear, text-based dashboard on your trading chart. At a glance, you can see:

  1. The average ranges for the previous day, week, month, and year.
  2. The current "Room Up" and "Room Down" values (the remaining space for price action).
  3. Precise Stop-Loss price levels for both buying and selling scenarios.

Essentially, this tool transforms historical volatility into actionable data, helping you determine if there is enough "space" left in the market to take a trade safely based on your specific risk preferences.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
7 Views
0 Downloads
0 Favorites
DYNAMIC_Breakout_Daily_Range_v11
//+------------------------------------------------------------------+
//|                                                   TSR_Ranges.mq4 |
//|                                         Copyright © 2006, Ogeima |
//|                                             ph_bresson@yahoo.com |
//| made for FXiGoR for the TSR Trend Slope Retracement method       |
//| modified to the DYNAMIC Daily Range Breakout System             |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Ogeima"
#property link      "ph_bresson@yahoo.com"

#property indicator_chart_window
//---- input parameters
extern double  Risk_to_Reward_ratio =  3.0;
int nDigits;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   if(Symbol()=="GBPJPY" || Symbol()=="EURJPY" || Symbol()=="USDJPY" || Symbol()=="GOLD")  nDigits = 2;
   else nDigits = 4;

   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   //----
   int R1=0,Rweek=0, Rmonth=0,Ryear=0,RAvg=0;
   int RoomUp=0,RoomDown=0,StopLoss_Long=0,StopLoss_Short=0;
   double   SL_Long=0,SL_Short=0;
   double   low0=0,high0=0;
   string   Text="";
   int i=0;

   R1 =  (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   for(i=1;i<=5;i++)
      Rweek    =    Rweek  +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=20;i++)
      Rmonth   =    Rmonth +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=240;i++)
      Ryear   =    Ryear +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;

   Rweek = Rweek/5;
   Rmonth = Rmonth/20;
   Ryear = Ryear/240;
   RAvg  =  (R1+Rweek+Rmonth+Ryear)/4;    

   low0  =  iLow(NULL,PERIOD_D1,0);
   high0 =  iHigh(NULL,PERIOD_D1,0);
   RoomUp   =  RAvg - (Bid - low0)/Point;
   RoomDown =  RAvg - (high0 - Bid)/Point;
   StopLoss_Long  =  RoomUp/Risk_to_Reward_ratio;
   SL_Long        =  Bid - StopLoss_Long*Point;
   StopLoss_Short =  RoomDown/Risk_to_Reward_ratio;
   SL_Short       =  Bid + StopLoss_Short*Point;


   Text =   "Average 1/2 Day Range:   " +  RAvg/2 + "\n"  +
            "Average Day  Range:       " +  RAvg + "\nAverage DAILY Range During:\n"  +
             
            "Previous Day:    " +  R1   + "\n" + 
            "Previous Week:   " +  Rweek   + "\n" + 
            "Previous Month:  " +  Rmonth  + "\n"+
            "Previous Year:    " +  Ryear  + "\n";
   Text =   Text +
            "Room Up:      " + RoomUp              + "\n" +
            "Room Down:  " + RoomDown            + "\n" ;

   Comment(Text);

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

Comments