backtrader.indicators.kst module¶
KST Indicator Module - Know Sure Thing indicator.
This module provides the KST (Know Sure Thing) momentum indicator developed by Martin Pring.
- Classes:
KnowSureThing: KST indicator (alias: KST).
示例
- class MyStrategy(bt.Strategy):
- def __init__(self):
self.kst = bt.indicators.KST(self.data) self.kst_signal = bt.indicators.KST(self.data, rp1=10, rp2=15, rp3=20, rp4=30)
- def next(self):
- if self.kst.kst[0] > self.kst.signal[0]:
self.buy()
- elif self.kst.kst[0] < self.kst.signal[0]:
self.sell()
- class backtrader.indicators.kst.KnowSureThing[源代码]¶
基类:
IndicatorIt is a "summed" momentum indicator. Developed by Martin Pring and published in 1992 in Stocks & Commodities.
- Formula:
rcma1 = MovAv(roc100(rp1), period)
rcma2 = MovAv(roc100(rp2), period)
rcma3 = MovAv(roc100(rp3), period)
rcma4 = MovAv(roc100(rp4), period)
Kst = 1.0 * rcma1 + 2.0 * rcma2 + 3.0 * rcma3 + 4.0 * rcma4
signal = MovAv(kst, speriod)
- See:
Params
rma1,rma2,rma3,rma4: for the MovingAverages on ROCsrp1,rp2,rp3,rp4: for the ROCsrsig: for the MovingAverage for the signal linerfactors: list of factors to apply to the different MovAv(ROCs)_movavand_movavs, allows to change the Moving Average type applied for the calculation of kst and signal
- alias = ('KST',)¶
- plotinfo = <backtrader.metabase.plotinfo_obj object>¶
- __init__(*args, **kwargs)¶
- next()[源代码]¶
Calculate KST and signal for the current bar.
Formula: KST = w1*RCMA1 + w2*RCMA2 + w3*RCMA3 + w4*RCMA4 Signal = SMA(KST, rsignal)
- frompackages = ()¶
- packages = ()¶