MQL5 bug when working with iClose/iOpen timeseries access, etc.

 
Hi!
 

#property tester_everytick_calculate may solve problems?

MQL5: Added new property for custom indicators #property tester_everytick_calculate. It is used in the strategy tester and allows to forcibly enable calculation of indicators on every tick.

25.Tester: Now, during non-visual testing/optimization, all used indicators (standard and custom) are calculated only by requesting data. An exception is the indicators that contain calls of theEventChartCustom functionand use theOnTimerhandler. Previously, in the strategy tester, when any tick came (even from another symbol), all indicators were calculated unconditionally. This innovation has greatly accelerated the testing and optimization.

To force the calculation of indicators at every tick, add the #property tester_everytick_calculate to the program.

Indicators compiled by the previous versions of the compiler, will be calculated as before - at each tick.
 

It is also always recommended, if you work with another timeframe - then once a minute you need to get OHLC from this timeframe (any CopyXXXXXX function).

Hence it comes out - when working with someone else's timeframe it is not necessary to use iXXXXXX atavisms, but to use CopyXXXXXX functions.

 
Vladimir Karputov:

It is also always recommended, if you work with another timeframe - then once a minute you need to get OHLC from this timeframe (any CopyXXXXXX function).

Hence, when working with another timeframe - you do not need to use iXXXXXX atavisms, but you must use CopyXXXXXX functions.

It's not serious!

Why then:iHigh(Symbol(),TF,i);

P.S. Everything works in mt4 without problems since the first days of its existence, why not do the same in mt5, so there won't be any tambourine? If it works in mt4 - then it is possible to make it work in mt5 as well
 
Vitaly Muzichenko:

Not serious!

Why then:iHigh(Symbol(),TF,i);

P.S. In mt4 everything works without problems since the first days of its existence, why not do the same in mt5, so there will be no tambourine? If it works in mt4 - it means it is possible to make it work in mt5 as well

Also, it was always recommended, if you work with another timeframe - you have to get OHLC from this timeframe once per minute (any CopyXXXX function). This has always been the case.

 
double high_k = NormalizeDouble(iHigh(Symbol(),TimeFrames, k),DigitsM);
double low_k = NormalizeDouble(iLow(Symbol(),TimeFrames, k),DigitsM);
double open_k = NormalizeDouble(iOpen(Symbol(),TimeFrames, k),DigitsM);
double close_k = NormalizeDouble(iClose(Symbol(),TimeFrames, k),DigitsM);

Try updating quotes before doing so via RefreshRates.

 
Dmitry Fedorchenko:

Try refreshing quotes via RefreshRates beforehand.

"RefreshRates" is a non-existent function.

 
Vladimir Karputov:

"RefreshRates" is a non-existent function.

I'm about
https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/csymbolinfo/csymbolinforefreshrates

There was a similar problem only in EA, it helped me.

 
Farkhat Guzairov:
The MQL4 version of this indicator has been working for more than 2 years and no such problems/errors have been found.

No CopyXXX will help you. This is a MT5 bug that started with build 30 and has not been fixed since build 44. Read the last 5-6 pageshttps://www.mql5.com/ru/forum/285631/page29 and you won't be alone.

Новая версия платформы MetaTrader 5 build 1930: Плавающие окна графиков и .Net библиотеки в MQL5
Новая версия платформы MetaTrader 5 build 1930: Плавающие окна графиков и .Net библиотеки в MQL5
  • 2018.11.13
  • www.mql5.com
26 октября 2018 года будет выпущена обновленная версия платформы MetaTrader 5...
 
Farkhat Guzairov:

Good day!

I am currently transferring previously written indicators from MQL4 to MQL5. I haven't danced around a lot and everything seems to be OK, but....

At some point the indicator data stops updating, I couldn't figure out exactly where the error was and only by accident I noticed that iClose/iOpen, etc. stop updating, i.e. they return the same value.

The funny thing is that even if I recompile the source code the indicator won't update correctly, but I see that it executes functions:

Only if you open the properties of the indicator and close it via "Ok", the data is updated and displayed correctly, but up to some point that may occur at any time (but 100% it happens). In this case the indicator stopped updating data at 2018.11.14 00:00, in general it happens after some time regularly.

Earlier another bug was revealed, function iBars(Symbol(),TimeFrames)/Bars(Symbol(),TimeFrames) returns zero value. Fortunately, it is not a constant error but it still occurs and we have to control it.

It turns out that MQ stops supporting MQL4. This is great, but MQL5 will have such bugs.

So how to solve the above problem?

1) Measure the running time of one OnTick/OnCalculate calculation in microseconds and print it in log.

This way you can see how much time you spend on tick calculation. Then estimate how many ticks at this speed you can calculate per second. You'll probably find no more than a dozen ticks, and you'll get more ticks per second.


2) Measure the time of each OnCalculate on indicators that are attached to charts / timeframes, from which you extract data.

There probably is a similar situation. Due to slow calculations, the terminal waits until the calculated symbol:timeframe is unlocked. It is the slow indicators, especially on a deep history, that leads to the freezing of payoffs of other people's charts.


When developing indicators you should put performance issues and economical recalculations in the first place. Otherwise you will kill everything around you.

 
Renat Fatkhullin:

It's the braking indicators, especially on deep history, that cause the freezing of other people's charts.

Then tell me why freezing happens to me? I have a freeze of outputs in OnTick before function of inquiry of indicators. I.e. update of CopyTime by M1 acts as a trigger which starts the other processing in OnTick, but before CopyTime there are no functions or interrogation of indicator.

And why there were no such problems before build 30 and everything was working fine since October 2017?