Range_v2.2_v2
Download scriptThis tool is designed to help traders visualize price data from higher timeframes directly onto their current trading chart. It allows you to see the "big picture" without having to constantly switch back and forth between different periods (for example, viewing Daily price levels while looking at a 1-hour chart).
Core Functionality
The script identifies and plots four specific data points from a higher timeframe that you choose: the High, Low, Open, and Close prices. By displaying these values on your current screen, it helps identify key support and resistance levels or the general price range established by larger market movements.
How the Logic Works
- Timeframe Selection: You can define which specific timeframe you want to track (such as Daily, Weekly, or 4-hour charts). The script then automatically gathers data from that period.
- Data Mapping: The tool looks at the current price action and maps the corresponding high, low, open, and close values from your selected higher timeframe onto your current view.
- Visual Smoothing: Because a higher timeframe (like a Day) covers many smaller candles (like 15-minute charts), the script ensures that these price levels remain consistent across all the smaller candles within that period. It "holds" the value steady so you can see a clear horizontal reference of where the market opened or reached its peak.
- Dynamic Shifting: The logic includes an adjustment system (Shift). This allows you to move the plotted lines forward or backward on the chart, giving you the flexibility to align the data exactly where you need it for your analysis.
Summary of Benefits
Instead of guessing where a daily candle started or ended while trading on a smaller timeframe, this script draws those boundaries clearly on your screen. It provides a visual bridge between short-term trading and long-term market structure, making it easier to spot whether the current price is trading near the highs or lows of a larger period.
//+------------------------------------------------------------------+
//| Range_v2.mq4 |
//| Copyright © 2006, Forex-TSD.com |
//| Written by IgorAD,igorad2003@yahoo.co.uk |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link "http://www.forex-tsd.com/"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 Tomato
#property indicator_color3 Orange
#property indicator_color4 Lime
//----
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 2
#property indicator_style1 2
#property indicator_style2 2
//----
extern string TimeFrame= "D1";
extern int Shift =0;
extern int AjShift=0;
extern string TimeFrames="1,5,15,30;H1(60);H4;D1;W1;MN";
//----
double UpBuffer[];
double DnBuffer[];
double OpenBuffer[];
double CloseBuffer[];
int TF;
string error="Wrong TimeFrame!";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//IndicatorBuffers(4);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,UpBuffer);
SetIndexLabel(0,"High");
SetIndexDrawBegin(0,0);
//
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,DnBuffer);
SetIndexLabel(1,"Low");
SetIndexDrawBegin(1,0);
//
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,OpenBuffer);
SetIndexLabel(2,"Open");
SetIndexDrawBegin(2,0);
//
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,CloseBuffer);
SetIndexLabel(3,"Close");
SetIndexDrawBegin(3,0);
//
short_name="Range_v2.2("+TimeFrame+")";
IndicatorShortName(short_name);
//----
if (TimeFrame=="M1" || TimeFrame=="1") TF=PERIOD_M1;
else
if (TimeFrame=="M5" || TimeFrame=="5") TF=PERIOD_M5;
else
if (TimeFrame=="M15" || TimeFrame=="15")TF=PERIOD_M15;
else
if (TimeFrame=="M30" || TimeFrame=="30")TF=PERIOD_M30;
else
if (TimeFrame=="H1" || TimeFrame=="60") TF=PERIOD_H1;
else
if (TimeFrame=="H4" || TimeFrame=="240") TF=PERIOD_H4;
else
if (TimeFrame=="D1" || TimeFrame=="1440") TF=PERIOD_D1;
else
if (TimeFrame=="W1" || TimeFrame=="10080") TF=PERIOD_W1;
else
if (TimeFrame=="MN" || TimeFrame=="43200") TF=PERIOD_MN1;
else
if (TimeFrame=="0") TF=Period();
else {Comment(error); TF=Period(); return(0);}
//----
SetIndexShift(0,AjShift + Shift*TF/Period());
SetIndexShift(1,AjShift + Shift*TF/Period());
SetIndexShift(2,AjShift + Shift*TF/Period());
SetIndexShift(3,AjShift + Shift*TF/Period());
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i=0,y=0, prevy=0;
int counted_bars=IndicatorCounted();
double LowArray[],HighArray[],OpenArray[],CloseArray[];
//----
if (TF<Period())
{
SetIndexDrawBegin(0,Bars);
SetIndexDrawBegin(1,Bars);
Comment("Incorrect TimeFrame");
return(0);
}
if(counted_bars > 0) int limit=Bars-counted_bars+TF/Period();
if(counted_bars < 0) return(0);
if(counted_bars ==0) limit=Bars-1;
//----
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TF);
ArrayCopySeries(LowArray,MODE_LOW,Symbol(),TF);
ArrayCopySeries(HighArray,MODE_HIGH,Symbol(),TF);
ArrayCopySeries(OpenArray,MODE_OPEN,Symbol(),TF);
ArrayCopySeries(CloseArray,MODE_CLOSE,Symbol(),TF);
//----
for(i=0,y=0;i<limit;i++)
{
prevy=y;
if (Time[i]<TimeArray[y]) y++;
UpBuffer[i]=HighArray[y];
DnBuffer[i]=LowArray[y];
OpenBuffer[i]=OpenArray[y];
//----
if(y!=prevy)
CloseBuffer[i]=CloseArray[y];
else CloseBuffer[i]=CloseArray[prevy];
}
return(0);
}
//+------------------------------------------------------------------+
Comments