OnDeinit in indicators - page 2

 
eevviill:

No, it doesn't. I turn off the terminal normally.

If Deinit is put into Init, it doesn't work either.

Only the custom object deletion function helped.

Well, if it doesn't delete, who knows what you've done there :)

 
keekkenen:

Well, if it doesn't remove it, who knows what you've done to it :)

Makes sense. But if I just delete the indicator from the chart, the zones are deleted. When I turn off the terminal, they are not. If I use the function in the init that deletes zones (it is the same function in deinit).

I understood that deinit works for all. And when it should be triggered when closing or opening the terminal?

 
int deinit()
  {

deinit2();

return(0);
}

//////////////////////

void deinit2()

{

  for(int i=ObjectsTotal()-1;i>=0;i--)

  {

  if(StringFind(ObjectName(i),Highest_vol_zones_name)!=-1)

  ObjectDelete(ObjectName(i));

  }

 

}
 
eevviill:

Makes sense. But if I simply remove the indicator from the chart, the zones are removed. Not when the terminal is switched off. Only if I put my own function to delete zones in the init (same function in deinit).

I understood that deinit works for all. But when it should work when terminal is closed or opened?

Yes, it works when the terminal is closed...

maybe you have some kind of logic going on for a long time ?

in the sense that at the moment of shutdown indicator uncannily calculates something and the terminal expects it all awry and/or interrupts, that OnDeinit does not work ?

I think the way to the helpdesk...

 
keekkenen:

yes, when you close the terminal it works...

maybe you have some kind of long playing logic ?

in the sense that at the moment of shutdown indicator performs some weird calculation and terminal expects it all awry and/or interrupts, that OnDeinit doesn't work ?

I think the way to the helpdesk...

If it works for you, then it's ok. I'll have a look at mine.
 

Nothing has changed and more has been added.

Buffer indicator. Operation Opened chart-attached M1 indicator-closed terminal-opened in a couple of minutes. The result is in screenshots.

And this despite the fact that I also wrote in the code

//////////////////////////////////////////////////////////////////
int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],const double &open[],const double &high[],
                const double &low[],const double &close[],const long &tick_volume[],const long &volume[],const int &spread[])
  {
    //new bar
if (Time[0] != prevtime) 
{
 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);


prevtime = Time[0];
}

 

Developers, are you going to sort out the problem?

Here's an indicator for you. Try what I did in the post above.

Opened the chart-attached the M1 indicator-closed the terminal-opened it after a couple of minutes.

Files:
 
eevviill:

Developers, are you going to sort out the problem?

Here's an indicator for you. Try what I did in the post above.

Opened the chart-attached the M1 indicator-closed the terminal-opened it after a couple of minutes.

The situation with your indicator has been solved.

The thing is that the indicator is calculated not only on the arrival of ticks, but also on the first drawing and on the arrival of missing history.

1. A new tick arrives - the indicator is calculated.

2. The missing history arrives, which plugs the hole between the last data from the last terminal start and the last tick. The indicator is calculated. But at the same time there is no new bar condition!

To solve this problem you need to check the number of bars. Approximately like this

   if(Time[0]!=prevtime || Bars!=prevbars)
     {
      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);

      prevtime=Time[0];
      prevbars=Bars;
     }
 
stringo:

The situation with your indicator has been solved.

Here's the thing - the indicator is calculated not only on the ticks arrival, but also on the first drawing and on the missing history arrival.

1. A new tick arrives - the indicator is calculated.

2. The missing history arrives, which plugs the hole between the last data from the last terminal start and the last tick. The indicator is calculated. But at the same time there is no new bar condition!

To solve this problem you need to check the number of bars. Like this

Thank you.

But it is not only in my indicator. I thought you from your side will solve this problem.

For example when closing the terminal Deinit in all programs to run.

 
eevviill:

Thank you.

But it's not just in my indicator. I thought you would solve this problem from your side.

For example, when closing the terminal, deinit in all programs.

Actually deinit in all programs is called when the terminal is closed.

There is even a special code for the reason of deinit. REASON_CLOSE

Reason: