Currently, backtrader is only using the closing price to update trailing stops even when OHLC data is provided. The correct way is to use High or Low depending if the order is a Sell or a Buy.
For example, consider the following scenario for a stop sell trail order:
A 10$ trail amount sell order from the current price of 100$ (so the price at which the order should be triggered is 90$)
Next OHLC candle is O=100, H=108, L=95, C=105.
What backtrader will do (incorrect way):
it will use the closing price of the new OHLC candle to update the trailing order. Since the closing price of 105$ is 5$ higher than the starting price of 100$, the new trigger price for the trailing order will become 90$+5$=95$.
What should be happening instead:
backtrader should use the High of the candle of 108$ to update the trailing stop to the new trigger price of 90$+8$=98$.
(same idea for the trailing buys, but the Low of the candle should be used)
Currently, backtrader is only using the closing price to update trailing stops even when OHLC data is provided. The correct way is to use High or Low depending if the order is a Sell or a Buy.
For example, consider the following scenario for a stop sell trail order:
What backtrader will do (incorrect way):
What should be happening instead:
(same idea for the trailing buys, but the Low of the candle should be used)