Reinitialize local STATIC variable upon ChartSetSymbolPeriod()

 

A static variable retains it's value even after Symbol or Period change of the chart. 

Is there a way to reinitialize local static variables upon Symbol or Period change?

Or is there only the possibility to declare the variable on the global scope and reinitialize it in OnInit()?


void TestStatic()
  {
  static int x=0; //Please reinitialize with 0 upon ChartChange

  Print(x);
  x++;
    
  return;
  }
 

I think you should go with GLOBAL and handle it on OnInit()...

STATIC variables in general have a ver very specific usage...

;)

Reason: