EA deinit on tester

 

hi there

when testing an EA and stopping it in middle of test, the deinit function is not called. i checked this multiple times and read the documents.

i have an object that writes csv journal files and in the end (when EA is closed or stopped) i need to add a summery and i decided to do it in object destructor which is called in deinit.


this is the destructor code:

//--------------------------------------------------------------------+
//    Destructor:
//--------------------------------------------------------------------+
void
JournalWatch::~JournalWatch( )
{
   double total = NormalizeDouble(this.total_profit + this.total_swap + this.total_comission,2);
   
   FileSeek(this.file_handle, 0, SEEK_END);
   FileWrite(this.file_handle, "","","","","",this.total_profit, "","","","","",
      this.total_swap,this.total_comission, "total: "+( string )total);
}


and this is how i create and delete the object:

//--- import journal class
#include <journal_Base.mqh>
JournalWatch *journal = new JournalWatch();


...

...

...


void OnDeinit(const int reason)
  {
   EventKillTimer();
   delete journal;
   Print("journal deleted");
  }


i have looked around in forum and yet couldn't find any answers. if anyone have any suggestions or workarounds about how i can call the deinit or accomplish writting summery i appreciate it a lot.