Year() returning bad value inside OnInit() - Indicator
Don't try to use any price or server related functions in
OnInit (or on load,) 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.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent and prices are valid.
Here is the code i'm using
While the Print inside OnCalculate works properly, it's not the case for the Print inside OnInit, which seem to always print 1900.
What is the reason for that?