You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello community,
I'm having some strange behaviors in MT5 when working with indicators that use other timeframes for calculations (ex. Pivot indicators).
Most of time they works fine on all symbols, but on some of them (in this particular case XAUUSD), data retrieved are not valid and so, all calculations are wrong.
Of course I tried to "return 0" in some scenarios in which current period and daily period series are surely not valid, for example. (This part is in the first part of OnCalculate of course)
This mitigate a lot of issues but not all.
Basically the cycle to calculate data is made in most of indicators in a similar way, cycling an integer variable from its value to 0.
What I seen is that for some ticks, I need to refresh all datas for all "rates_total-1" rates, otherwise I get badly calculated values.
A workaround comes to my mind and can be descrived as "I refresh indicator for all rates_total until a specific number of ticks is received". I counted ticks with an int variable and when this variable is greater than X, i start refreshing indicators for "rates_total-prev_calculated" rates.
In the end of my OnCalculate I increase ticks_count with ++ command.
This works fine and honestly I can use it without any problem but it sound too strange to me... Is it possible that there is no command to see if data are valid or not? I used CopyRates, checked iTime, checked SymbolIsSynchronized and so on... Not a single one solved my issue but only my rude and raw workaround.
I'm almost sure i'm missing something, but what?
Thanks to all that want to help my in finally found a sense of it.
:-)