Open and Close on the same bar #1170
Replies: 1 comment
-
I answered my own question. I had to update the logic of the buy code to verify whether a trade will be closing on the bar and if so then open a new buy trade if the signal is true again. I got it to work. Nice! Great tool this! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all. I recently started looking at bt and was wondering if it had the ability to open and close trades on the same bar. I have read that if a SL or TP is hit it can (might have it wrong), but my requirement is a little bit different. Let me explain.
If you open a trade, let's say using Stoch <= 20 and use a time-based exit of 2 bars it means that the trade will close out after 2 trading bars. This is all, buy and sell, at the close of the bar. But if the buy signal becomes true again then the situation exists where the buy and close signal is both true at the same time. This might sound strange, but I have a couple of trading system working this way.
Currently the new buy signal will get pushed to the next day instead of buying at the close of the bar, thus causing alpha decay in the return stream.
Any suggestions or am I going down a rabbit hole with no bottom?
Beta Was this translation helpful? Give feedback.
All reactions