-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Sell and Buy limits are not being respected #1070
Unanswered
MrPotatoHead-Dev
asked this question in
Q&A
-
Here is the code for a strategy I have.
df = df[-70:]
class PatreonBlock(Strategy):
initsize = 0.99
mysize = initsize
def init(self):
super().init()
self.signal1 = self.I(SIGNAL)
def next(self):
super().next()
stoploss = self.data.SL[-1]
range_High = self.data.ons_High[-1]
range_Low = self.data.ons_Low[-1]
entry = self.data.entry[-1]
cc_close = self.data.Close[-1]
if self.data.signal is not None:
if self.data.signal == 1.0 and stoploss > cc_close:
print(entry, stoploss, range_Low, self.data.time[-1])
print()
self.sell( tp = range_Low, sl=stoploss+10, size =1)
elif self.data.signal == 2.0:
tp_price = range_High
self.buy(tp = range_Low, sl=stoploss-10)
Ive plotted the signals and they are showing up where they are but when I go to use backtesting the positions arent being opened. I have tried on VS code and on Colab. both with limits, and without. Im stumped.
Any help would be much appreciated.
Ps I know its a bit messy as I was moving things around trying to get it to work. With the lookback of the last 70 candles I should have multiple short positions opened.
Its using data from US100
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment