Job finished
Specification
I need help writing a bit of modular MQl5 code for EA integration.
The purpose of the code is to write the information of 20 different variables into a .csv file (in a format readable by excel) during the optimization in MT5.
It needs to write the information for all currently running optimization passes simultaneously in ontick()
(in other words, it needs the Frame() function)
I want it to write into a different file for each optimization pass.
(FrameInputs() does this)
So in other words pass1.csv pass2.csv, ect.
The variables to be written are empty, I will fill them later in my own. But the indexes need to have a variable name so I can feed them with information from another function.
The only variable I want you to write in is the TimeCurrent() into the first variable.
Here is an example of my (failed) code.
void OnTick() { int data[20]; data[0] = variable1; data[1] = variable2; data[2] = variable3; data[3] = variable4; data[4] = variable5; data[5] = variable6; data[6] = variable7; data[7] = variable8; data[8] = variable9; data[9] = variable10; data[10] = variable11; data[11] = variable12; data[12] = variable13; data[13] = variable14; data[14] = variable15; data[15] = variable16; data[16] = variable17; data[17] = variable18; data[18] = variable19; data[19] = variable20; ArrayInitialize(data,0); // int values(int& data[]) int hl=FileOpen("filetest",FILE_CSV|FILE_WRITE|FILE_SHARE_WRITE|FILE_ANSI|FILE_COMMON); if(hl==INVALID_HANDLE) { printf("Error %i creating tester file",GetLastError()); } else { FileSeek(hl,0,SEEK_END); FileWrite(hl,data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],data[14],data[15],data[16],data[17],data[18],data[19]); FileClose(hl); if(!FrameAdd("Statistics",0,0,data[ 20 ])) printf("FrameAdd failed with error %i",GetLastError()); else { Print("Frame added"); } } } //+----------------------
The results in the file should look something like this
So excel reads them like this
The names and variables should be an empty value and return nothing unless I fill the variable.
So variable1 = 2, variable2 = "" variable3 = ""
and variablename1 = "drawdown", variablename2 = "", variablename3 = ""
Or something to that effect.
The end result is I want it to be modular and fill the file with whatever data I choose at a later point.