I'm trying to optimise with the folowing code. When I look at the
results, the winning and losing average bars (which should be fixed)
does not correspond at all with the "length" parameter, which should
govern it?
The code is as follows;
PB=Optimize("PB",0.99,0.97,0.998,0.002);
Length=Optimize("Length",12,3,15,1);
Cond1=Ref(C,-1)<PB*Ref(C,-2);
Cond2=C>Ref(C,-1);
Buy = Cond1 AND Cond2;
Sell = False;
inTrade = False;
bcnt = 0;
for (i = 0; i < BarCount; i++)
{ if (inTrade)
{
Buy[i] = False;
}
if (++bcnt == Length)
{inTrade = False;
Sell[i] = True;
}else
{
if (Buy[i])
{inTrade = True;bcnt = 0;
}
}}
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Can anyone help?
Thanks,
Rich