#define STAT_VALUES_COUNT 100 sinput double TeckProfit=20; sinput double StopLoss=20; double deposit; double TotalNetProfit; double MaximalDrawdown; double stat_values[STAT_VALUES_COUNT]; // Array for testing parameters //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnTick() { } //+------------------------------------------------------------------+ double OnTester() { deposit = TesterStatistics(STAT_INITIAL_DEPOSIT); TotalNetProfit = TesterStatistics(STAT_PROFIT); MaximalDrawdown = MathMax(TesterStatistics(STAT_EQUITY_DD),TesterStatistics(STAT_BALANCE_DD)); stat_values[0]=deposit; stat_values[1]=TotalNetProfit; stat_values[2]=MaximalDrawdown; stat_values[3]=TeckProfit; stat_values[4]=StopLoss; FrameAdd("Statistics",1,0,stat_values); return 0; } //+------------------------------------------------------------------+ void OnTesterInit() { Print("Begin..."); ParameterSetRange("TeckProfit", true, 0, 20, 50, 70); ParameterSetRange("StopLoss", true, 0, 20, 50, 70); } //+------------------------------------------------------------------+ void OnTesterPass() { string name =""; // Public name/frame label ulong pass =0; // Number of the optimization pass at which the frame is added long id =0; // Public id of the frame double val =0.0; // Single numerical value of the frame string parameter[]; uint parameter_count=0; while( FrameNext(pass,name,id,val,stat_values)) {Print("********* ",pass);if( FrameInputs(pass,parameter,parameter_count))appendLogfile(pass);} //--- Get the pass number, list of parameters, number of parameters //if( FrameInputs(pass,parameters_list,parameters_count))Print("********* ",pass); //appendLogfile(pass); } //+------------------------------------------------------------------+ void OnTesterDeinit() { Print("... end."); } //+------------------------------------------------------------------+ void appendLogfile(ulong pass){ //string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH); //Print(terminal_data_path+"\\"+"MQL5"+"\\"+"Files"+"\\"); string InfoSottostante="InfoSottostante.csv"; if (FileIsExist(InfoSottostante)==false){ int InfoSottostantehandle=FileOpen(InfoSottostante,FILE_READ|FILE_WRITE|FILE_CSV); FileSeek(InfoSottostantehandle,0,SEEK_END); string stamp0,stamp1,stamp2,stamp3,stamp4,stamp5; stamp0="Pass"; stamp1="deposit"; stamp2="TotalNetPr"; stamp3="MaximalDrawdown"; stamp4="TeckProfit"; stamp5="StopLoss"; FileWrite(InfoSottostantehandle, stamp0, stamp1, stamp2, stamp3, stamp4, stamp5); FileClose(InfoSottostantehandle); } int InfoSottostantehandle=FileOpen(InfoSottostante,FILE_READ|FILE_WRITE|FILE_CSV); FileSeek(InfoSottostantehandle,0,SEEK_END); string stamp0,stamp1,stamp2,stamp3,stamp4,stamp5; stamp0=DoubleToString(pass,0); stamp1=DoubleToString(stat_values[0],0); stamp2=DoubleToString(stat_values[1],0); stamp3=DoubleToString(stat_values[2],0); stamp4=DoubleToString(stat_values[3],0); stamp5=DoubleToString(stat_values[4],0); FileWrite(InfoSottostantehandle, stamp0, stamp1, stamp2, stamp3, stamp4, stamp5); FileClose(InfoSottostantehandle); }
I found the solution by placing the correct code

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hello, in the file does not write the optimized variables. Thank you if you want to help me.