to cast a value use brackets eg thisBarOpened = (datetime)Time[0];
But datetime is now 64 bit and wont fit in an int (which is 32bit), so why not just leave thisBarOpened as a datetime ?
datetime thisBarOpened=Time[0];
LouK:
If you double post you will find your posts being deleted . .. if you carry on after that you will find your User ID BANNED. Please do not double post: https://www.mql5.com/en/forum/149338
Can anyone tell me how to correct datetime for this update?
This is a snippet that had been working for over a year. It's purpose is to detect when a new bar has drawn. Was bullet proof. Not now. Doesn't work following the upgrade.
int checkTime(){int thisBarOpened=datetime Time[0];
if(thisBarOpened!=lastBarOpened){newBar=true;lastBarOpened=thisBarOpened;}
LouK:
Can anyone tell me how to correct datetime for this update?
Make some proper code:
//somewhere in the global scope: datetime lasttime; //somewhere in OnTick() handler: if(Time[0] > lasttime) { lasttime = Time[0]; // do something on new bar // }

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
Can anyone tell me how to correct datetime for this update?
This is a snippet that had been working for over a year. It's purpose is to detect when a new bar has drawn. Was bullet proof. Not now. Doesn't work following the upgrade.
int checkTime(){int thisBarOpened=datetime Time[0];
if(thisBarOpened!=lastBarOpened){newBar=true;lastBarOpened=thisBarOpened;}
if(newBar){
// do stuff if newBar
}
}
4 errors produced:
'Time' - unexpected token
'[' - unexpected token
'[' - array required
'datetime' - expression expected
Any help would be greatly appreciated. Otherwise, I guess I go back to mod arithmetic, which is how I did it before using this method.