Hello,
in my indicator i need to query login.
This happens outside OnInit. When multiple charts have this indicator attached, it happens in some charts, that my_login=0.
So
returns 0;
Where is it in your code?
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, account information and prices are valid.
Don't call in OnTimer until you've received a tick.
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, account information and prices are valid.
Don't call in OnTimer until you've received a tick.
Thank you for this list.
Questions:
1. Does this list also apply for MT5 ?
2. Does it mean, with SECOND call of
OnCalculate
i can be sure connection established and account information available AND realtime data available ?
Thank you
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
in my indicator i need to query login.
This happens outside OnInit. When multiple charts have this indicator attached, it happens in some charts, that my_login=0.
So
returns 0;