Supertrend strategy

On ES futures, the Supertrend strategy lost $99,524 after costs and ran a $100,000 account down to its margin on July 31, 2020. The run stops there.

TrendSwingHourly barsBacktested Nov 6, 2026

Supertrend backtest, the result

Contract

E-mini S&P 500

  • −$99.5K

    Net after costs

    After $21,524 in fees and slippage

  • 1 of 5

    Years that made money

    January 2016 to July 2020

  • −$101K

    Largest drawdown

    Peak to trough, 1 contract

  • −$130

    Average trade

    766 trades

Supertrend on ES, net after costs by month, from January 2016 to July 2020: −$99,524; buying and holding one ES contract: +$236,212

Net after costs by month, January 2016 to July 2020.

Supertrend rules

A band 3 ATRs from price changes side when price closes through it, so the strategy is always long or short.

A drawing of the rules on a made-up day, not a result.

  1. The ATR is Wilder's average of the true range over 10 one-hour bars; the bands are the bar's midpoint plus and minus 3 ATR, the upper band moving only down and the lower only up unless the previous close crossed them.
  2. In a downtrend a close above the upper band turns the trend up; in an uptrend a close below the lower band turns it down.
  3. After 10 bars the strategy holds one contract long in an uptrend and short in a downtrend, through every session of the contract, turning round at each change.
Decides on
Hourly bars
Holds
Overnight and across days
Parameters
factor 3, warmup 10

Results by year

It made money in 1 of 5 years on ES. Its best year was 2018, +$2,207, and its worst 2017, −$22,177. The account was closed out on July 31, 2020, so the years stop there.

Net after costs by year on ES, with trades, win rate, largest drawdown and buying and holding the same contract
YearNetTradesWin rateDrawdownBuy and hold
2016−$21,78617428%−$28,179+$11,497
2017−$22,17717128%−$23,874+$21,936
2018+$2,20716039%−$34,200−$8,589
2019−$13,03815133%−$22,978+$35,436
2020, Jan to Jul−$44,72911030%−$57,633+$27,761

Supertrend backtest results

On ES it lost $78,000 before costs, then paid $21,524 in fees and slippage.

Net = before costs − fees − slippage
ES: −$78,000 − $2,599 − $18,925 = −$99,524
Every figure of the Supertrend backtest, by contract
FigureESNQ
Net after costs−$99,524+$65,524
Before costs−$78,000+$112,940
Fees$2,599$6,271
Slippage$18,925$41,145
Trades7661,767
Trades a year170168
Win rate31%38%
Profit factor0.781.03
Average trade−$130$36
Average trade, 95% interval−$250 to −$11−$157 to $228
Sharpe ratio-0.820.10
Largest drawdown−$101,328−$114,497
Time in the market100%100%
Buying and holding the contract+$236,212+$401,004

The whole interval is under zero: after costs, the average trade lost money.

Supertrend code and Pine Script

The strategy as the backtest ran it, and the Pine Script our compiler wrote from it for TradingView.

Supertrend
supertrend.py
1from atlantive import BUY, EMA, SELL, Bars, Strategy2 3 4class Supertrend(Strategy):5    """Supertrend, ATR(10) x 3, on one-hour bars, always in the market.6 7    The ATR is Wilder's average of the true range (alpha 1 / 10). The bands are the bar's midpoint8    (high + low) / 2 plus and minus 3 ATR; the upper band only moves down and the lower band only9    up, unless the previous close crossed them. In a downtrend the line is the upper band and a close10    above it turns the trend up; in an uptrend the line is the lower band and a close below it turns11    the trend down (the first bar starts in a downtrend, as TradingView's ta.supertrend does). After12    10 bars the strategy holds one contract long in an uptrend and short in a downtrend, turning13    round at each change, through every session of the contract.14    """15 16    data = "bars"17 18    class Params:19        factor: float = 3.020        warmup: int = 1021        clip: int = 122 23    class State:24        bars: Bars(interval_ns=3_600_000_000_000)25        atr: EMA(alpha=0.1)26        seen: int27        last_close: float28        upper: float29        lower: float30        trend: int31 32    def on_event(self, view, ev, orders):33        if not self.bars.update(ev):34            return35        high = float(self.bars.prev_high)36        low = float(self.bars.prev_low)37        close = float(self.bars.prev_close)38        tr = high - low39        if self.seen > 0:40            tr = max(tr, abs(high - self.last_close), abs(low - self.last_close))41        self.atr.update(tr)42        middle = (high + low) / 2.043        upper = middle + self.p.factor * self.atr.value44        lower = middle - self.p.factor * self.atr.value45        if self.seen == 0:46            self.trend = -147        else:48            if not (lower > self.lower or self.last_close < self.lower):49                lower = self.lower50            if not (upper < self.upper or self.last_close > self.upper):51                upper = self.upper52            if self.trend == -1:53                if close > upper:54                    self.trend = 155            elif close < lower:56                self.trend = -157        self.upper = upper58        self.lower = lower59        self.last_close = close60        self.seen += 161        if self.seen < self.p.warmup:62            return63        if self.trend == 1:64            if view.position < 0:65                orders.ioc(side=BUY, qty=abs(view.position) + self.p.clip)66            elif view.position == 0:67                orders.ioc(side=BUY, qty=self.p.clip)68        else:69            if view.position > 0:70                orders.ioc(side=SELL, qty=abs(view.position) + self.p.clip)71            elif view.position == 0:72                orders.ioc(side=SELL, qty=self.p.clip)
1//@version=62// Supertrend, exported from Atlantive.3// Chart simulation: decisions use completed bars; market orders fill at the next bar open.4// Native fills, fees, data gaps and session boundaries can differ. Re-test on the target symbol.5// Use standard time-based candles and the strategy's timeframe, not synthetic chart prices.6// Pine v6 trims old trade records at its order limit; the strategy keeps calculating.7// Margin is explicitly disabled to retain the native signal simulation's sizing.8strategy("Supertrend", overlay=true, initial_capital=100000.0, commission_type=strategy.commission.cash_per_contract, commission_value=1.68, default_qty_type=strategy.fixed, default_qty_value=1, calc_on_every_tick=false, process_orders_on_close=false, slippage=0, margin_long=0, margin_short=0)9 10if timeframe.in_seconds() != 360011    runtime.error("Supertrend was exported for the 60 minute timeframe; set the chart to 60.")12 13factor = input.float(3.0, "factor")14warmup = input.int(10, "warmup", minval=-9007199254740991, maxval=9007199254740991)15clip = input.int(1, "clip", minval=-9007199254740991, maxval=9007199254740991)16 17_q_safe_int(x) =>18    if math.abs(x) > 900719925474099119        runtime.error("an integer left the exact chart range; this run cannot be compared faithfully")20    int(x)21_q_int(x) => _q_safe_int(x < 0 ? math.ceil(x) : math.floor(x))22_q_iadd(a, b) => _q_safe_int(a + b)23 24_q_high = _q_int(math.round(high * 1000000000.0))25_q_low = _q_int(math.round(low * 1000000000.0))26_q_close = _q_int(math.round(close * 1000000000.0))27 28var int seen = 029var float last_close = 0.030var float upper = 0.031var float lower = 0.032var int trend = 033var float _q_atr_value = 0.034var bool _q_atr_seeded = false35var int _q_atr_skipped = 036var int _q_atr_frozen = 037float high_l = na38float low_l = na39float close_l = na40float tr = na41float middle = na42float upper_l = na43float lower_l = na44 45bool _q_running = true46high_l := _q_high * 1.047low_l := _q_low * 1.048close_l := _q_close * 1.049tr := high_l - low_l50if seen > 051    tr := math.max(tr, math.max(math.abs(high_l - last_close), math.abs(low_l - last_close)))52_q_sample1 = tr53if na(_q_sample1) or math.abs(_q_sample1) > 1.7976931348623157e30854    _q_atr_skipped := _q_atr_skipped + 155else56    if not _q_atr_seeded57        _q_atr_value := _q_sample158        _q_atr_seeded := true59    else60        _q_moved2 = _q_atr_value + 0.1 * (_q_sample1 - _q_atr_value)61        if _q_moved2 == _q_atr_value and _q_sample1 != _q_atr_value62            _q_atr_frozen := _q_atr_frozen + 163        _q_atr_value := _q_moved264middle := (high_l + low_l * 1.0) / 2.065upper_l := middle + factor * _q_atr_value66lower_l := middle - factor * _q_atr_value67if seen == 068    trend := _q_int(-1)69else70    if not (lower_l > lower or last_close < lower)71        lower_l := lower72    if not (upper_l < upper or last_close > upper)73        upper_l := upper74    if trend == -175        if close_l > upper_l76            trend := _q_int(1)77    else if close_l < lower_l78        trend := _q_int(-1)79upper := upper_l80lower := lower_l81last_close := close_l82seen := _q_int(_q_iadd(seen, 1))83if seen < warmup84    _q_running := false85if _q_running86    if trend == 187        if _q_int(strategy.position_size) < 088            _q_qty3 = _q_int(_q_iadd(math.abs(_q_int(strategy.position_size)), clip))89            if _q_qty3 <= 090                runtime.error("market order quantity must be a positive whole unit")91            _q_pos3 = _q_int(strategy.position_size)92            if _q_pos3 > 0 or _q_pos3 < 0 and _q_qty3 < -_q_pos393                runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")94            strategy.order("q1", strategy.long, _q_qty3)95        else if _q_int(strategy.position_size) == 096            _q_qty4 = _q_int(clip)97            if _q_qty4 <= 098                runtime.error("market order quantity must be a positive whole unit")99            _q_pos4 = _q_int(strategy.position_size)100            if _q_pos4 > 0 or _q_pos4 < 0 and _q_qty4 < -_q_pos4101                runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")102            strategy.order("q2", strategy.long, _q_qty4)103    else104        if _q_int(strategy.position_size) > 0105            _q_qty5 = _q_int(_q_iadd(math.abs(_q_int(strategy.position_size)), clip))106            if _q_qty5 <= 0107                runtime.error("market order quantity must be a positive whole unit")108            _q_pos5 = _q_int(strategy.position_size)109            if _q_pos5 < 0 or _q_pos5 > 0 and _q_qty5 < _q_pos5110                runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")111            strategy.order("q3", strategy.short, _q_qty5)112        else if _q_int(strategy.position_size) == 0113            _q_qty6 = _q_int(clip)114            if _q_qty6 <= 0115                runtime.error("market order quantity must be a positive whole unit")116            _q_pos6 = _q_int(strategy.position_size)117            if _q_pos6 < 0 or _q_pos6 > 0 and _q_qty6 < _q_pos6118                runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")119            strategy.order("q4", strategy.short, _q_qty6)

How it was tested

The published rules, never tuned on the data, with real costs on every fill. Every strategy here is tested the same way.

Market data
CME Globex hourly bars, Jan 2, 2016 to Jul 31, 2026
Rules
As published, with the published parameters, never tuned on this data
Size
1 contract on every trade
Contract
The most traded one, rolled as the market moved
Fees
The broker's $0.50 a side, plus CME's and the NFA's fees when the window opens
Slippage
1 tick a side on ES, 2 in NQ's regular session and 3 outside it, 1 on other markets, where it was not measured
Stops and entries
Tested on 1-second closes and filled at the next bar
Contracts traded
ES: 43 contracts, ESH6 to ESU6NQ: 43 contracts, NQH6 to NQU6
Costs paid
ES: $2,599 in fees, $18,925 in slippageNQ: $6,271 in fees, $41,145 in slippage
Warm-up
None: each contract reads only its own bars
Flagged days
ES: NoneNQ: None Days the data holds too few bars for. Flagged, not removed.

Could you pass
a prop firm challenge
with the Supertrend strategy?

A backtest says whether a strategy makes money. Our AI runs its trades through the rules of every prop firm account, then tells you which one it would pass and at what size.

No card needed. Free credits every month.

  • Most money: Blue Guardian Futures Direct 50K, $5,084
  • Best payout odds: Funded Futures Family Straight to Funded 50K, 98%
  • Fastest pass: Phidias Express to Live 50K, 11 days
Blue Guardian Futures Direct 50K
Most money

$5,084

Median net across 2,000 simulated runs

Evaluation
None
First payout
97%
Fees paid
$1,521

Median net across 2,000 simulated runs

Best 5%$13,143Worst 5%−$412
Day 060120180
Example: ES opening range breakout

Questions about the Supertrend strategy

What is the Supertrend strategy?

A band 3 ATRs from price changes side when price closes through it, so the strategy is always long or short. Atlantive backtested it on CME futures from January 2016 to July 2026 after costs.

Is the Supertrend strategy profitable on ES futures?

Not in this backtest: on ES futures from January 2016 to July 2020 it lost $99,524 after costs, over 766 trades, positive in 1 of 5 years; on NQ it made $65,524. Buying and holding one ES contract over the same window made $236,212. The average trade was −$130, its 95% interval −$250 to −$11. These are hypothetical results of a backtest, not of trading.

What are the Supertrend strategy's rules?

The ATR is Wilder's average of the true range over 10 one-hour bars; the bands are the bar's midpoint plus and minus 3 ATR, the upper band moving only down and the lower only up unless the previous close crossed them. In a downtrend a close above the upper band turns the trend up; in an uptrend a close below the lower band turns it down. After 10 bars the strategy holds one contract long in an uptrend and short in a downtrend, through every session of the contract, turning round at each change. Its parameters are the published ones, never tuned on the data it was tested on.

How was the Supertrend strategy backtested?

On CME Globex data from January 2016 to July 2026, one contract, on hourly bars, rolled to the most traded contract as the market moved, with the broker's and CME's fees and the slippage measured on each market. Stops and entries were tested on 1-second closes and filled at the next bar. Nothing was fitted to the data.

Can I run the Supertrend strategy in TradingView?

Yes. The page carries its Pine Script, written by Atlantive's compiler from the same code the backtest ran, for TradingView's strategy tester. A chart's fills and fees can differ from the backtest's, so test it again on the symbol you trade.

Can I change the Supertrend strategy and test it again?

Yes. Rerun it in Atlantive: a new chat opens with the strategy's rules in the box, for you to read, change and send. The agent writes the code, backtests it on the market and window you name, and reports the result with its costs.

Rerun it in Atlantive. Change the market, the dates or a rule, then send it.

A new chat opens with this in the box

Backtest a Supertrend, ATR(10) x 3, on one-hour bars on ES, 2016-01-02 to 2026-07-31, one contract on a $100,000 account with default costs: always in the market, long in an uptrend and short in a downtrend, turning at each change.

Never sent for you

May we measure this visit?

With your consent, Google Analytics and PostHog count visits to these pages. You can separately allow Google Ads to measure visits from our ads. Visit measurement starts only after you choose. Cookie policy