PriceBoundChecking breaking short side exits

I am using daily Norgate data and converting the raw data into "as-traded" OHLC bars. I have a low level strategy loop that handles the entries and exits, and for each of the BuyPrice, SellPrice, ShortPrice, and CoverPrice I am using the "as-traded" calculated prices instead of the the raw prices. Because of this I have set the PriceBoundChecking option to false. Everything works fine for the long side, but for the short side it is exiting on the next bar, even though the strategy says to exit many bars later. And instead of using the "as-traded" price for the cover exit, it is using the raw prices. It is almost as though there is some hidden exit command that I am not seeing. It's very weird that the long side works fine, and just the short side is doing this. For debugging I have:

  1. commented out the PriceBoundChecking, and the issue goes away, but then it uses the unadjusting data instead of the "as-traded" data.
  2. If I comment out all of the exits in the low-level strategy loop it still takes one trade, and exits very next bar at the unadjusted price (same issue). Something external is making it exit, because all of mine are turned off.

Almost as if there is an exit like ApplyStop somewhere in the code, but there is not. The only place I have any exits are the low level loop.

Something else to note, the trades show fine on a chart. It is plotting up arrows and down arrows that I construct in the code at the right times and prices, for both long and short trades. This only happens in the Analysis backtester statistics.

Does anyone know what could be going on with this?

@vjsworld, probably you have already have done it, but did you carefully verified each value in the Backtester Settings dialog (those are used when you do not override them in your code):



yes, they seem to be correct

See, here it is working fine in a chart:


But when you look at these same trades in the backtester the shorts are broken:


See how the shorts are immediately exiting the next day, and also at the raw price instead of the as-traded price.

The longs work fine.

I see that the short exits are of type "Ruin".

Maybe this KB article will help:

Ruin stop or mysterious Short(6) in the trade list

Probably, the detailed log report will further give you hints to solve the issue.

SetOption( "DisableRuinStop", True );

fixed it!!!!!!!!

Man I love this forum! You guys are the best! THANKS @beppe!!!

1 Like

Special thanks to @Tomasz that over the years documented almost everything about AmiBroker!

In any case, it is important to note that while it is possible to turn OFF this built-in stop but it is highly discouraged.

As we say in Italian: "Uomo avvisato, mezzo salvato." (approximate translation: "Better safe than sorry."

Agreed, @Tomasz is awesome