Probably 17:00 NY time, if it is a major pair, it will be best. I will include later on this correction.

Just continuing with the idea of the previous script. I will keep as A1,A2,A3 for the time being because it allows to make several trials changing the Close for the High or Low and so on as well as increasing to A4, A5, and so on.

As with the parameters set as above, If we ad and "Exit Time = 5" the Anual Return goes to 126%. Then, when optimizing it goes down to 110% and then when doing Walk Forward Analisis for 3 cycles it goes down to -23%.

Supose now I want to introduce some filter, as it is written below and make optimization:


function run()
{
BarPeriod = 1440;
set (PARAMETERS);
vars A1 = series(priceClose(2));
vars A2 = series(priceClose(1));
vars A3 = series(price(0));
var per = optimize(0.000, 0.001,0.01);
var Vlr;

Vlr = A1[0] * per;
printf("Result=%.f",Vlr);


if (A1[0] < A2[0] and A3[0] < A1[0]-Vlr) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+Vlr) enterShort();

Stop = optimize(30,20,100)*PIP;
TakeProfit = optimize(500,200,700)*PIP;
ExitTime = 5;

}


When doing this optimization it popes up "error 043:EURUSD: wrong parameter!". I assume something is wrong in the script but I can not figure out where it can be, since before trying to optimize it seems to be working fine.