The problem is knowing the 'End of Bar' has occured. We only know that a new bar has opened because a tick has been recieved after the bar's defined close time. It could be a very long time between ticks and EA code is data driven (meaning executes when data changes or is recieved) by the reciept of a tick. Unless you use very nasty infinite time checking loops for your own internal checking of when time has past and the bar should be closed independant of whether a tick has been recieved or not. So you can only easily calculate bar[1] on recieving the frist tick of a new bar. bar[0] changes value with every new tick recieved within its timeframe.
End of Bar 1 == Start of bar 0. You want to send the Alert's only for bar 1 and only once (at beginning of the new bar)
static datetime Time0; if (condition){ if (i==1 and Time0 != Time[0]){ Time0 = Time[0]; // send alerts }

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
The attached indicator seems to be calculating on every tick, whereas I want it to only calculate at the close of the bar. I've tried various bits of code, but as I'm very much a beginner I haven't been able to solve it.
I think it's a simple task for a more experienced person.
Any help, appreciated.