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.
Hull Moving Average reduces lag by using weighted MAs of different periods. The HMA crossover fires faster than SMA/EMA crossovers while remaining smooth. Enters on fast HMA crossing above slow HMA.
class HullMACross(Strategy):
n_fast = 9
n_slow = 18
def init(self):
self.hma_fast = self.I(_hma, self.data.Close, self.n_fast)
self.hma_slow = self.I(_hma, self.data.Close, self.n_slow)
def next(self):
if crossover(self.hma_fast, self.hma_slow):
self.buy()
elif crossover(self.hma_slow, self.hma_fast):
self.position.close()