Changing the TF is a problem - page 4

 

The last design suits me completely.

Thank you all.

 
Vasyl Nosal:
No. Without zeroing it would be what it is in the screenshots.

So you have gaps within the loop itself, the sequence is broken. In that code, which fragment I gave you, ALL bars are recalculated when prev_calculated is zeroed. And it means that zeroing them beforehand is meaningless - a waste of processor time.

PS. By the way, you have forgotten an important nuance. By any chance, are you talking about MT5 where price arrays are not inverted in timeseries? In this case it would be like this:

int OnCalculate(...)
{
   // индекс последнего посчитанного на прошлом вызове бара
   // с которого начинаем расчёт
   int nStartBar = MathMax(prev_calculated - 1, 0);

   for(int i = nStartBar; i < rates_total; i++)
   {
       // рассчитываем индикатор на всех непосчитанных барах
   }
}
 
Sergei Vladimirov:

So you have gaps within the loop itself, the sequence is broken. In that code, which fragment I gave you, ALL bars are recalculated when prev_calculated is zeroed. And it means that zeroing them beforehand is meaningless - a waste of processor time.

PS. By the way, you have forgotten an important nuance. By any chance, are you talking about MT5 where price arrays are not inverted in timeseries? In that case it would be like this:

mql4

Nope. Here's with your design on a pair where there was no history.

Files:
 

Well. The problem turned out to be not so simple.

The developers ask for a new bull variable to store whether the chart is updated and automatic resetting of buffers if more than 1 bar is loaded.

 
Vasyl Nosal:

Well. The problem turned out to be not so simple.

The developers ask for a new bull variable to store whether the chart is updated and automatic resetting of buffers if more than 1 bar is loaded.

You have two variables: prev_calculated and rates_total. Controlling the loading of history (in this case prev_calculated==0) you must think what to do with indicator buffers - the usual behavior in such cases, is to equate the loading of history to the first loading event of the indicator.
 
Karputov Vladimir:
You have two variables at your disposal: prev_calculated and rates_total. By controlling the history loading (with prev_calculated==0) you have to think about what to do with indicator buffers - the usual behavior in such cases is to equate history loading to the first indicator loading event.
What does this have to do with the order? There are 4 options here and none of them work.
 
Vasyl Nosal:

Well. The problem turned out to be not so simple.

The developers are asking for a new bull variable to store whether the chart has updated and automatic buffers resetting if more than 1 bar has been loaded.

Take your time, please.

And while you are waiting for an answer from developers, listen to what the moderator said above. I recommend and reread thoughtfully this topic of yours again from the beginning.

Pay attention to this post of the moderator, for example: https://www.mql5.com/ru/forum/68180#comment_2089395, where he cited:

if(prev_calculated==0)  // значит история изменилась или это первый проход

After all, I, as well as others, have hinted to you about this, as well as some other things, in my two posts: https://www.mql5.com/ru/forum/68180/page3#comment_2095342

Look at the Documentation, which is cited there (not only in the part of the highlighted phrase, but in the text as a whole).

Take your time, please, and then everything will work out for you in terms of solving this problem of yours. Good luck!

 
Dina Paches:

You take your time, please.

And while you are waiting for a reply from the developers, listen to what the moderator said above. I recommend you to reread this thread again.

Pay attention to this post of the moderator, for example: https://www.mql5.com/ru/forum/68180#comment_2089395 where he cited:

After all, I, as well as others, hinted to you about this, as well as some other things, in my two posts: https://www.mql5.com/ru/forum/68180/page3#comment_2095342

Have a look at the Documentation that you have given there.

Take your time, please, and then everything will work out for you in terms of solving this problem of yours. Good luck!

Do you have a solution to the code?

Or are you afraid that I will change the TF and your design won't work too? It is OK, we are solving a GENERAL problem here.

 
Vasyl Nosal:

Do you have a solution to the code?

Or are you afraid that I will change the TF and your design won't work either? That's OK, we are solving a common problem here.

But I still recommend to use the advice I gave in this post: https://www.mql5.com/ru/forum/68180/page4#comment_2097011.

And I have solutions for me.

For your own advice please feel free to continue without me. A hint of general direction (see prev_calculated and rates_total) has been given to you many times by various people here.

From your assumption about me, I assume that you also failed to notice the following, which I told you:

Implementation may be different depending on the task. The nuances may be different. Why don't you see how things are implemented in other countries, depending on various conditions? Including with the help of ripping to understand, determine, form acceptable options for yourself, depending on the tasks?

As you probably did not notice Victora Nikolaev's post: https://www.mql5.com/ru/forum/68180/page2#comment_2091839

You do have a head, don't you? I do.

Do you want to solve your problem? It seems that way.

So, if you want and need to, you can bring out your solutions for different programs and output them yourself.

Do I or anyone else in this thread have to provide you with anything in more detail? No.


 
Dina Paches:

...


Do you have a solution code?