claudio_arrau2:
My latest EA uses Trendlines and calculates differences between Values and the trendline.
The tester works perfect and gives correct results. When I use Optimization, then no trade at all is triggered, so everything shows "0" at the end,
Play videoPlease edit your post.
For large amounts of code, attach it.
- There is no chart during optimization. Therefor there is no trendline.
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
MQL4:
I often test my EAs first without optimization and then in a second step I tune the parameters using "Optimization".
E.g., I step through different values for Stop Loss settings.
My latest EA uses Trendlines and calculates differences between Values and the trendline.
The tester works perfect and gives correct results. When I use Optimization, then no trade at all is triggered, so everything shows "0" at the end,
no trade, no loss, no nothing.
In my "normal" EA based on Indicators or EMA values and similar, the Optimization works perfect.
The code is very long, because the EA is complex. A typical piece of code where the problem might be is attached below.
The EA basically draws trendlines, tests them agains some rules and then goes long or short accordingly.
I use Arrays and also ArraySort, this is where my suspicion is...
thanks for your help!
for(i=0; i<lim;i++){
UHPt=UHP[i,1];
if(UHPt>UH[0] && High[UHPt]>High[UH[0]])
{
UH[1]=UHPt;
UColorD=Red;
if(UH[1]-UH[0]>=MinTrend && UH[0]>0){
U_ObjD();
CountD++;
test_lineD();
if(isTouching || Euro_MaxValD>MaxDistanceEuro){
ObjectDelete("LH"+aiD);
CountD--;
}else{
if(CurDistD1<=CurDistD){ObjectDelete("LH"+aiD);}
if(CurDistD1>CurDistD){
CurDistD=CurDistD1;
TotsD[BL,1]=aiD;
TotsD[BL,0]=UH[1]-UH[0];
TotsD[BL,2]=UH[0];
TotsD[BL,3]=UH[1];
}
}
}//end if UH1-UH0
}//end if UHP>0
aiD++;
}//end for loop DOWNTREND
ArraySort(TotsD,WHOLE_ARRAY,0,MODE_DESCEND);
for(i=0;i<=TurnExtremes;i++){
if(TotsD[i,0]>0){ObjectDelete("LH"+TotsD[i,1]);}
}
Valid_aiD=TotsD[0,1];
Valid_UH1=TotsD[0,3];
Valid_UH0=TotsD[0,2];