Strategy
This strategy is backtested on daily OHLCV price data across major US equity indices and ETFs. Entry and exit signals are generated from the strategy's indicators with no lookahead bias; trades execute at the open of the bar following the signal.
Performance metrics are computed per symbol and shown individually. The parameter optimization section, where available, runs a grid search over the strategy's key parameters, optimizing for Sharpe ratio. Transaction costs and slippage are not modeled.
The signal logic and indicator code for this strategy is shown in the methodology code section below.
Triple EMA (3×EMA1 − 3×EMA2 + EMA3) is the most lag-reduced of the EMA family. Fast/slow TEMA crossover provides early trend signals with minimal whipsaws compared to simpler MAs.
class TEMACross(Strategy):
n_fast = 9
n_slow = 21
def init(self):
self.tema_fast = self.I(_tema, self.data.Close, self.n_fast)
self.tema_slow = self.I(_tema, self.data.Close, self.n_slow)
def next(self):
if crossover(self.tema_fast, self.tema_slow):
self.buy()
elif crossover(self.tema_slow, self.tema_fast):
self.position.close()