#property description "This indicator does not calculate values. It makes a single attempt to" #property description "apply the call of ArrayFree() function to three arrays: dynamic one, static one and" #property description "an indicator buffer. Results are shown in Experts journal." //--- 指標の設定 #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- グローバル変数 double ExtDynamic[]; // 動的配列 double ExtStatic[100]; // 静的配列 bool ExtFlag=true; // フラグ double ExtBuff[]; // 指標バッファ //+------------------------------------------------------------------+ //| カスタム指標を初期化する関数 | //+------------------------------------------------------------------+ int OnInit() { //--- 配列へのメモリ追加 ArrayResize(ExtDynamic,100); //--- 指標バッファマッピング SetIndexBuffer(0,ExtBuff); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| カスタム指標の反復関数 | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { //--- 単一の分析を行う if(ExtFlag) { //--- メモリ解除を試みる //--- 1. 動的配列 Print("+============================+"); Print("1. Check dynamic array:"); Print("Size before memory is freed = ",ArraySize(ExtDynamic)); Print("Is this a dynamic array = ",ArrayIsDynamic(ExtDynamic) ? "Yes" : "No"); //--- 配列メモリ解除を試みる ArrayFree(ExtDynamic); Print("Size after memory is freed = ",ArraySize(ExtDynamic)); //--- 2. 静的配列 Print("2. Check static array:"); Print("Size before memory is freed = ",ArraySize(ExtStatic)); Print("Is this a dynamic array = ",ArrayIsDynamic(ExtStatic) ? "Yes" : "No"); //--- 配列メモリ解除を試みる ArrayFree(ExtStatic); Print("Size after memory is freed = ",ArraySize(ExtStatic)); //--- 3. 指標バッファ Print("3. Check indicator buffer:"); Print("Size before memory is freed = ",ArraySize(ExtBuff)); Print("Is this a dynamic array = ",ArrayIsDynamic(ExtBuff) ? "Yes" : "No"); //--- 配列メモリ解除を試みる ArrayFree(ExtBuff); Print("Size after memory is freed = ",ArraySize(ExtBuff)); //--- フラグの値を変更する ExtFlag=false; } //--- 次の呼び出しのために prev_calculated の値を返す return(rates_total); } |