Move it to OnTick/OnCalculate.
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.
Do you mean that you want to check the current real time of the trade server and not the simulated time in the tester?
I don't think that is possible. You may be able to use DLL calls to get the current time of the computer however.
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:
Does your statement apply to _Point and _Digits too?
I think this can be used in OnInit() as it is static properties of the symbol.Do you mean that you want to check the current real time of the trade server and not the simulated time in the tester?
I don't think that is possible. You may be able to use DLL calls to get the current time of the computer however.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use