Questions from Beginners MQL5 MT5 MetaTrader 5 - page 622

 
How do I increase the number of bars in the tester in MT4 before initialising the indicator? The indicator should calculate on the history - you need to check if it is correct in the tester.
 
Another question, how do I check the integrity of the history during initialization in MT4? I suspect that at the moment of initialisation the history is being swapped, which affects the pre-calculation...
 
-Aleks-:
Another question, how do I check the integrity of the history during initialization in MT4? I have a suspicion that at the moment of initialisation the history is being swapped, which affects the pre-calculation...
Check the number of bars rates_total. If rates_total > prev_calculated+1 - then more than 1 bar was swapped and hence history is being swapped.
 
Alexey Kozitsyn:
Check the number of bars rates_total. If rates_total > prev_calculated+1 - it means that more than 1 bar was swapped and hence the history has been swapped.
And check frequency once per second, and after long pause continue initialization, right?
 
-Aleks-:
And frequency of check do once per second, and after long pause continue initialization, right?

In general, as I was recently told in SD, it is better to do without timer in indicators.

It is enough to add the condition: if( prev_calculated <= 0 || rates_total > prev_calculated+1 ) as a condition of first start and full recalculation of the indicator. If you do it in OnCalculate(), there will be no problems.

 
And what 'long pause' are you talking about?
 
Alexey Kozitsyn:

In general, as I was recently told in SD, in indicators it is better to do without timer.

It is enough to add the condition: if( prev_calculated <= 0 || rates_total > prev_calculated+1 ) as a condition of first start and full recalculation of the indicator. If you do it in OnCalculate(), there will be no problem.

I want to have a correct calculation of indicator type class in my Expert Advisor.

If we allow 10 000 bars per chart, and we have them, then Bars will not return more than 10000 even if there is a new bar. Then how do I know if there is a new bar when the history is loaded?

 
And apparently the check should not be done at initialisation, as the EA is initialised when the terminal is loaded before connecting to DC....
 
-Aleks-:

Well, I need the indicator type class to be calculated correctly in my EA.

Therefore I am confused, if 10000 bars per chart are allowed and they are, then Bars will not return more than 10000 even if new bars appear. Then how do I know if there is a new bar when loading history?

Why not? Yes, it will. And Bars() and rates_total will increase. Check the number in OnCalculate().

The number of bars set in the terminal does not affect to the number of bars in the tester (a little less than 100000).

 
Alexey Kozitsyn:

Why not? It will. Both Bars() and rates_total will increase. Check the number in OnCalculate().

The number of bars set in the terminal did not affect the number of bars in the tester (just under 100000).

No no, I need it not in the tester but when I run the terminal on a real chart - there it will work only if the history has less than the maximum number of bars, or am I wrong?
Reason: