Deactivate Re-entrydelay in ApplyStop

I have a simple trading system for one stock, in which I have a buy rule a sell rule and a time-stop rule.

Buy = Cross (C, BBandTop (C, 20, 2));
Sell = C > O;
ApplyStop (stopTypeNBar, stopModeBars, Optimize( "max. days",4,3,9,1));

The issue with this system is that whenever a Sell signal or a Stop signal is generated for a certain bar, the Buy signal is automatically ruled out. If only starts the calculations for the next Buy rule on the bar after the sell occured.
It's like Amibroker applies a re-entrydelay of 1 bar, which I want to de-activate.

I tried to turn it off in the Applystop formula, but it does not solve the problem:

ApplyStop (stopTypeNBar, stopModeBars, Optimize( "max. days",4,3,9,1), 1,0,0);

@Straddle I don't know if this is the correct answer, but I wonder if you did experiment with the following options?

// Described as scenario 3
SetOption("AllowSameBarExit", True );
SetOption("HoldMinBars", 1 );
Buy = 1; // for testing purposes Buy every day // Cross (C, BBandTop (C, 20, 2));
Sell = C > O;
ApplyStop (stopTypeNBar, stopModeBars, Optimize( "max. days",4,3,9,1));

A detailed discussion about their usage is found in the Portfolio-level back-testing document.

Hi Beppe, thanks for your answer. I adapted my colde as such by adding:

SetOption("AllowSameBarExit", True );
SetOption("HoldMinBars", 1 );

Right now my original issue is solved, buy signals are also generated on bars when a sell occured. The only issue I now have, I would like to implement a pause between new trades to avoid the exit and entry date of a new trade will equal to the exit date of the previous date.
Do you know how to do this?

The code currently looks like this:

SetOption ("AllowSamebarExit", 1);
SetOption ("HoldMinBars", 1);
SetTradeDelays (1, 1, 1, 1);

BuyPrice = SellPrice = ShortPrice = CoverPrice = Open;

//Trading Code
Buy = Cross (C, BBandTop (C, 20, 2));;
Sell = C > O;
ApplyStop (stopTypeNBar, stopModeBars, Optimize( "max. days",4,3,9,1));

@Straddle unfortunately I do not understand your new request.

To clarify this, it might be useful to publish a backtest report screenshot that shows a trade (mark it) that you want to avoid.


@Straddle simply deleting the two SetOption() lines you added removes the option to re-enter on the same bar (the trade opened on 5/05/2010 will not be included in the report).

So now I'm quite confused about what you truly want to achieve...

  • The system generates a buy signal on 30/apr/2010 and buys at the open of the next day (correct)
  • The system generates a sell signal on 4/may)2010 and sells at the open of the next day (correct)
  • On 5/May/2010 a buy signal is generated, but no trade is executed on 6/may/2010 (this I want to resolve)