Price Data Components
Miscellaneous
0
Views
0
Downloads
0
Favorites
DailyHighLowHistory AHA 0_1
//+------------------------------------------------------------------+
//| 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
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---