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.
Breakout strategy using the N-period price channel (highest high / lowest low). Enters long on a close above the prior channel high, exits on a close below the channel low. Similar to Donchian but uses raw high/low.
class PriceChannel(Strategy):
n = 20
def init(self):
self.ch_high = self.I(_channel_high, self.data.High, self.n)
self.ch_low = self.I(_channel_low, self.data.Low, self.n)
def next(self):
if self.data.Close[-1] >= self.ch_high[-2] and not self.position:
self.buy()
elif self.data.Close[-1] <= self.ch_low[-2] and self.position:
self.position.close()| Total return | +37.633% |
| Net profit | $376,327 |
| Gross profit | $625,172 |
| Gross loss | $436,767 |
| CAGR | +3.362% |
| Annualized return | +3.362% |
| Monthly average return | +0.308% |
| Median monthly return | +0.423% |
| Best month return | +9.571% |
| Worst month return | -7.774% |
| Rolling 1-month return | +13.798% |
| Return per trade | +0.326 |
| Log return CAGR | +20.128% |
| Compounded vs simple return difference | -35.941% |
13 trades · green dashes = buy entries · red dashes = sell exits
| Total return | +28.475% |
| Net profit | $284,750 |
| Gross profit | $445,100 |
| Gross loss | $172,970 |
| CAGR | +7.826% |
| Annualized return | +7.826% |
| Monthly average return | +0.622% |
| Median monthly return | +0.667% |
| Best month return | +6.104% |
| Worst month return | -5.900% |
| Rolling 1-month return | +10.041% |
| Return per trade | +1.955 |
| Log return CAGR | +19.179% |
| Compounded vs simple return difference | -21.265% |