Skip to content

How limit price is executed. #894

Answered by kernc
kratos143 asked this question in Q&A
Discussion options

You must be logged in to vote

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, ...)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kratos143
Comment options

Answer selected by kratos143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants