backtesting.py icon indicating copy to clipboard operation
backtesting.py copied to clipboard

Question regarding stoploss, takeprofit.

Open makovez opened this issue 2 years ago • 1 comments

What does backtesting.py consider first? The low price or the high price of a candle to determine stop loss or take profit first?

makovez avatar Feb 16 '23 13:02 makovez

When SL and TP are hit within the same bar, backtesting.py acts pessimistically, that is considering SL as hit first. https://github.com/kernc/backtesting.py/blob/0ce24d80b1bcb8120d95d31dc3bb351b1052a27d/backtesting/backtesting.py#L843-L848 Have to double check if this code works correctly with stop-limit orders. :thinking:

kernc avatar Feb 16 '23 13:02 kernc