Looking for help on Bresserts DSS Indicator
-
Hi, I'm attempting to build out a Bresserts DSS (Double Smoothed Stochastic) indicator. I have a working version both in TV and Pandas, but I'm failing to get it to work in BT.
When I pass the second stochastic into a bt.ind.EMA it fails to produce a line, or a value, only Nan's. I've run this with the EMA as a separate indicator, passing the stochastic as input, and still nothing. Thanks in advance for the help.
class DSS (bt.Indicator): lines = ('percent_K', 'pre_Calc','percent_K','stoch_triple', 'smoother','xDSS','stoch2','stochastic',) plotlines = dict(percent_K=dict(_name='%K', _plotskip=True,), pre_Calc=dict(_plotskip=True), stoch_triple =dict(_plotskip = True), stochastic =dict(_plotskip = False), xDSS = dict(_plotskip=True),) params = dict( period=10, ema_length = 9, trigger_length = 5 ) def __init__(self): self.lines.pre_Calc = btind.EMA(bt.talib.STOCH(self.data.close, self.data.high, self.data.low, period = self.p.period ), period = self.p.ema_length) # self.lines.pre_Calc = bt.talib.STOCH(self.data.close, self.data.high, self.data.low, period = self.p.period ) self.lines.stochastic = btind.EMA(bt.talib.STOCH(self.lines.pre_Calc, self.lines.pre_Calc, self.lines.pre_Calc, period = self.p.period ),period = self.p.ema_length)
Tradingview code
'''
study(title="DSS Bressert (Double Smoothed Stochastic)", shorttitle="DSS Bressert")
PDS = input(10, minval=1)
EMAlen = input(9, minval=1)
TriggerLen = input(5, minval=1)xPreCalc = ema(stoch(close, high, low, PDS), EMAlen)
xDSS = ema(stoch(xPreCalc, xPreCalc, xPreCalc, PDS), EMAlen)
xTrigger = ema(xDSS, TriggerLen)'''
Pandas code
def DSS(self, High, Low, Close): self.df_xfer = pd.DataFrame() self.period = 10 #PDS self.ema_len = 9 # self.trigger_len = 5 # Set minimum low and maximum high of the k stoch self.df_xfer['High_Max'] = High.rolling(self.period).max() self.df_xfer['Low_Min'] = Low.rolling(self.period).min() #Calculate the Stochastic self.df_xfer['%K'] = 100 * (Close - self.df_xfer['Low_Min']) / (self.df_xfer['High_Max'] - self.df_xfer['Low_Min']) self.df_xfer['preCalc'] = self.df_xfer['%K'].ewm(span = self.ema_len, min_periods=1 ).mean() self.df_xfer['xDSS_3'] = self.stochastics(self.df_xfer['preCalc'],self.df_xfer['preCalc'],self.df_xfer['preCalc']).ewm(span = self.ema_len, min_periods=1).mean() self.df_xfer['Trigger'] = self.df_xfer['xDSS_3'].ewm(span = self.trigger_len, min_periods=1).mean() return (self.df_xfer['xDSS_3'], self.df_xfer['Trigger'])