Problems with TimeToStr function

 

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.

 

iBarShift() third parameter expects a time value which is an integer, not a string.

The compiler is not rigorous enough to emit an error.

 
phy wrote >>

iBarShift() third parameter expects a time value which is an integer, not a string.

The compiler is not rigorous enough to emit an error.

Thanks phy.

Reason: