Return two dimensional array from optimization frame

 

Hi Guys

See code snippet below, i'm trying to get an array of returns for a tester run in the optimizer. WriteProfitData() is working in a single tester run however the full 2D array is not returned from the frame in the optimizer.

I tried to do this by reading/writing files after each tester run but things get very messy when 16 agents are writing to the common folder at the same time....

Also strangely I can access the value of data[0,0] but everything else is zero.

input int dummy_var=0;
double profitdata[,50];

//+------------------------------------------------------------------+
//| Handle Tester Events                                             |
//+------------------------------------------------------------------+
double OnTester()
  {
   string name="";
   long   id=0;
   double data[];
   ArrayResize(profitdata,50);
   
   name="profit";
   id=0;
   WriteProfitData();
   FrameAdd(name,id,dummy_var,profitdata);
   
   return 0.0;
  }
//+------------------------------------------------------------------+
//| Handle Tester Events                                             |
//+------------------------------------------------------------------+
void OnTesterPass()
  {
   //DebugBreak();      
   ulong  pass=0;
   string name="";
   long   id=0;
   double value=0.0;
   double data[,50];
   ArrayResize(data,50);

   while(FrameNext(pass,name,id,value,data))
     {
      Print(pass," ",name," ",id," ",value);
      Print(data[0,0]);
      Print(data[0,1]);
      Print(data[0,2]);
      Print(data[0,3]);
      //DebugBreak();
     }
  }

//+------------------------------------------------------------------+
//| Handle Tester Events                                             |
//+------------------------------------------------------------------+
void OnTesterInit()
  {
  Print("Start!!");
  }

//+------------------------------------------------------------------+
//| Handle Tester Events                                             |
//+------------------------------------------------------------------+
void OnTesterDeinit()
  {
  Print("End!!");
  }

//+------------------------------------------------------------------+
//| Get Profit Data (runs during pass)
//+------------------------------------------------------------------+
void WriteProfitData()
   {
   static int n1=0;
   //DebugBreak();
   profitdata[n1,0]=TimeCurrent();
   profitdata[n1,1]=AccountInfoDouble(ACCOUNT_BALANCE);
   profitdata[n1,2]=AccountInfoDouble(ACCOUNT_EQUITY);
   profitdata[n1,3]=AccountInfoDouble(ACCOUNT_PROFIT);
   profitdata[n1,4]=AccountInfoDouble(ACCOUNT_MARGIN);
   profitdata[n1,5]=PositionsTotal();
   n1++;

   //DebugBreak();
   }
 

Where did you see you can pass a 2D array to FrameAdd() ?

Working with files and Frames doesn't have a problem. You don't need to write to a file from all your agents.

Please search before asking, there several good topic about using Frame on this forum.