ATR Trailing Stop

← 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

Enters long immediately and uses an ATR-based trailing stop (close minus mult×ATR). The stop adapts to volatility — wider in volatile markets, tighter in calm ones — protecting profits while allowing room to breathe.

Implementation

class ATRTrailingStop(Strategy):
    n = 14
    mult = 2.0

    def init(self):
        h, l, c = self.data.High, self.data.Low, self.data.Close
        self.atr = self.I(_atr, h, l, c, self.n)

    def next(self):
        atr_val = self.atr[-1]
        stop = self.data.Close[-1] - self.mult * atr_val
        if not self.position:
            self.buy()
        elif self.data.Close[-1] < stop:
            self.position.close()

Performance metrics

Total return+151.640%
Net profit$1,516,397
Gross profit$1,499,327
Gross loss$862,691
CAGR+15.042%
Annualized return+15.042%
Monthly average return+1.233%
Median monthly return+1.435%
Best month return+5.777%
Worst month return-8.321%
Rolling 1-month return+9.879%
Return per trade+2.090
Log return CAGR+1.626%
Compounded vs simple return difference-154.227%

Equity curves

Chart for symbol:

Charts & distributions

2025-06 → 2026-04 · 5-year daily data

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

24 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+59.169%
Net profit$591,690
Gross profit$1,215,950
Gross loss$660,790
CAGR+15.001%
Annualized return+15.001%
Monthly average return+1.201%
Median monthly return+2.129%
Best month return+5.222%
Worst month return-10.562%
Rolling 1-month return+6.137%
Return per trade+1.963
Log return CAGR-25.006%
Compounded vs simple return difference-69.960%