Download MetaTrader 5
To add comments, please log in or register
Publish your trading signal. Gain access to millions of traders!
toriachtmql
52
toriachtmql 2015.10.02 14:48 

Hi ,

 

apologies for the basic qn but I'm used to teh JVM doing this magic for me. I have a function that is called OnTick, it creates a few object instances, makes calculations and passes on the object reference to a controller function, controller does his thing and exits/finished. simplified code below. I know I need to clean up these objects, but I don't know how/when. I presume I need to do so at end of each "tick cycle" else I'll up with thousands of objects....

 

Perhaps I could make teh object class variables but my  real question is howto a clean up after myself? 

 

Thanks in advance, 

 

void OnTick()
{

   runCalc()

}

int runCalc()
{

 BaseObject *baseObj=new BaseObject
 SuperObject *superObj=new SuperObject

 baseObj.runMagic();
 superObj.runYourMagic();

 controller(baseObj,superObj);

}

void controller(BaseObject &_bobj, SuperObject &_sobj)
{

  //do stuff
  //make trades
}
whroeder1
13619
whroeder1 2015.10.02 16:04  
Toriacht: I presume I need to do so at end of each "tick cycle" else I'll up with thousands of objects....
Yes you do.
  1. delete your pointers before returning.
  2. Don't use pointers
     BaseObject baseObj;
     SuperObject superObj;
/
To add comments, please log in or register