IndicatorRelease

Entfernt handle des Indikators und setzt Berechnungsteil des Indikators frei, wenn es nicht von jemandem verwendet wird.  

bool  IndicatorRelease(
   int       indicator_handle     // handle des Indikators
   );

Rückgabewert

Gibt true im Erfolgsfall zurück, anderenfalls false.

Hinweis

Funktion erlaubt handle des Indikators zu entfernen, wenn es nicht brauchbar ist und spart den Speicher damit. Handle wird sofort entfernt, Berechnungsteil des Indikators wird nach einiger Zeit durchgeführt (wenn er nicht mehr aufgerufen wird).

Im Strategietester wird die Funktion IndicatorRelease() nicht ausgeführt.

Beispiel:

//+------------------------------------------------------------------+
//|                                        Test_IndicatorRelease.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//--- input parameters
input int                MA_Period=15;
input int                MA_shift=0;
input ENUM_MA_METHOD     MA_smooth=MODE_SMA;
input ENUM_APPLIED_PRICE price=PRICE_CLOSE;
//--- wir werden handle des Indikators aufbewahren 
int MA_handle;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- erzeugen wir handle des Indikators 
   MA_handle=iMA(Symbol(),0,MA_Period,MA_shift,MA_smooth,price);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- wenn der Wert der globalen Variable noch nicht festgelegt wird 
   if(GlobalVariableCheck("MA_value")==0)
     {
      //--- dynamisches Feld für Erhaltung der Werte des Indikators 
      double v[];
      //--- erhalten wir Werte des Indikators in zwei letzten Bars 
      if(CopyBuffer(MA_handle,0,0,2,v)==2 && v[1]!=EMPTY_VALUE)
        {
         //--- speichern wir Wert der globalen Variable in der vorletzten Bar  
         if(GlobalVariableSet("MA_value",v[1]))
           {
            //--- befreien wir handle des Indikators  
            if(!IndicatorRelease(MA_handle))
               Print("IndicatorRelease() failed. Error ",GetLastError());
           }
        }
     }
//---
  }