OnDeinit in indicators - page 5

 
mql5:
I will try to explain again (on my fingers):
  1. The terminal started up X amount of time after the last start-up
  2. Initiated history download, which is missing (terminal was idle for X minutes)
  3. Called OnCalculate for the indicator on the available history prevtime = last known history time, indicator buffer size N bars
  4. While the history is being downloaded from the server, a tick comes
  5. Called OnCalculate of the indicator, where Time[0] is a tick time, the indicator memorizes it as prevtime, indicator buffer size is N+1 bars (between N and N+1 bars there is a gap in the history)
  6. After the history is downloaded, OnCalculate is called again, but this time there is no hole in the history, but prevtime has the same date as Time[0] - no new bar (respectively, no clearing of buffers in the indicator), buffer size of indicator N+X/Timeframe bars and IndBuffer[0] are not the same as in step 5



What does prevtime have to do with it?

I am asking why it doesn't work.

/////////////////////////////////////
void OnDeinit(const int reason)
{
 ArrayInitialize(body_up,EMPTY_VALUE);
ArrayInitialize(body_down,EMPTY_VALUE);
ArrayInitialize(shadow_up,EMPTY_VALUE);
ArrayInitialize(shadow_down,EMPTY_VALUE);
  ArrayInitialize(yell_body_up,EMPTY_VALUE);
ArrayInitialize(yell_body_down,EMPTY_VALUE);
ArrayInitialize(yell_shadow_up,EMPTY_VALUE);
ArrayInitialize(yell_shadow_down,EMPTY_VALUE);


}
 
eevviill:

What does this have to do with prevtime?

I'm asking why it doesn't work.

And how do you know it's not working? How do you check?

And why initialize the indicator buffers before unloading it? It's already unloaded, isn't it?

Indicator buffers should be initialized when all indicator values are fully recalculated:

int OnCalculate(..)
{
   ...
   if (<необходимо пересчитать все значения индикатора, например, если limit == Bars - 1>)
   {
      ArrayInitialize(...);
   }
   ...
}
 
eevviill:

Here. I do a buffer zeroing for this. Inite has already said you can't do that.

I want to deinit. But it doesn't work there either. Why?

What does init() and deinit() have to do with it? The operation is needed in quite a different place. I will repeat it again. After the calculation, history was loaded.

I made a working version.

Files:
 
Scriptong:

How do you know if it's not working? How do you check?


https://forum.mql4.com/ru/65066/page2#1015138
 
Vinin:

What does init(), deinit() have to do with it? The operation is needed elsewhere. I'll repeat. After calculation the history was loaded.

Made a working version.

I still got it right the first time on your recommendation.

I'm wondering why the deinit doesn't work to zero the arrays?

 
eevviill:
https://forum.mql4.com/ru/65066/page2#1015138

You gave a link to code that works in OnCalculate. I asked about how you know that initialization in DeInit doesn't work. Let me specify, just in case, that after OnDeinit() nothing from indicator code works (neither OnInit(), nor OnCalculate()). Thus, you can check the fact of arrays zeroing only in OnDeinit() itself.

 
Scriptong:

You gave a link to code that works in OnCalculate. I asked about how you know that initialization in DeInit doesn't work. Let me specify, just in case, that after OnDeinit() nothing from indicator code works (neither OnInit(), nor OnCalculate()). Therefore, you can check the fact of zeroing of arrays only in OnDeinit() itself.

I have provided a link to

OperationOpened chart-attached M1 indicator - closed terminal - opened it in a couple of minutes. The result is on screenshots.

This is how I test it.

 
eevviill:

I still got it right the first time on your recommendation.

I'm wondering why deinit doesn't work with zeroing of arrays?

Or doesn't deinit work when the terminal is closed?
 
eevviill:
Or does deinit not work when the terminal is closed?
It does, but there is no point in clearing the indicator buffers - they are not saved.
 
mql5:
It works, but there is no point in clearing the indicator buffers - they are not saved.

Why?

Why is the value of buffer 0 filled saved but not zeroed?