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.
Weighted Moving Average crossover, where recent prices carry more weight than older ones. Enters long on fast WMA crossing above slow WMA, exits on the reverse. More responsive than SMA crossover.
class WMACross(Strategy):
n_fast = 10
n_slow = 20
def init(self):
self.wma_fast = self.I(_wma_simple, self.data.Close, self.n_fast)
self.wma_slow = self.I(_wma_simple, self.data.Close, self.n_slow)
def next(self):
if crossover(self.wma_fast, self.wma_slow):
self.buy()
elif crossover(self.wma_slow, self.wma_fast):
self.position.close()