@ihustling said in IndexError: array index out of range when dealing with RSI indicator:
If you were wondering where I got the EMA indicators from, you mention SMA throughout the Quickstart guide and on your Github home page
Respectfully but truly sincere: you haven't read the docs.
Sorry, you seem to be in a rush and the trees are not letting you see the forest.
@backtrader said in IndexError: array index out of range when dealing with RSI indicator:
fast_ema = bt.ind.ExponentialMovingAverage(period = 5)
slow_ema = bt.ind.ExponentialMovingAverage(period = 10)
rsi = bt.ind.RSI(period = 10)
You WILL NEVER see those indicators (nor any other) defined inside the
From the Quickstart Guide:
# Keep a reference to the "close" line in the data dataseries
self.dataclose = self.datas.close
# To keep track of pending orders and buy price/commission
self.order = None
self.buyprice = None
self.buycomm = None
# Add a MovingAverageSimple indicator
self.sma = bt.indicators.SimpleMovingAverage(self.datas, period=self.params.maperiod)
I know it's tempting to go very quickly and be winning the first millions during your first days of algotrading, but I do truly believe you should read the docs. Be it backtrader, be it any other platform.
Even if you look at the GitHub page the code looks like this
sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)