BOY, do I feel stupid. Thank you Mr. Backtrader! :)
Posts made by Samuel Strickland
RE: Help plotting a custom indicator's line object on the main plot
Help plotting a custom indicator's line object on the main plot
I've managed to get a custom indicator to work. I'm able to interact with it in my next(self) function.
Only problem is, it will not plot on the main plot, it only plots on a subplot (I really want it on the main plot).
I feel like I'm losing my mind over something so simple. Help me please.
import backtrader as bt class indmax(bt.Indicator): lines = ('max') params = (('period', 250),) def __init__(self): # pulled this bit from the backtrader stochastic rsi source code hh = bt.indicators.Highest(self.data, period=self.p.period) self.lines.max = hh
In my strategy, I reference the custom indicator like so:
class HelpMeStrategy(bt.Strategy): params = (('maxperiod', 250),) def __init__(self): self.stratmax= indmax(self.datas, period=self.params.maxperiod)
Doing the these steps with the existing backtrader sma indicator yields a plot on the main plot by default, but not my stupid custom indicator.