EA DeInit and Init if ChartTimeframe switches (EA reload yourself)

 

Hy, is it possible to force my EA to reload itself, everytime the Timeframe on the Chart is switched?

//+------------------------------------------------------------------+
//|                                            RefreshYourselfEA.mq4 |
//|                                                   Copyright 2019 |
//|                                                         mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019"
#property link      "mql5.com"
#property version   "1.00"
#property strict

int PerioD=Period();
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(Period()!=PerioD)
   {
      OnDeinit();                 // here is the Question..
      OnInit();                   // is it possible somehow?
   }
  }
//+------------------------------------------------------------------+

 

Hi,

Yes,i can be done,

 
Tim Rittel:
As far as I know EA will Deinit whenever the tf is changed - for what ever reason - automatically. Reinstall, basically.
Which is good, if that's what you want. ;)
Reason: