The OnDeinit () method for an indicator, no longer exists in MQL5?

 

Hello,

The OnDeinit () method for an indicator, no longer exists in MQL5?


//+------------------------------------------------------------------+
//|                                                          ttt.mq5 |
//|                                   Copyright 2018, Pierre Rougier |
//|                                           www.apprendre-mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, Pierre Rougier"
#property link      "www.apprendre-mql5.com"
#property version   "1.00"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Pierre Rougier: The OnDeinit () method for an indicator, no longer exists in MQL5?
Where do you get that idea? Perhaps you should read the manual.
Type Function name Parameters Application Comment
int OnInit none Expert Advisors and indicators Init event handler. It allows to use the void return type.
void OnDeinit const int reason Expert Advisors and indicators Deinit event handler.
: : : : :
          MQL5 programs / Program Running - Reference on algorithmic/automated trading language for MetaTrader 5
 
Pierre Rougier:

Hello,

The OnDeinit () method for an indicator, no longer exists in MQL5?


Did you build this code from the wizard? If so, you may need to add it yourself.

OnDeinit() works for both Experts and Indicators.

void OnDeinit(const int reason)
{
    Print(StringFormat("%s(): reason [%d]", __FUNCTION__, reason));
}
 

Did you build this code from the wizard? 

Exactly.

Thanks,
Pierre

Reason: