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.
Volume-Weighted Moving Average gives more weight to price levels with higher volume. The fast/slow VWMA crossover identifies trend changes with volume confirmation, reducing false signals in low-volume moves.
class VWMACross(Strategy):
n_fast = 10
n_slow = 20
def init(self):
close, vol = self.data.Close, getattr(self.data, "Volume", None)
self.vwma_fast = self.I(_vwma, close, vol, self.n_fast)
self.vwma_slow = self.I(_vwma, close, vol, self.n_slow)
def next(self):
if crossover(self.vwma_fast, self.vwma_slow):
self.buy()
elif crossover(self.vwma_slow, self.vwma_fast):
self.position.close()