DailyHighLowHistory AHA 0_1
Download scriptThis tool is designed to help traders visualize historical price boundaries by automatically identifying and plotting the high and low points of previous trading days on a current chart. Instead of requiring you to manually look up historical data or calculate previous price levels, the script handles these calculations automatically for every candle on your screen.
How it Works
The core logic focuses on "Day-to-Day" memory. The script scans through the history of the currency pair or asset you are currently viewing and performs the following steps:
- Time Identification: For every point in time shown on your chart, the script identifies which specific calendar day that period belongs to.
- Historical Retrieval: It then "looks back" specifically at the previous full trading day (the 24-hour period preceding the current one).
- Price Extraction: From that previous day, it extracts two critical pieces of data: the highest price reached (the "Daily High") and the lowest price reached (the "Daily Low").
- Visual Mapping: It then takes those two values and projects them onto your current chart.
Key Features for the User
- Automatic Alignment: You don't need to tell the script which day to look at; it dynamically calculates the correct "previous day" based on wherever you are currently looking on the chart.
- Visual Indicators: The tool renders these levels as lines. The Highs and Lows are distinguished by different colors (Green and Red), allowing you to quickly see where price sat the day before.
- Contextual Awareness: By mapping yesterday's extremes onto today's price action, it provides a clear visual reference for "Support" and "Resistance" levels based on historical volatility.
In short, this script simplifies your technical analysis by constantly drawing the boundaries of the previous day's market activity, helping you see at a glance how today's price is reacting relative to yesterday's range.
//+------------------------------------------------------------------+
//| DailyHighLowHistory AHA 0_1.mq4 |
//| Hua Ai (aha) |
//| |
//+------------------------------------------------------------------+
#property copyright "Hua Ai (aha)"
#property link ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- buffers
double PrevHigh[];
double PrevLow[];
bool startup;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,PrevHigh);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,PrevLow);
//----
startup=true;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
startup=false;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
datetime yesterday, today;
string tempdate, sy, sm, sd;
double yesterday_close,yesterday_high,yesterday_low;
double R;
int shift, offset, year, month, day, limit, counted_bars;
counted_bars=IndicatorCounted();
if (counted_bars<0) return(-1); // check for possible errors
if (counted_bars>0) counted_bars--; // last counted bar will be recounted
offset=PERIOD_D1/Period();
limit=Bars-offset-counted_bars;
for(int i=limit;i>=0;i--)
{
//if (!startup) return(0);
//if(startup)
//{
today=iTime(NULL, 0, i);
//Print("yesterday=", TimeToStr(yesterday));
year=TimeYear(today);
month=TimeMonth(today);
day=TimeDay(today);
if(month<10) sm="0"+month; else sm=month;
if(day<10) sd="0"+day; else sd=day;
tempdate=year+"."+sm+"."+sd+" 00:00";
//Print("tempdate=", tempdate);
today=StrToTime(tempdate);
shift=iBarShift(NULL,PERIOD_D1,today)+1;
//if(TimeDayOfWeek(today)==0) shift+=1;
if (TimeDayOfWeek(today)==1) shift+=1;
//yesterday_close=iClose(NULL,PERIOD_D1,shift);
yesterday_high=iHigh(NULL,PERIOD_D1,shift);
yesterday_low=iLow(NULL,PERIOD_D1,shift);
// if(yesterday==D'2006.11.06 00:00')
{
//Print("yesterday_close=", yesterday_close);
//Print("yesterday_high=", yesterday_high);
//Print("yesterday_low=", yesterday_low);
}
PrevHigh[i] = yesterday_high;
PrevLow[i] = yesterday_low;
//}
}
startup=false;
//----
return(0);
}
//+------------------------------------------------------------------+
Comments