PrevDayHL
Download scriptThis script is designed as a visual tool for traders who want to keep a constant eye on the previous day's price extremes while analyzing current market movements. By automatically plotting specific historical data points on your chart, it helps you identify key levels of support and resistance without having to manually search through past candles.
How It Works
The core logic of this script revolves around identifying two specific price points from the preceding trading day: the highest price reached and the lowest price reached.
Instead of showing you the data for the current day, the script "looks back" at the completed daily candle that occurred just before the current timeframe began. It then extracts those two extreme values and carries them forward into your current view.
Visual Representation
The script creates two distinct visual lines on your trading chart:
- The Upper Boundary: This represents the highest price point achieved during the previous full trading day.
- The Lower Boundary: This represents the lowest price point achieved during the previous full trading day.
Purpose and Utility
By displaying these two levels simultaneously, the script provides a clear visual "envelope" of where the market traded yesterday. For many traders, these levels serve as significant psychological markers:
- Breakout Identification: You can easily see if the price is currently breaking above yesterday's high or dropping below yesterday's low.
- Range Awareness: It defines the immediate trading range, helping you understand how the current price compares to the recent historical volatility.
- Simplified Analysis: It removes the need for manual calculation, ensuring that these critical levels are always visible and consistent across your various charts.
//+------------------------------------------------------------------+
//| PrevDayHL.mq4 |
//| Scriptong |
//| scriptong@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Scriptong"
#property link "scriptong@mail.ru"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if (counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for (int i=0; i<limit; i++)
{
int PrevDay = iBarShift(Symbol(), PERIOD_D1, Time[i])+1;
ExtMapBuffer1[i] = iHigh(Symbol(), PERIOD_D1, PrevDay);
ExtMapBuffer2[i] = iLow(Symbol(), PERIOD_D1, PrevDay);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments