How to release memory use by build-in indicators?

 

How can I release the memory previously used by iRSI, iStochastic etc.?

I run into memory issues when using iStochastic for 1 million bars with various settings. I think that if it was somehow possible to clean up MT4's internal memory use it would be better.

 
Roel13:

How can I release the memory previously used by iRSI, iStochastic etc.?

I run into memory issues when using iStochastic for 1 million bars with various settings. I think that if it was somehow possible to clean up MT4's internal memory use it would be better.

Hello Roel13,

May I ask you why you need 1 million bars? Try to decrease the amount of bars used in your calculations. In order to do that, please take a look here: https://www.metatrader5.com/en/terminal/help/startworking/settings

Regards,
Malacarne

 
Malacarne:

Hello Roel13,

May I ask you why you need 1 million bars? Try to decrease the amount of bars used in your calculations. In order to do that, please take a look here: https://www.metatrader5.com/en/terminal/help/startworking/settings

Regards,
Malacarne

Hello Malacarne,

To get a more reliable overview of how good a formula is.

Is there any way to clean up MT4's internal memory use it would be better?

This issue/bug is easy to similute btw, just run hundreds of calculations with varying settings on i<some internal indicator>; it seems clear that MT4 somehow caches the information for all of them and then runs out of memory.

 

If you don't need that buffer(s) anymore, you can use:


void  ArrayFree(
   void&  array[]      // array
   );

https://www.mql5.com/en/docs/array/arrayfree


But if you want to keep indicator buffer(s)  working, rewrite the indicator to only calculate new bars not previously calculated.


A kind regard.

Documentation on MQL5: Array Functions / ArrayFree
Documentation on MQL5: Array Functions / ArrayFree
  • www.mql5.com
Array Functions / ArrayFree - Reference on algorithmic/automated trading language for MetaTrader 5
 

doesn't the delete function also work?

CiMA maMovingAverage = new CiMA

delete(maMovingAverage);  (In the deinit section of the code)

 

Hello guys.

My code eat all ram memory and can not release it.
When indicator ran, ram usage become 99% until i remove Indicator from chart.
This is my code:

//+------------------------------------------------------------------+

#property copyright "Copyright 2017, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property indicator_chart_window


int      fast_ema_Period=12;                //Fast Period

int      slow_ema_Period=26;              //Slow Period

int      signal_Period=9;                      //Signal Period


//+------------------------------------------------------------------+

//| Custom indicator initialization function                  |

//+------------------------------------------------------------------+

int OnInit()

  {

   for (fast_ema_Period=1; fast_ema_Period <= 1000; fast_ema_Period++)

      {

                  iMACD(Symbol(),0,fast_ema_Period,slow_ema_Period,signal_Period,PRICE_CLOSE);

      }

//---

   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(rates_total);

  }

//+------------------------------------------------------------------+



IN THIS LINE :

iMACD(Symbol(),0,fast_ema_Period,slow_ema_Period,signal_Period,PRICE_CLOSE);

When iMACD Initialized, some Memory used.

 "" IS THERE ANY WAY TO RELEASE RAM BEFORE OnCalculate FUNCTION HAS BEEN END ????????? ""

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

Forum on trading, automated trading systems and testing trading strategies



Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


 
morimil:

Hello guys.

My code eat all ram memory and can not release it.
When indicator ran, ram usage become 99% until i remove Indicator from chart.
This is my code:


IN THIS LINE :

iMACD(Symbol(),0,fast_ema_Period,slow_ema_Period,signal_Period,PRICE_CLOSE);

When iMACD Initialized, some Memory used.

 "" IS THERE ANY WAY TO RELEASE RAM BEFORE OnCalculate FUNCTION HAS BEEN END ????????? ""

For sure you have memory issue, you are opening 1000 indicators.

See IndicatorRelease(), but that will not help if you don't change your approach.

 
Alain Verleyen:

For sure you have memory issue, you are opening 1000 indicators.

See IndicatorRelease(), but that will not help if you don't change your approach.


Thank you sir for your fast reply.

I'll check and feedback.





I check it, it's Work

Thank you so much

You are my Hero