Madrid, Spain
Posts: 7 since Feb 2016
Thanks Given: 7
Thanks Received: 1
|
I have tried to code a counter following your instructions but it seems like it doesn't limit the buys. Here is my code, maybe i have committed some mistakes and that is why it doesn't work well.
Inputs: length(20),Distance(2);
Vars: HigherBand(0),LowerBand(0),av(0),cont(0), apertura(0), cierre(0);
HigherBand = Average(c,length) + Distance*stdDev(c,length);
LowerBand = Average(c,length) - Distance*stdDev(c,length);
av = average(c,length);
cont = 0;
apertura = 1530;
cierre = 2200;
If higherband > lowerband and apertura <= time and time <= cierre then begin
if marketposition = 0 and cont <= 25 then begin
Buy ("compra") next bar at LowerBand limit;
cont = cont + 1;
end;
if marketposition = 1 and H >= av then begin
Sell next bar at Higherband limit;
end;
end;
If cierre > time then cont = 0;
|