I am running a strategy using the following instructions:
Code: Select all
[IntrabarOrderGeneration = False]
MP = MarketPosition;
setstopposition;
setstoploss(one_perc_dollars); //$500
if (MP[1]=0 and (Long_Stop=0) and (scale=0) and (stage=0 or stage=1 or stage=2 or stage=3) )
then begin
Long_Stop = Close[0] * (1 - (vol_perc_long/100));
Num_Shares_p1 = ((p1_pcent) * (one_perc_dollars/(Close[0]-Long_Stop)) ) ;
Buy ("LE_1") Num_Shares_p1 shares this bar on close;
//Long_Stop = Close[1] * (1 - (vol_perc_long/100));
scale=1;
eprice = close;
end;
As soon as the trade is stopped out it is executing another trade even though I am using "MP[1]=0" i.e telling it to wait one bar before entering the next trade.
It looks like the MarketPosition does not get set to 1 at the close of the previous trade bar hence once the 1st trade is stopped out it is valid then to execute the second trade.
As soon as the trade is filled how can I get MP to be set to 1?
Thanks