Program Trade, This condition is "Same bar exit" or "Next Bar open exit"?

Hi, I would like to make buy n sell can same bar exit.
When the Buy signal occur, will buy at open,
if lose 30pts, will stop loss at the same bar immediately

When I do backtest, I have tried "Applystoploss" or "SetOption("AllowSameBarExit", True );" for stop loss at -30pts at the same bar,
The result of exit signal is occur at "next bar open" instead of immediate cut loss at buyprice-30pts at same bar.

My question is base on my code for real time trade,

  1. If "buy at open signal" & "30pts cut loss signal" occur at the same bar, will it Close the position at "buyprice-30" immediately?
  2. I set only 1 trade per day, if buy-sell signal at the same bar, will the "buy-sell" action non stop repeat til the bar end? or only ONE buy n sell at -30pts, then stop trade today?

Thanks!!!

NN=1;
ma8=MA(C,8);
Buyeee  = Ref(C,-2)<=Ref(ma8,-2) AND Ref(C,-1)>Ref(ma8,-1);
Selleee = Ref(C,-1)<Ref(ma8,-1)- tpbuff ;

Shorteee = Ref(C,-2)>=Ref(ma8,-2) AND Ref(C,-1)<Ref(ma8,-1) ;
Covereee  = Ref(C,-1)>Ref(ma8,-1) +tpbuff;

buyinprice=ValueWhen(Buyeee,O);
shortinprice=ValueWhen(Shorteee,O);

Buy=Buyeee;
Sell=Selleee OR L<buyinprice-30 ;

Short=Shorteee;
Cover=Covereee OR H>shortinprice+30 ;

SellPrice =IIf(L<buyinprice-30,  (buyinprice -30), O);
CoverPrice=IIf(H>shortinprice+30, (shortinprice +30),O);

Buy = Buy AND Sum( Buy OR short, BarsSince( new_day ) + 1 ) <= NN;
Short = Short AND Sum( Short OR buy, BarsSince( new_day ) + 1 ) <= NN;

Buy = ExRem( Buy, sell );
sell = ExRem( Sell, Buy );
Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short );

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.