ronz_higher_timeframe_high_n_low
Download scriptThis script is designed to help traders visualize significant price boundaries by identifying the highest and lowest price points from a larger timeframe and projecting them onto their current chart.
Core Functionality
The primary purpose of this tool is to provide context. Often, traders looking at small timeframes (like 5-minute or 15-minute charts) need to know where the "big picture" highs and lows are located. This script automatically fetches those major levels from a higher timeframe (such as a Weekly or Daily chart) and draws them as visual guides on your active screen.
How it Works
- Higher Timeframe Tracking: You can choose a specific larger timeframe to monitor. The script looks back at that period to find the most recent "High" and "Low" prices.
- Visual Indicators: It plots two distinct lines on your chart:
- An Upper Line representing the high price of the selected higher timeframe.
- A Lower Line representing the low price of that same timeframe.
- Automatic Alignment: The script includes an "Auto Shift" feature. When enabled, it intelligently aligns the data so that the lines correspond correctly with your current chart's timeline, ensuring that the historical highs and lows are positioned accurately relative to the candles you are currently viewing.
- Day Labels: To improve readability, the script identifies the start of new days. It places small text labels (e.g., "MON", "TUE") on the chart at midnight. This helps you navigate the timeline easily while observing where the high and low price boundaries sit during specific trading days.
Key Benefits for Traders
By using this tool, you can see "Support" and "Resistance" levels more clearly. Instead of guessing where the major price boundaries are, you can see exactly where the market has peaked or bottomed out on a larger scale. This helps in identifying potential areas where the price might struggle to break through or where it might find significant turning points.
//+----------------------------------------------------------------+
//| RoNz Higher Timeframe High and Low.mq4 v1.0 (15.01.25) by RoNz |
//+----------------------------------------------------------------+
#property copyright "2015, Rony Nofrianto, Indonesia."
#property link "https://www.mql5.com/en/users/ronz"
#property description "Show High and Low for Selected Timeframe"
#property version "1.0"
#property strict
#property indicator_chart_window
const string FontType="Arial";
const int FontSize=8;
const string Days[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
enum EN_STD_TIMEFRAMES { M1=1,M5=5,M15=15,M30=30,H1=60,H4=240,D1=PERIOD_D1,W1=PERIOD_W1,MN1=PERIOD_MN1 };
//---- Indicator Buffers
double ExtUpperStopBuffer[],ExtLowerStopBuffer[];
//---- Indicator Inputs
extern EN_STD_TIMEFRAMES inpHigherPeriod=PERIOD_W1;//Higher Timeframe
extern bool inpUseAutoShift=false;//Use Auto Shift
int inpStopPointShift=0;//Shift
//----
string MyShortName="RoNz Timeframe High and Low";
#property indicator_buffers 2
#property indicator_label1 "Upper Period High Price"
#property indicator_color1 clrBlue
#property indicator_type1 DRAW_LINE
#property indicator_style1 STYLE_DOT
#property indicator_label2 "Upper Period Low Price"
#property indicator_color2 clrRed
#property indicator_type2 DRAW_LINE
#property indicator_style2 STYLE_DOT
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
MyShortName=MyShortName;
if (inpUseAutoShift)
inpStopPointShift=inpHigherPeriod/Period();
else
inpStopPointShift=0;
ChartSetInteger(0,CHART_SHIFT,true);
ChartSetInteger(0,CHART_SHOW_ASK_LINE,true);
ChartSetInteger(0,CHART_SHOW_PERIOD_SEP,true);
//ObjectsDeleteAll(WindowFind(MyShortName));
//----
IndicatorShortName(MyShortName);
IndicatorDigits(Digits());
IndicatorBuffers(2);
SetIndexBuffer(0,ExtUpperStopBuffer);
SetIndexLabel(0,"Upper Period High Price");
SetIndexShift(0,inpStopPointShift);
SetIndexDrawBegin(0,inpStopPointShift); // Upper Stop Point
SetIndexBuffer(1,ExtLowerStopBuffer);
SetIndexLabel(1,"Upper Period Low Price");
SetIndexShift(1,inpStopPointShift);
SetIndexDrawBegin(1,inpStopPointShift); // Lower Stop Point
//---- Invisible Value
for(int i=0; i<2; i++)
SetIndexEmptyValue(i,0);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
if(IsTesting()) return;
EventKillTimer();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---- Return if no data was calculated before
if(prev_calculated<0) return(-1);
int limit;
//---- Calculating Entry Sign and Stop Point Indicator
if(prev_calculated==0)
{
limit=rates_total;
}
else
{
limit=rates_total;//-(prev_calculated-1);
}
//---- Calculating entry, Stop Point, and Support/Resistance indicator
for(int i=0; i<limit && !IsStopped(); i++)
{
Draw_PriceStopIndicator(i,time[i]);
if(TimeToString(time[i],TIME_MINUTES)=="00:00")
CreateDayLabel("Day"+(string)i,time[i],ExtLowerStopBuffer[i],Days[TimeDayOfWeek(time[i])]);
}
//---- Return calculated bar
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CreateDayLabel(string lblName,datetime time,double price,string lblText)
{
ObjectDelete(lblName);
ObjectCreate(lblName,OBJ_TEXT,0,time,price);
ObjectSetText(lblName,lblText,FontSize-3,FontType,clrGray);
ObjectSetInteger(0,lblName,OBJPROP_SELECTABLE,false);
return true;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Draw_PriceStopIndicator(int i,datetime dtTime)
{
//---- Setting Upper/Lower Stop Indicator
int UpperPeriod=inpHigherPeriod;
int shift=iBarShift(NULL,UpperPeriod,dtTime);
ExtUpperStopBuffer[i]=iHigh(NULL,UpperPeriod, shift);
ExtLowerStopBuffer[i]=iLow(NULL,UpperPeriod, shift);
}
//+------------------------------------------------------------------+
Comments