Can Amibroker exit on price below stop when there is a gap?

Hello,

I noticed when playing around with trailing stops that the backtest results always exits on the trailstop amount. Is it possible to exit on a price below the stop if the open of the new trading day is below the low on the previous day and the trailstop is between that level?

image

There are different ways to implement Stops from Settings or ApplyStop() function and also a term called looping.

When you write your own loop, you can do almost anything you want with Entry / Ecit / Trail etc so a good place to start is here.

It is the same case with backtesting, most scenarios like say 90% are covered with functions or easy features but for the rest you need to write your own CBT.

I was hoping that there was an option to include gaps in the applystop functionality. I guess taking this into account programmatically will cost lots of time.

Applystop DOES take care of gaps. So it exits at bar's Open price if Open exceeds stop value (e.g. see scenarios 1 or 2 of ApplyStop manual).
The thing that is misleading you is the fact that your plotted stop line is not a line created by ApplyStop.
ApplyStop is backtest function not chart function.
Plot the Sell signal then you will see that ApplyStop exits at Open in cases you've described.

BTW, you should post reproducible code next time.
Please see this thread.

1 Like

Hey fxshrat,

As always you were right. I currently use:

ApplyStop( 2, stopModePercent, 25, 0);

Somehow this works but not 100% bulletproof (I also tried this with option 1 and 2 but I'm not seeing any difference).

image

Trade 2 and 3 are correct but when comparing the prices of the trailstop (this equals the maxhigh * 0.75 of the trade) of trade 4 to the low. It should have been triggered on 6/5/2010 (dd/mm/yyyy) on a price of 7,3 (=trailstop). The trailstop of 7.3 is achieved on the high (= 9.73) on 26/4/2010.

image

There is probably a logical explanation but I'm not seeing it.

Update:

Applystop with mode 0 works on trade 2 and 3 but not on trade 4 (Exit on 06/05/2010 is expected).

Applystop with mode 1 works on trade 4 (correct exit on the trailstop value) but not correct on trade 2 and 3. With trade 2 and 3, an exit is expected at the open (=gap) and not on the trailstop value.

Is a combination of mode 0 and 1 possible?

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