Hi all... I'm a newbee and trying to write an EA. All is going well but I wish to make the EA stay out of trading for 2 periods (candles) after it closes a trade. I've tried using "TimeCurrent()" and adding the seconds of the period but I get a warning of different data types. I seem at a loss as to how to go about it . Any help would be appreciated.
Not a good idea if you have a disconnection that misses a bar or more. Check for inequality rather than equality.
He is using TimeMinute() ... a bit hard to see when not in SRC box (I had to look twice!).
A simple way to detect a new bar (MT4):
It depends exactly what you want.
Let's say you are trading the H1 chart.
Last order was closed at 13:37
Do you want the next order to be opened on or after 15:00 (so skip the rest of 13:00 candle and the 14:00 candle)
Or do you want the next order to be opened on or after 15:37 (2 hours later)