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.
Applies the Stochastic formula to RSI values rather than price, creating a faster and more sensitive oscillator. Enters long when Stochastic RSI is below 20 (oversold RSI), exits above 80.
class StochasticRSI(Strategy):
rsi_n = 14
stoch_n = 14
oversold = 20
overbought = 80
def init(self):
rsi = _rsi(self.data.Close, self.rsi_n)
stoch = _stoch_rsi(rsi, self.stoch_n)
self.stoch_rsi = self.I(lambda: stoch, name="StochRSI")
def next(self):
if self.stoch_rsi[-1] < self.oversold and not self.position:
self.buy()
elif self.stoch_rsi[-1] > self.overbought and self.position:
self.position.close()| Total return | +39.037% |
| Net profit | $390,367 |
| Gross profit | $978,920 |
| Gross loss | $616,288 |
| CAGR | +8.933% |
| Annualized return | +8.933% |
| Monthly average return | +0.728% |
| Median monthly return | +0.599% |
| Best month return | +6.570% |
| Worst month return | -7.070% |
| Rolling 1-month return | +11.379% |
| Return per trade | +0.745 |
| Log return CAGR | +8.112% |
| Compounded vs simple return difference | -37.911% |
39 trades · green dashes = buy entries · red dashes = sell exits
| Total return | +65.649% |
| Net profit | $656,490 |
| Gross profit | $1,016,090 |
| Gross loss | $459,310 |
| CAGR | +16.389% |
| Annualized return | +16.389% |
| Monthly average return | +1.222% |
| Median monthly return | +7.187% |
| Best month return | +11.269% |
| Worst month return | +0.359% |
| Rolling 1-month return | +16.650% |
| Return per trade | +1.306 |
| Log return CAGR | +65.267% |
| Compounded vs simple return difference | -43.587% |