DYNAMIC Breakout Daily Range_v10
Download scriptThis tool is designed to help traders analyze market volatility and potential price movement by calculating daily price ranges. Instead of guessing how much a currency pair or commodity might move, the script uses historical data to provide a mathematical foundation for setting goals and managing risk.
How the Logic Works
1. Historical Range Analysis The script begins by looking at "Daily" charts to determine the distance between the highest and lowest prices reached during specific periods. It captures several different snapshots of history:
- The range of the single previous day.
- The average range over the last 5 days.
- The average range over the last 10 days.
- The average range over the last 20 days.
2. Calculating the "Average Day Range" By aggregating these different timeframes (1, 5, 10, and 20 days), the script calculates a combined Average Day Range. This provides a smoothed perspective of how much the asset typically moves, filtering out one-time spikes while still accounting for recent trends.
3. Measuring Available "Room" The tool then compares the current market price against the high and low of the current day to see how much "room" is left for the price to move before hitting that average range:
- Room Up: Calculates how much further the price can climb based on the calculated averages.
- Room Down: Calculates how much further the price can drop based on the calculated averages.
4. Dynamic Risk Management One of the most practical features of this script is its ability to project potential Stop Loss levels based on a user-defined Risk-to-Reward ratio.
- It takes the "Room" (the distance to the average target) and divides it by your desired ratio (e.g., 3.0).
- It then automatically projects a Stop Loss price for both "Long" (buying) and "Short" (selling) positions.
Summary of Information Displayed
The script displays a real-time text summary directly on your trading chart, showing:
- All the specific historical averages (1, 5, 10, and 20 days).
- The calculated Average Day Range.
- The remaining "Room Up" and "Room Down" for the current session.
By providing these numbers instantly, the script allows you to see at a glance whether a trade has enough space to reach a profit target while ensuring your risk parameters remain mathematically aligned with market volatility.
//+------------------------------------------------------------------+
//| 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,R5=0,R10=0,R20=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++)
R5 = R5 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
for(i=1;i<=10;i++)
R10 = R10 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
for(i=1;i<=20;i++)
R20 = R20 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
R5 = R5/5;
R10 = R10/10;
R20 = R20/20;
RAvg = (R1+R5+R10+R20)/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 Day Range: " + RAvg + "\n" +
"Prev 01 Day Range: " + R1 + "\n" +
"Prev 05 Days Range: " + R5 + "\n" +
"Prev 10 Days Range: " + R10 + "\n" +
"Prev 20 Days Range: " + R20 + "\n";
Text = Text +
"Room Up: " + RoomUp + "\n" +
"Room Down: " + RoomDown + "\n" ;
Comment(Text);
return(0);
}
//+------------------------------------------------------------------+
Comments