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

 
Renat Fatkhullin:

Straight away on the code and the work:

  1. The CopyXXX function in indicators doesn't wait for complete synchronous downloading of data, but gives what is available. Otherwise the indicators would really slow down.

  2. There seems to be a problem with the follow-up, if all the data was not synced the first time.
    It's necessary to change to a gentle mode "I will carefully wait for successful downloading". For example, OnCalculate is not called.

  3. The bad thing is that the global initialization with the maximum load is placed in OnInit where the indicator takes a very long time to count and wait.
    In this case the update of charts of this symbol is blocked and many other participants have to wait and not receive fresh data. The indicator should not take resources for a long time. It's better to stretch the long initialization step by step/symbol initialization in OnCalculate, counting step by step.

  4. I've had this indicator pump out about 800 MB of historical data over the network for synchronization

  5. The indicator has 512 drawing lines that are explicitly allocated memory for. This is extremely expensive. Only 100 lines are used.

  6. The code is poorly readable

1. yes, that's why I have to call them several times with a pause, or to restart the indicator manually several times, but even that doesn't always help and the indicator stops calculating after some time

2. I admit that the current version isn't optimal; I tried different variants, including the recommended function in the documentation (section "organizing access to data"); in the last version I have simplified it a bit, and it's probably also not optimal to call iBarShift functions many times, but on the other hand if you reject them, you need to create a special function for preparing synchronized data that I can't yet write, it is very cumbersome, and there is no standard function, moreover if the language has a standard feature to request the time n

3. OnInit only defines portfolio combinations and assigns buffers, no requests in OnInit. Optionally I tried to open charts of all M1 instruments in the background to prevent cache disappearance, and it seems to help, of course at maximum load it all is terrible, 28 charts... First request to data is in OpsCalculate where I call CopyClose in loop with pause (RequestData function) for data to be cached and series for all instruments to be gathered and then comes call (SetupIntervals, CalculateEquity and others) and I thought that all data will be ready and all calls of iBarShift and iClose and other useful functions will return cached data, but it somehow does not always work

4. this must be 800 mb tick data...? But i don't know how else i could form a batch of portfolios with 28 instruments, they should be requested anyway, in mt4 there was no problem with it (probably because all timeframes exist separately in mt4)

5. The thing is that the indicator assumes that a lot of portfolio combinations may be involved, now there is a preset combination with 420 lines + service lines (all sorts of wands, channels, etc.), theoretically the user may request all 512 lines, the number of buffers cannot be limited beforehand using #property indicators_buffers, because it is unknown how many will be requested by the user, in mt4 it is lags at maximum load, but works

6. I will comment on it if necessary.


P.S. I thought maybe you have downloaded the wrong version, because I made a mistake the first time and posted another version, then corrected the attachment.

P.P.S. I want to use the opportunity to clarify the functionality of the synthetic charts, will this functionality be somehow developed? For example I want to do not only the formula indexes, but to simulate the buy/sell position of a group of instruments, now it's hard to do because I have to write a cumbersome formula for the point value and contract size, and the point value does not change on the history ...

 

Renat Fatkhullin:

The indicator should not take up resources for a long time. It's better to evenly stretch the long initialization to a step-by-step/character initialization in OnCalculate, by calculating in pieces.

It is clear, so as not to slow down other programs in the terminal, but there is a contradiction: When calculating the model of the portfolio, the indicator needs all the rows of data at once, because the equity of the portfolio is calculated by them, i.e. it can't calculate anything without the ready data, and the portfolio needs all the components at once, and if there are several portfolios and if the comparison or summing of portfolios is done, then it needs all the portfolios, and then it is not much stretch - it is not a sliding window that can be calculated in parts, here first the calculation is done - That's why I raised the question about a universal standard function that would correctly prepare an array of synchronized data for calculation.

 
Vladimir Karputov:

Downloaded from

It's 18.10 now and everything works.


I congratulate you, you got lucky and you don't have the right CPU, memory, OS or whatever...but that doesn't make the bug not real.

