signals stop showing after a certain date
pretty new to this. followed some guide online and i managed to write out this code which seems to work fine until after july. I'm just trying to create a chart with the 14 day RSI as an indicator to signal buy (rsi<30) and sell (rsi>70) points.
here is my code
import backtrader as bt import datetime class RSIStrategy(bt.Strategy): def __init__(self): self.rsi = bt.talib.RSI(self.data, period=14) def next(self): if self.rsi < 30 and not self.position: self.buy(size=1) if self.rsi > 70 and self.position: self.close() cerebro = bt.Cerebro() fromdate = datetime.datetime.strptime('2020-01-01', '%Y-%m-%d') todate = datetime.datetime.strptime('2020-12-25', '%Y-%m-%d') data = bt.feeds.GenericCSVData(dataname='2020_hourly.csv', dtformat=2, compression=60, timeframe=bt.TimeFrame.Minutes, fromdate=fromdate, todate=todate) cerebro.adddata(data) cerebro.addstrategy(RSIStrategy) cerebro.run() cerebro.plot()
the data import is fine, double checked that so it shouldn't be the problem. but the chart it produces looks like this
as you can see, after around end july, the signals stop appearing even though there are certain points where the rsi is clearly below 30 (some even below 20) or over 70.
could anyone help identify what the problem is? would really appreciate it, thanks!
vladisld last edited by
Most probably this is because of the available cash that you set for the broker - actually you didn't so the default (10000$) is used instead. The problem is that the price of the asset you are working with grows beyond that limit - the price is already around 11000$ after July. So your orders are simply rejected from that point on.
Try to set the available cash to something larger: