Random Walk Index

← strategies

Strategy

Methodology

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.

Methodology

Random Walk Index compares actual price movement to what would be expected in a random walk. RWI > 1 indicates a non-random directional move (true trend). Enters long on breakout, exits when RWI drops below 0.5.

Implementation

class RandomWalkIndex(Strategy):
    n = 14

    def init(self):
        h,l,c = pd.Series(self.data.High), pd.Series(self.data.Low), pd.Series(self.data.Close)
        atr = _atr(h, l, c, self.n)
        rwi_high = (h - l.shift(self.n)) / (atr * np.sqrt(self.n)).replace(0,1e-10)
        self.rwi = self.I(lambda: rwi_high, name="RWI")

    def next(self):
        if self.rwi[-1] > 1 and not self.position: self.buy()
        elif self.rwi[-1] < 0.5 and self.position: self.position.close()

Performance metrics

Total return+36.724%
Net profit$367,235
Gross profit$566,190
Gross loss$415,677
CAGR+2.541%
Annualized return+2.541%
Monthly average return+0.226%
Median monthly return-0.153%
Best month return+8.813%
Worst month return-7.896%
Rolling 1-month return+14.359%
Return per trade+0.112
Log return CAGR+48.592%
Compounded vs simple return difference-31.044%

Equity curves

Chart for symbol:

Charts & distributions

2024-02 → 2026-04 · 5-year daily data

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

23 trades · green dashes = buy entries · red dashes = sell exits

Drawdown (underwater)

Rolling 1-month Sharpe

Rolling 1-month return (%)

Period return (≈ monthly)

Return distribution (bar returns)

MAE vs MFE (trades)

Rolling 12m Beta

Rolling 12m correlation

Monthly returns (run)

Performance Matrix

Total return+6.205%
Net profit$62,050
Gross profit$261,020
Gross loss$191,440
CAGR+1.827%
Annualized return+1.827%
Monthly average return+0.171%
Median monthly return+0.324%
Best month return+10.145%
Worst month return-12.786%
Rolling 1-month return+10.145%
Return per trade+0.263
Log return CAGR-9.285%
Compounded vs simple return difference-9.998%