Strategy
This is a long-only daily strategy. The indicator is computed from the completed bar, and the order fills at the next bar’s open. Each fill pays 0.10% commission. There is no extra slippage, and the strategy does not sell short.
Metrics below are one index at a time, not a portfolio of them. Where a parameter search is available, it picks the Sharpe-maximizing grid point on the S&P 500. That search sees the same sample it reports, so the best cell is an in-sample peak.
The signal logic and indicator code for this strategy is shown in the methodology code section below.
Know Sure Thing (KST) combines four smoothed ROC values with increasing weights. Enters long when KST crosses above its signal line, exits on the reverse. Designed to capture major market cycles.
class KnowSureThing(Strategy):
r1,r2,r3,r4 = 10,15,20,30
s1,s2,s3,s4 = 10,10,10,15
sig_n = 9
def init(self):
c = pd.Series(self.data.Close)
kst = 100*(c.pct_change(self.r1).rolling(self.s1).mean()*1 + c.pct_change(self.r2).rolling(self.s2).mean()*2 + c.pct_change(self.r3).rolling(self.s3).mean()*3 + c.pct_change(self.r4).rolling(self.s4).mean()*4)/10
self.kst = self.I(lambda: kst, name="KST")
self.signal = self.I(lambda: kst.ewm(span=self.sig_n, adjust=False).mean(), name="Signal")
def next(self):
if crossover(self.kst, self.signal) and not self.position: self.buy()
elif crossover(self.signal, self.kst) and self.position: self.position.close()