![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello guys,
I tried to use this code.
int a =TimeCurrent();
a=a-(Minute()*60);
string var1=TimeToStr(a,TIME_DATE|TIME_MINUTES); // var1='2008.08.05 23:00'
//datetime var1=D'2008.08.05 23:00';
int shift=iBarShift(NULL,PERIOD_H1,var1);
double opening_price = iOpen(NULL,PERIOD_H1,shift);
...
Using TimeToStr function, i don't get the real iOpen on the chart, but, if i use the some specific time using: datetime var1=D'2008.08.05 18:00' i get the real one!
Can anyone help me with this.
Where is my mistake?
Many thanks in advance.