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

To add comments, please log in or register
Tim Rittel
266
Tim Rittel  

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?
   }
  }
//+------------------------------------------------------------------+

Mehrdad Jeddi
26157
Mehrdad Jeddi  

Hi,

Yes,i can be done,

andrew4789
276
andrew4789  
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. ;)
To add comments, please log in or register