Download MetaTrader 5

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

To add comments, please log in or register
Pierre Rougier
661
Pierre Rougier  

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);
  }
//+------------------------------------------------------------------+
whroeder1
17915
whroeder1  
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
Anthony Garot
746
Anthony Garot  
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));
}
Pierre Rougier
661
Pierre Rougier  

Did you build this code from the wizard? 

Exactly.

Thanks,
Pierre

To add comments, please log in or register