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.
ATR-based volatility breakout: enters long when price closes above the EMA plus a multiple of ATR, signalling an expansion beyond normal volatility. Exits when price falls back below the EMA.
class VolatilityBreakout(Strategy):
n = 20
atr_n = 14
mult = 2
def init(self):
atr_vals = _atr(self.data.High, self.data.Low, self.data.Close, self.atr_n)
self.sma = self.I(_ema, self.data.Close, self.n)
upper_vals = _ema(self.data.Close, self.n) + self.mult * atr_vals
self.upper = self.I(lambda: upper_vals, name="Upper")
def next(self):
if self.data.Close[-1] > self.upper[-2] and not self.position:
self.buy()
elif self.data.Close[-1] < self.sma[-1] and self.position:
self.position.close()| Total return | +35.439% |
| Net profit | $354,391 |
| Gross profit | $566,375 |
| Gross loss | $371,753 |
| CAGR | +3.328% |
| Annualized return | +3.328% |
| Monthly average return | +0.293% |
| Median monthly return | +0.279% |
| Best month return | +8.554% |
| Worst month return | -6.108% |
| Rolling 1-month return | +13.969% |
| Return per trade | +0.296 |
| Log return CAGR | +31.550% |
| Compounded vs simple return difference | -29.710% |
17 trades · green dashes = buy entries · red dashes = sell exits
| Total return | -0.307% |
| Net profit | -$3,070 |
| Gross profit | $193,120 |
| Gross loss | $188,110 |
| CAGR | -0.092% |
| Annualized return | -0.092% |
| Monthly average return | +0.022% |
| Median monthly return | -0.302% |
| Best month return | +3.255% |
| Worst month return | -5.214% |
| Rolling 1-month return | +7.049% |
| Return per trade | -0.018 |
| Log return CAGR | +0.211% |
| Compounded vs simple return difference | +0.391% |