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.
Rate of Change (ROC) measures the percentage change in price over N periods. Enters long when ROC exceeds a positive threshold, indicating upward momentum. Exits when ROC drops below the negative threshold.
class MomentumROC(Strategy):
n = 10
threshold = 0.02
def init(self):
self.roc = self.I(_roc, self.data.Close, self.n)
def next(self):
if self.roc[-1] > self.threshold and not self.position:
self.buy()
elif self.roc[-1] < -self.threshold and self.position:
self.position.close()| Total return | +87.893% |
| Net profit | $878,934 |
| Gross profit | $1,055,817 |
| Gross loss | $787,354 |
| CAGR | +5.357% |
| Annualized return | +5.357% |
| Monthly average return | +0.452% |
| Median monthly return | -1.076% |
| Best month return | +4.598% |
| Worst month return | -7.679% |
| Rolling 1-month return | +14.071% |
| Return per trade | +0.214 |
| Log return CAGR | +7.450% |
| Compounded vs simple return difference | -87.114% |
48 trades · green dashes = buy entries · red dashes = sell exits
| Total return | +46.122% |
| Net profit | $461,220 |
| Gross profit | $841,700 |
| Gross loss | $419,020 |
| CAGR | +12.081% |
| Annualized return | +12.081% |
| Monthly average return | +0.985% |
| Median monthly return | -0.843% |
| Best month return | +2.890% |
| Worst month return | -9.372% |
| Rolling 1-month return | +8.386% |
| Return per trade | +0.795 |
| Log return CAGR | -1.315% |
| Compounded vs simple return difference | -46.646% |