20191002: The community is currently in readonly mode
Stochastic values generated outside 0100

I have run a backtest on backtrader using a stochastic indicator and have recorded the results to a csv file. On further inspection, I have found stochastic values recorded as less than 0 as well as greater than 100. This is contrary to what was expected from this indicator.
I have used the following code which includes 2 stochastic indicators. The first(self.stochastic) uses the original data and the second stochastic indicator(self.stochastic15) uses the original data that has been resampled.
I tried using the stochastic indicator from both Backtrader and Talib and in both cases the same issue was found. The commented out sections in the code represents the Backtrader stochastic indicator.
class TestStrategy(bt.Strategy): def __init__(self): #self.stochastic = bt.indicators.StochasticSlow(self.data0, safediv = True, period=5, period_dfast=3, period_dslow=3) self.stochastic=bt.talib.STOCH(self.data0.high, self.data0.low, self.data0.close, fastk_period=5, slowk_period=3, slowd_period=3) self.stochastic.csv=True #self.stochastic15 = bt.indicators.StochasticSlow(self.data1, safediv = True, period=5, period_dfast=3, period_dslow=3) self.stochastic15 = bt.talib.STOCH(self.data1.high, self.data1.low, self.data1.close, fastk_period=5, slowk_period=3, slowd_period=3) self.stochastic15.csv=True
Does someone have some advise on how to resolve this?
Many thanks

@juliev said in Stochastic values generated outside 0100:
Does someone have some advise on how to resolve this?
Yes. Your data is wrong, hence the wrong results. The formula itself prevent any value above 100, but OHLC restrictions have to be for that, i.e.:
H >= C >= L