It's real and it's not just happening to me.

 
transcendreamer:

This is understandable, in order not to slow down other programs in the terminal, but there is a contradiction: when calculating the portfolio model, the indicator will need all rows of data at once, because the equity of the portfolio is calculated using them, that is, without ready data it is impossible to calculate anything, and the portfolio needs all components at once, and if there are several portfolios and if there is a comparison or summation between portfolios, then for several portfolios, and then it cannot stretch, because it is not a sliding window that can be calculated in parts, here first the calculation is made - That's why I asked the question about a universal standard function that would correctly prepare an array of synchronized data for calculation.

That's the key flaw. I have the same problem.

The calculation and displaying works instantly in mt4, but there is no problem with indicators in mt5, while all the charts I need to get the prices from are always open. It turns out I can only write simple indicators, like single-buffer MAs(

 

There is definitely a bug on:

1) Server 2012 (build 9200) on Hyper-V x64, IE 10, RDP, UAC, Intel Xeon E5-2687W v2 @ 3.40GHz, Memory: 3033 / 3839 Mb, Disk: 96 / 107 Gb, GMT-5

2) Windows Server 2012 R2 (build 9600) x64, IE 11, RDP, UAC, QEMU Virtual version (cpu64-rhel6), Memory: 1340 / 2047 Mb, Disk: 15 / 28 Gb, GMT+2


 
Stanislav Dray:

There is definitely a bug on:

1) Server 2012 (build 9200) on Hyper-V x64, IE 10, RDP, UAC, Intel Xeon E5-2687W v2 @ 3.40GHz, Memory: 3033 / 3839 Mb, Disk: 96 / 107 Gb, GMT-5

2) Windows Server 2012 R2 (build 9600) x64, IE 11, RDP, UAC, QEMU Virtual version (cpu64-rhel6), Memory: 1340 / 2047 Mb, Disk: 15 / 28 Gb, GMT+2

I've got:

Windows 7 Service Pack 1 (build 7601) x64, IE 11, Intel Core i5-2400 @ 3.10GHz, Memory: 469 / 8182 Mb, Disk: 96 / 148 Gb, GMT+2

 
transcendreamer:

This is understandable, in order not to slow down other programs in the terminal, but there is a contradiction: when calculating the portfolio model, the indicator will need all rows of data at once, because the equity of the portfolio is calculated using them, that is, without ready data it is impossible to calculate anything, and the portfolio needs all components at once, and if there are several portfolios and if there is a comparison or summation between portfolios, then for several portfolios, and then it cannot stretch, because it is not a sliding window that can be calculated in parts, here first the calculation is made - That's why I asked the question about a universal standard function that would correctly prepare an array of synchronized data for calculation.

You should write the indicator with clear understanding that you won't get everything at once.

In OnInit you should stimulate the loading of history of required instruments by single calls of CopyXXX, but you have to wait for the full initialization in OnCalculate.

Your initialization phase seems to have an error - you incorrectly waiting for data and blocking.

 
Renat Fatkhullin:

Put the code to work. So far so good.

File without body, by the way.

In 2 hours everything is fine, timer is ticking in the comments with the right date.
 
Vitaly Muzichenko:

This is the key flaw. I have the same problem.

In mt4 the calculation and displaying works instantly, but in mt5 there is a complete problem with indicators, although all the charts from which you want to receive prices are always open. It turns out I can only write simple indicators, like single-buffer MAs(

If I'm looking for a different way to get the chart you need, I cannot see a universal and comfortable way to do it. I understand that everything is designed for the speed of the terminal and programs in it.

 
Vitaly Muzichenko:

This is the key flaw. I have the same problem.

In mt4 the calculation and displaying works instantly, but in mt5 there is a complete problem with indicators, although all the charts from which you want to get the prices are always open. It turns out that I can only write simple indicators, such as single-buffer MAs(

I have to look at the code.

Here in the code above there is clearly a bunch of logical and resource problems.

Reason: