MT4- How can I have my Indicator analyze "X" # of candles before starting?
If I dont do that, it may take many days/week before my EA has enough data to start dealing.
Don't try to use any price or server related functions in
OnInit (or on load,) as there may be no connection/chart yet:
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, account information and prices are
I dont really make the link with my question...
The relevant answer was
whroeder1:In OnInit set a flag indicating it's the first tick. On OnTick if the flag is set, clear it and do what you need.
The rest was additional information as so many people try to do initial calculations in OnInit when all data may not be loaded.