Hi , I faced a problem I want to use iBars function and give symbol name parameter from an array to this function but it return 0. On the other hand ,when I use Symbol() it works without any problem . can you guys kindly tell me why?! I code in mql5 .
Both lines work out the same way.
Both lines work out the same way.
Hi, @ Alexandr Bryzgalov , so is it possible my meta editor has a bug! Isn't it a universal opensource compiler?!
did you compile it as an indicator or script? I just figure it out that this happen only in indicator!
in script it works ok for me too!
please chek the attached file.I am getting the same problem today. Maybe because iBars is being called on
int OnInit() { ... }
However, I can reproduce the error . It occurs only if I did not use the symbol for many days.
If I restart MT4, iBars works fine again for the same symbol that produced an error before. It is really a bug !
int OnInit() { ... }
- 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.
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.
Thanks for the advice, William. To solve the problem, I had to implement a logic in the onTick() function to check if iBars delivered more than a minimal numbers of bars to calculate prices.
It works after some ticks.
In one of my MT4 instances I had to delete the history directory in order it worked correctly.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi , I faced a problem I want to use iBars function and give symbol name parameter from an array to this function but it return 0. On the other hand ,when I use Symbol() it works without any problem . can you guys kindly tell me why?! I code in mql5 .