Replies: 2 comments
-
Might indeed be a bug, see #119 (comment). Thanks. |
Beta Was this translation helpful? Give feedback.
-
I'm jumping on this conversation but happy to post this as a new question. I'm seeking clarification on the execution of orders in relation to the trade_on_close flag and intra-candle price movements. If I understand correctly, orders are executed either at the close of the current bar or at the open of the next bar, depending on the Essentially, I'm inquiring whether the High and Low of a candle are considered for triggering take-profit and stop-loss orders. I'm working with large datasets and moving to a more granular time frame for every trade could be challenging. I'm wondering if there's a possible workaround or if a feature like Thank you! |
Beta Was this translation helpful? Give feedback.
-
Thank you for this library. I’ve only started learning about programming half a year ago so I still lack a lot of knowledge, but your library is quite intuitive. But I can’t figure out if there is anything I can do to solve the following issues:
Quite a lot of trades execute on the same bar as the entry, so I get a bunch of these warnings:
UserWarning: (2023-05-09 17:00:00) A contingent SL/TP order would execute in the same bar its parent stop/limit order was turned into a trade. Since we can't assert the precise intra-candle price movement, the affected SL/TP order will instead be executed on the next (matching) price/bar, making the result (of this trade) somewhat dubious. See #119
My orders are always set up like this for both sides:
self.sell_order = self.sell(size=self.sell_size, limit=self.sell_price, sl=self.sell_sl, tp=self.sell_tp)
So entry and tp are always limit orders and stop loss is a always a market order.
However, stop loss order doesn’t get registered if it happens on the same candle as when the trade is opened, and if it is reached only by a wick. For example, the following trade registers as a win instead of a loss, even though the stop loss is hit:
Is there anything I can do so that stop loss would always get triggered even if it happens on the same candle as the open? I’ve asked ChatGPT and it suggested some edits to the copy of backtesting.py, but that didn’t go anywhere. I’m not yet capable of understanding that code very well. If you have any suggestions about how I can work around this issue, please let me know.
It would also be OK if other stuff wouldn’t work because of the required edits, I would be satisfied if I could get a proper Win Rate % for now.
Beta Was this translation helpful? Give feedback.
All reactions