-
Suppose i have 5 minutes data frame. And i want to enter a short position if previous candle low is broken. I don't want to wait for current candle to close. I want to enter when the low is broken. Can we do this like limit = self.data.Low[-1] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
When you "see" the current bar, it has already closed. This is how the framework works, and this prevents us from falling for lookahead bias. The way to achieve this is as you say, placing a stop-limit order. If you just placed a limit order, it would execute whenever the price is above the set limit (for short orders), so you need to add a stop to make sure the order only becomes valid once the stop is hit. I.e.: low = self.data.Low[-1]
self.sell(limit=low, stop=low, ...) |
Beta Was this translation helpful? Give feedback.
When you "see" the current bar, it has already closed. This is how the framework works, and this prevents us from falling for lookahead bias.
The way to achieve this is as you say, placing a stop-limit order. If you just placed a limit order, it would execute whenever the price is above the set limit (for short orders), so you need to add a stop to make sure the order only becomes valid once the stop is hit. I.e.: