Changing the TF is a problem - page 3

 
Vasyl Nosal:

I have an idea. I'll write later.

the idea is dead.

I'll ask developers to make something like HistoryUpdated() system check whether all history was updated or not.

An optimal variant. To keep the history for all timeframes up to date. Recently, a similar indicator has appeared in CodeBase
 
Slawa:

Developers won't help you because they won't.

Already said: if difference between rates_total and prev_calculated is greater than 1, then it is historyUpdated

is greater than 0, not 1.

И? Does that solve the problem?

Or is it not a problem for you to recalculate the whole story on every new bar?

 
Vasyl Nosal:

is greater than 0, not 1.

И? Does that solve the problem?

Or is it not a problem for you to recalculate the whole story on every new bar?

You have been told correctly. Greater than 1. When a new bar appears, the difference is 1.

And that completely solves the problem.

A normal indicator takes very little time to completely recalculate. Less than a second.

 
Victor Nikolaev:

You have been told correctly. Greater than 1. When a new bar appears, the difference is 1.

And that completely solves the problem.

A normal indicator takes very little time to fully recalculate. Less than a second.

Only works if the buffers are zeroed.

//history update
  int all=rates_total;
  int counted=prev_calculated;
  if(all-counted>1)
  { 
  ArrayInitialize(up_arr,EMPTY_VALUE);
  ArrayInitialize(down_arr,EMPTY_VALUE);
  counted=0;
  }
   
   //main
 for(int i=all-counted;i>=0;i--)
{
 
Vasyl Nosal:

It only works if you reset the buffers to zero.

//history update
  int all=rates_total;
  int counted=prev_calculated;
  if(all-counted>1)
  { 
  ArrayInitialize(up_arr,EMPTY_VALUE);
  ArrayInitialize(down_arr,EMPTY_VALUE);
  counted=0;
  }
   
   //main
 for(int i=all-counted;i>=0;i--)
{

Sorry, but let me ask:

  • why do you need to assign rates_total and prev_calculated to separate variables created on each tick here?
  • In the conditional if() statement and in the for() loop, why do you need to re-calculate the difference of these variables?
  • why not just introduce a variable for the difference between rates_total and prev_calculated, for example limit?
The implementation may be different depending on the task. The nuances may be different. Why don't you see how it is implemented by others, depending on the different conditions? Including, and with the help of priming to understand, decide, form acceptable variants for yourself, depending on the tasks?
 
Vasyl Nosal:

P.S. I'll add more to this:

Your idea about zeroing (counted=0) in block of conditional operator if(){} seems to be clear to me.

Just in case it would be clearer to you what I mean briefly above, here is an extract from the Documentation, from the section ... Language basics / Functions / Event handling functions:

... If since the last call of OnCalculate() price data was changed (a deeper history was pumped or history gaps were filled), then the value of input parameter prev_calculated will be set to zero by the terminal itself.

 
Vasyl Nosal:

It only works if you reset the buffers to zero.

You don't need to reset anything.

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

   for(int i = nStartBar; i >= 0; i--)
   {
       // рассчитываем индикатор на всех непосчитанных барах
   }
}

If you reset prev_caclulated to zero, the indicator will recalculate completely. And this is correct - you do not know what exactly has changed in the history. Maybe, some hole was loaded, maybe the studs were cleaned somewhere. It is obligatory to recalculate completely. In all other cases, only one last bar will be recalculated (whena new bar appears, the last two).

 
Dina Paches:

Sorry, but let me ask:

  • Why do you need to assign the values of rates_total and prev_calculated to separate variables on each tick?
  • In the conditional if() statement and in the for() loop, do you re-calculate the difference of these variables?
  • why not just enter a variable for the difference between rates_total and prev_calculated, e.g. limit?
The implementation can be different depending on the task. The nuances may be different. Why don't you see how it is implemented by others, depending on the different conditions? Including, and with the help of priming to understand, decide, form acceptable variants for yourself, depending on the tasks?

Thank you. Good point.

It's not. It's so that you can recalculate the whole history if there's a gap.

 
Dina Paches:

P.S. I'll add more to this:

Your idea about zeroing (counted=0) in block of conditional operator if(){} seems to be clear to me.

Just in case it would be clearer to you what I mean briefly above, here is an extract from the Documentation, from the section ... Language basics / Functions / Event handling functions:

... If since the last call of OnCalculate() price data was changed (a deeper history was pumped or history gaps were filled), then the value of input parameter prev_calculated will be set to zero by the terminal itself.

It won't. It's 0 then not 0 then 0 again (when loading history a couple of times).
 
Sergei Vladimirov:

There is no need to reset anything.

If you zero out prev_caclulated, the indicator will recalculate completely. And this is correct - you do not know what exactly has changed in the history. Maybe, some hole was loaded, maybe the studs were cleaned somewhere. It is obligatory to recalculate completely. In all other cases, only one last bar will be recalculated (whena new bar appears, the last two).

No. Without zeroing will be what the screenshots show.
Reason: