OBV Trend

← 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

On-Balance Volume accumulates volume on up days and subtracts on down days. Enters long when OBV rises above its moving average (smart money accumulating), exits when OBV drops below its MA.

Implementation

class OBVTrend(Strategy):
    n = 20

    def init(self):
        obv = _obv(self.data.Close, getattr(self.data, "Volume", None))
        self.obv = self.I(lambda: obv, name="OBV")
        self.obv_ma = self.I(_obv_sma, obv, self.n)

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

Performance metrics

Total return+5.485%
Net profit$54,851
Gross profit$784,570
Gross loss$718,375
CAGR+0.205%
Annualized return+0.205%
Monthly average return+0.080%
Median monthly return-1.095%
Best month return+5.165%
Worst month return-8.620%
Rolling 1-month return+10.408%
Return per trade+0.031
Log return CAGR-1.839%
Compounded vs simple return difference-7.964%

Equity curves

Chart for symbol:

Charts & distributions

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

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

67 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+13.468%
Net profit$134,680
Gross profit$706,250
Gross loss$545,430
CAGR+3.873%
Annualized return+3.873%
Monthly average return+0.366%
Median monthly return-4.914%
Best month return+4.441%
Worst month return-14.842%
Rolling 1-month return+8.615%
Return per trade+0.190
Log return CAGR-42.240%
Compounded vs simple return difference-33.040%