Free memory after using .ex4

 

Hello guys, Im new to mql4 although I know basic C++. Im trying to write a script that outputs a .csv file with the values of some given indicators for each candlestick.

To do that Ive written a script that calls each indicator via the iCustom function within a for loop and then writes the value of the indicator at a given time into a file.

The problem I ran into is that if I want to run this for loop for a long time I eventually run out of memory, Ive noticed in the task manager that every time I run this iCustom function my RAM usage goes up until theres no space avainable and then the indicator just prints 0.

#define TDI_def "Indicators\\TDI_Pro-1 .ex4" 

#resource "\\" + TDI_def

double TDI;

void OnStart()

  {

      //Define variables

      for(int i = 5; i>=0; i--) 

      {

      TDI = iCustom(Symbol(), Period(), "::" + TDI_def ,0,4,i);  

      MessageBox(StringFormat("TDI Value: %f" , TDI));

      }

  }


So my question is farily simple, how do I free ram memory on every iteration so that i dont run out of memory eventually?


Thanks in advance.

Documentation on MQL5: Constants, Enumerations and Structures / Input/Output Constants / MessageBox
Documentation on MQL5: Constants, Enumerations and Structures / Input/Output Constants / MessageBox
  • www.mql5.com
MessageBox - Input/Output Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
  1. Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. David Valle: The problem I ran into is that if I want to run this for loop for a long time I eventually run out of memory, Ive noticed in the task manager that every time I run this iCustom function my RAM usage goes up until theres no space avainable

    So my question is farily simple, how do I free ram memory on every iteration so that i dont run out of memory eventually?

    Your posted code is using no memory; there is nothing to release. Your problem is elsewhere, probably in the indicator.
 
William Roeder #:
  1. Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. Your posted code is using no memory; there is nothing to release. Your problem is elsewhere, probably in the indicator.

Thanks for your answer William!, i have edited my post as you mentioned.

With regards to my code using no memory i should say thats not true, i check my RAM usage on the task manager during every iteration of the code and there is memory being used on every iteration that doesnt get deallocated. With regards to the indicator its just a standar RSI, i get the same proble using for example iRSI