//+------------------------------------------------------------------+ //| Should be called in the OnTesterDeinit() handler | //+------------------------------------------------------------------+ void FrameAnnealingMethod::FrameDeinit(void) { //--- change the text and color of the text label l_text.Color(clrGreen); l_text.Text("Optimization complete. Press 'Play' button for repeat play"); ChartRedraw(); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void FrameAnnealingMethod::FrameTester(double F,double Fbest,Input &Mass[],int num,int it) { int i=0,j=0; int size=ArraySize(Mass); double FrameMass[];// array to be passes to a frame ArrayResize(FrameMass,9+3*size); // fill the statistics FrameMass[0]=TesterStatistics(STAT_PROFIT); // Total Net Profit FrameMass[1]=TesterStatistics(STAT_PROFIT_FACTOR); // Profit Factor FrameMass[2]=TesterStatistics(STAT_RECOVERY_FACTOR); // Recovery Factor FrameMass[3]=TesterStatistics(STAT_SHARPE_RATIO); // Sharpe Ratio FrameMass[4]=TesterStatistics(STAT_TRADES); // Number of trades FrameMass[5]=TesterStatistics(STAT_DEALS); // Number of deals FrameMass[6]=TesterStatistics(STAT_EQUITY_DDREL_PERCENT); // the maximum equity drawdown as a percentage FrameMass[7]=F;// the current value of the custom optimization criterion FrameMass[8]=Fbest;// the best value of the custom optimization criterion // fill the array of values of optimized parameters for(i=9;i<9+3*size;i=i+3) { FrameMass[i]=Mass[j].Value; FrameMass[i+1]=Mass[j].BestValue; FrameMass[i+2]=Mass[j].Temp; j++; } //--- Create a data frame and send it to the terminal if(!FrameAdd(MQL5InfoString(MQL5_PROGRAM_NAME),num,it,FrameMass)) Print("Frame add error: ",GetLastError()); else Print("Frame added, Ok"); //--- } //+------------------------------------------------------------------+ //| Receives frame with data during optimization and displays chart | //+------------------------------------------------------------------+ void FrameAnnealingMethod::FrameTesterPass(int cr) { //--- Variables for working with frames int i=0,j=0; double FrameOut[]; string name; ulong pass; long id; double value; int size=0; // string params[]; // uint par_count; while(FrameNext(pass,name,id,value,FrameOut)) { if(id==-1) { l_text.Color(clrRed); l_text.Text("The temperature reached a minimum value. Please click the STOP button in Strategy Tester"); // l_text.Text("The temperature reached a minimum value"); } else { j=0; n_frame.Text(StringFormat("Number of pass: %d",id)); size=(ArraySize(FrameOut)-9)/3;// calculate the number of optimized parameters // update the table of statistics t_stat.SetValue(1,0,StringFormat("%.2f",FrameOut[0])); t_stat.SetValue(1,1,StringFormat("%.2f",FrameOut[1])); t_stat.SetValue(1,2,StringFormat("%.2f",FrameOut[2])); t_stat.SetValue(1,3,StringFormat("%.2f",FrameOut[3])); t_stat.SetValue(1,4,StringFormat("%G",FrameOut[4])); t_stat.SetValue(1,5,StringFormat("%G",FrameOut[5])); t_stat.SetValue(1,6,StringFormat("%.2f",FrameOut[6])); t_stat.SetValue(1,7,StringFormat("%.2f",FrameOut[7])); if(t_stat.GetValue(1,8)==StringFormat("%s"," - ")) { t_stat.SetValue(1,8,StringFormat("%.2f",FrameOut[8])); for(i=9;i<9+size*3;i=i+3) { t_value.SetValue(0,j,StringFormat("%.2f",FrameOut[i+1])); j++; } } else { j=0; if((cr!=5) && (cr!=6) && (cr!=11) && (cr!=12))// it is necessary to maximize the objective function { if(FrameOut[8]>=StringToDouble(t_stat.GetValue(1,8))) { t_stat.SetValue(1,8,StringFormat("%.2f",FrameOut[8])); for(i=9;i<9+size*3;i=i+3) { t_value.SetValue(0,j,StringFormat("%.2f",FrameOut[i+1])); j++; } } } else { if(FrameOut[8]<=StringToDouble(t_stat.GetValue(1,8))) { t_stat.SetValue(1,8,StringFormat("%.2f",FrameOut[8])); for(i=9;i<9+size*3;i=i+3) { t_value.SetValue(0,j,StringFormat("%.2f",FrameOut[i+1])); j++; } } } } j=0; // fill the table of optimized parameters for(i=9;i<9+size*3;i=i+3) { t_inputs.SetValue(1,j,StringFormat("%.2f",FrameOut[i])); t_value.SetValue(1,j,StringFormat("%.2f",FrameOut[i+2])); j++; } } ChartRedraw(); }//end while } //+------------------------------------------------------------------+ //| Chart events handling | //+------------------------------------------------------------------+ void FrameAnnealingMethod::FrameOnChartEvent(const int id,const long &lparam, const double &dparam,const string &sparam,int cr) { long speed=0; string name; ulong pass; long frameid; double value; int size=0; int i=0,j=0; double FrameOut[]; // if(!PlayFrame) return; //--- If this is an event of a mouse click on a graphical object if(id==CHARTEVENT_OBJECT_CLICK) { //--- If the event of our object is received if(sparam==b_playbutton.Name()) { if(frame_counter==0) { t_stat.SetValue(1,8,StringFormat("%s"," - ")); FrameFirst(); } while(ObjectGetInteger(0,sparam,OBJPROP_STATE)==1) { if(FrameNext(pass,name,frameid,value,FrameOut)) { if(frameid!=-1) { j=0; size=(ArraySize(FrameOut)-9)/3;// calculate the number of optimized parameters t_stat.SetValue(1,0,StringFormat("%.2f",FrameOut[0])); t_stat.SetValue(1,1,StringFormat("%.2f",FrameOut[1])); t_stat.SetValue(1,2,StringFormat("%.2f",FrameOut[2])); t_stat.SetValue(1,3,StringFormat("%.2f",FrameOut[3])); t_stat.SetValue(1,4,StringFormat("%G",FrameOut[4])); t_stat.SetValue(1,5,StringFormat("%G",FrameOut[5])); t_stat.SetValue(1,6,StringFormat("%.2f",FrameOut[6])); t_stat.SetValue(1,7,StringFormat("%.2f",FrameOut[7])); if(t_stat.GetValue(1,8)==StringFormat("%s"," - ")) { t_stat.SetValue(1,8,StringFormat("%.2f",FrameOut[8])); for(i=9;i<9+size*3;i=i+3) { t_value.SetValue(0,j,StringFormat("%.2f",FrameOut[i+1])); j++; } } else { j=0; if((cr!=5) && (cr!=6) && (cr!=11) && (cr!=12))// it is necessary to maximize the objective function { if(FrameOut[8]>=StringToDouble(t_stat.GetValue(1,8))) { t_stat.SetValue(1,8,StringFormat("%.2f",FrameOut[8])); for(i=9;i<9+size*3;i=i+3) { t_value.SetValue(0,j,StringFormat("%.2f",FrameOut[i+1])); j++; } } } else { if(FrameOut[8]<=StringToDouble(t_stat.GetValue(1,8))) { t_stat.SetValue(1,8,StringFormat("%.2f",FrameOut[8])); for(i=9;i<9+size*3;i=i+3) { t_value.SetValue(0,j,StringFormat("%.2f",FrameOut[i+1])); j++; } } } } j=0; // fill the table of optimized parameters for(i=9;i<9+size*3;i=i+3) { t_inputs.SetValue(1,j,StringFormat("%.2f",FrameOut[i])); t_value.SetValue(1,j,StringFormat("%.2f",FrameOut[i+2])); j++; } frame_counter++; //--- Update the text in the chart header l_text.Text(StringFormat("Play with pause %d ms: frame %d",StringToInteger(e_speed.Text()),frame_counter)); n_frame.Text(StringFormat("Number of pass: %d",frameid)); ChartRedraw(); Sleep((int)StringToInteger(e_speed.Text())); } } else { frame_counter=0; ObjectSetInteger(0,sparam,OBJPROP_STATE,false); l_text.Text("Press 'Play' button for repeat play"); ChartRedraw(); } } } if(sparam==b_backbutton.Name()) { ObjectSetInteger(0,sparam,OBJPROP_STATE,false); speed=StringToInteger(e_speed.Text()); if(speed>0) { speed=speed-100; e_speed.Text(IntegerToString(speed)); ChartRedraw(); } } if(sparam==b_forwardbutton.Name()) { ObjectSetInteger(0,sparam,OBJPROP_STATE,false); speed=StringToInteger(e_speed.Text()); speed=speed+100; e_speed.Text(IntegerToString(speed)); ChartRedraw(); } if(sparam==b_stopbutton.Name()) { ObjectSetInteger(0,sparam,OBJPROP_STATE,false); l_text.Text("Press 'Play' button for repeat play"); frame_counter=0; ChartRedraw(); } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ uint FrameAnnealingMethod::FrameToFile(int count) { ResetLastError(); int i=0; string strF; double FrameOut[]; string name; ulong pass; long id; double value; FrameFirst(); int file_handle=FileOpen("output.txt",FILE_WRITE|FILE_TXT|FILE_COMMON); if(file_handle!=INVALID_HANDLE) { strF="Number of iteration\tPass in agent\tF\tFbest\t"; for(i=0;i<count;i++) strF=strF+"Value"+IntegerToString(i+1)+"\t"+"BestValue"+IntegerToString(i+1)+"\t"+"Temp"+IntegerToString(i+1)+"\t"; FileWrite(file_handle,strF);// write the file title strF=""; while(FrameNext(pass,name,id,value,FrameOut)) { if(id!=-1) { StringConcatenate(strF,id,"\t",value,"\t",FrameOut[7],"\t",FrameOut[8],"\t"); for(i=9;i<ArraySize(FrameOut);i++) strF=strF+DoubleToString(FrameOut[i],3)+"\t"; FileWrite(file_handle,strF); } } } else return GetLastError(); FileClose(file_handle); return 0; } //+------------------------------------------------------------------+
felipe ramos:
void FrameTester(double F,double Fbest,Input &Mass[],int num,int it);
Se for essa linha, INPUT é palavra reservada, não pode ser usada dessa forma.
Se "Input" é uma classe ela deveria ter sido declarada em algum ponto do seu código.
Eu consegui resolver alterando a classe AnnealingMethod, no arquivo AnnealingMethod.mqh.
Lá tem um struct "Input". Ao baixar o arquivo do artigo, o struct estava dentro da classe, no trecho "public".
Eu apenas movi o struct para fora da classe e funcionou.
Você está perdendo oportunidades de negociação:
- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Registro
Login
Você concorda com a política do site e com os termos de uso
Se você não tem uma conta, por favor registre-se