endy5: yes, Raptor, you have true!... but is "better" solution? I won´t use EA.
A better solution than a comparison of 2 integers (datetimes) on each tick ? I doubt it, testing of integers is very fast . . . nothing is called from your Broker, Time[0] is updated when the new tick is received.
Philippe Pauleau #: I also need a delay inside OnInit function because history is not always loaded.
Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:
Terminal starts.
Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
OnInit is called.
For indicators OnCalculate is called with any existing history.
Human may have to enter password, connection to server begins.
New history is received, OnCalculate called again.
A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
yes, Raptor, you have true!... but is "better" solution? I won´t use EA.
I also need a delay inside OnInit function because history is not always loaded.
I am using this loop in the OnInit function:
Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet: