customized indicator plot problem
-
I customized an indicator , I wanted to plot it with main data, I wrote " self.xxx.plotinfo.plotmaster = self.data" but it doesn't work. please tell me the reason. Thank you !
-
Can you kindly include the full block of code and the error message in your question?
@Sam said in customized indicator plot problem:
it doesn't work. please tell me the reason
...is not very informative.
-
class LeiDa(bt.Indicator):
lines = ('zhuli', )def __init__(self): self.addminperiod(30) def next(self): dataclose = self.data.get(size=30) close_ma = talib.MA(np.array(dataclose), timeperiod=7, matype=0) temp = (dataclose[-20:] - close_ma[-20:]) / close_ma[-20:] * 480 result = talib.EMA(temp, timeperiod=2) * 5 self.zhuli[0] = result[-1:]
class MyStrategy(bt.Strategy):
def __init__(self): self.leida = LeiDa(self.data) self.leida.plotinfo.plotmaster = self.data
-
@run-out Hi ,I just post my code, Can you help me? Why didn't my indicator plot with the main data? Thank you!
-
your price range is 240+, your indicator shows -1.43. diagram range is set by
master
, therefore you can't see the indicator. I suggest to show it on the separate plot since this is type of the oscillator. -
@ab_trader Thank you!