Replies: 1 comment 1 reply
-
You can relate ...
last_trade = self.closed_trades[-1]
if len(self.data.index) - last_trade.exit_bar > 2:
# At least two days since last trade was closed
self.buy(...) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings all,
I just started out my journey into backtesting and python programming as such recently. I was able to implement my strategy, however there was one thing I was struggling with i.e. to code a condition such that I want to avoid taking a new trade in the same candle where we have hit a stop loss or have taken profit. Below is some is one of sample condition I'm checking before going long
Any idea how do I add this condition for this in second if statement ? I want to go long only after closing of 2 candles after the candle where we hit SL or take profit. I saw some variables like exit_bar in closed trades which might help but i'm not able to use them.
Beta Was this translation helpful? Give feedback.
All reactions