Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Average True Range (ATR) can make a backtest’s stop distance respond to volatility, but it cannot make a flawed simulation trustworthy. A strategy can look profitable because it uses information that was unavailable at the time, was selected from many failed alternatives, omits assets that later disappeared, or assumes fills and costs that would not occur in practice. Treat ATR as one tool for modeling volatility—not as a cure for those problems.

What ATR changes in a backtest

ATR estimates how much an asset has been moving; it does not predict whether the next move will be up or down. A fixed-distance stop stays the same distance from its reference price regardless of recent volatility. An ATR-scaled stop changes that distance as the measured volatility changes.

For a bar at time t, true range (TR) is the greatest of:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • High(t) − low(t)
  • |high(t) − close(t−1)|
  • |low(t) − close(t−1)|

Comparing the current high and low with the prior close lets true range account for gaps between bars. ATR is an average of true ranges over a chosen period. One smoothed update described by Fidelity is ATR = (previous ATR × (n − 1) + current TR) / n, where n is the period. Fidelity describes 14 periods as typical, 2–10 as a shorter average, and 20–50 as a longer-term range; these are educational conventions, not universal optimal settings.

#1 Best Overall
Trading: Technical Analysis Masterclass: Master the financial markets
  • Language: english
  • Book - trading: technical analysis masterclass: master the financial markets
  • It is made up of premium quality material.

A rule might place a stop a chosen multiple of ATR from an entry or another reference price. The exact reference, multiplier, and rule for updating the stop are strategy choices, not properties guaranteed by ATR. A larger multiplier generally means a wider stop. If the strategy targets a fixed dollar risk per trade, that wider distance generally means a smaller position. The stop does not make a trade safer by itself.

As Fidelity notes, ATR is not directional: an expanding ATR can accompany buying pressure or selling pressure. A volatility-responsive stop may reduce exits caused by ordinary movement in a volatile instrument, but it can also permit a larger loss before the stop is reached. Whether the resulting strategy performs better is an empirical question for a properly designed test.

Why a backtest can look better than live trading

Lookahead bias and signal timing

Lookahead bias occurs when a simulated decision uses information that was not available when the decision supposedly happened. It can enter through an indicator, a data transformation, or the assumed time of execution. TradingView’s Pine Script User Manual identifies lookahead bias as a common cause of unrealistic strategy results and strategy repainting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
How to Day Trade for a Living: A Beginner’s Guide to Trading Tools and Tactics, Money Management, Discipline and Trading Psychology (Stock Market Trading and Investing)
  • As a day trader, you can live and work anywhere in the world. You can decide when to work and when not to work.
  • You only answer to yourself. That is the life of the successful day trader. Many people aspire to it, but very few succeed. Day trading is not gambling or an online poker game.
  • To be successful at day trading you need the right tools and you need to be motivated, to work hard, and to persevere.

A signal that uses a bar’s completed close is not necessarily eligible to fill at that same close: the bar’s final value may only be known after it closes. The test must state when the signal becomes known and when the order can first execute. TradingView says its broker emulator generally fills historical orders after a bar closes based on available chart data, while execution settings can change that behavior.

Some code patterns make future leakage easy to miss. Freqtrade documents examples including negative shifts, fixed-row access, and aggregations over a full dataframe. Its lookahead-analysis command compares a baseline with sliced backtests, but it can only check signals that actually trigger; an untriggered path may go undetected. Automated checks are useful, but they do not replace inspection of the logic and data timing.

Selection bias and overfitting

If you try many assets, date ranges, indicators, or parameter combinations and report only the strongest result, the winner may owe much of its apparent edge to the search. Choosing only instruments that survived or timeframes that worked creates a similar problem. TradingView’s strategy documentation cautions about selection bias from ignoring weak instruments, timeframes, or date ranges, and recommends testing outside the data used for optimization.

Keep a record of the variants tried, including disappointing results. Tune on one period, freeze the rules, and evaluate them on a separate period that was not used to choose the strategy. A holdout is less informative if it is repeatedly inspected and used to revise the rules; doing so turns it into part of the search.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a large scan of strategies, Probability of Backtest Overfitting (PBO), often assessed with combinatorially symmetric cross-validation, and the Deflated Sharpe Ratio (DSR) are possible diagnostics. They address selection-related concerns under their methods and assumptions; neither proves that a strategy will work in the future.

Survivorship and historical membership

A test of assets that exist today can omit companies or instruments that failed, merged, or were delisted. An index test can also be distorted if it applies today’s membership to the past instead of using the members that belonged to the index at each historical date.

In a 2008 paper, Gilles Daniel, Didier Sornette, and Peter Wohrmann reported an overstatement of “up to 8% per annum” in their example of look-ahead benchmark bias for the S&P 500, using CRSP data from 1926 to 2006. That is a result for their benchmark example and dataset, not a general estimate of the bias in an individual strategy.

Costs and fills that are too generous

Gross returns do not show what remains after trading costs. TradingView’s documentation says commission is not applied in its Pine strategy engine unless it is configured, and its default slippage is zero. Its documentation also illustrates that adding a commission assumption can reduce reported net profit and increase volatility and maximum drawdown. Actual costs depend on the asset, venue, order size, holding period, and account; a single generic cost assumption will not fit every strategy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Execution assumptions matter as much as the fee line. A limit order may not fill even if a bar’s recorded price reaches the limit. A bar-based test may also lack enough detail to establish the order in which a stop and a target were reached within the same bar. State the fill convention, how spread and slippage are modeled, and what happens when the available data cannot resolve an intrabar sequence.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to use ATR without overstating what it proves

Specify the ATR rule precisely enough that another person could reproduce it. At minimum, record:

  • The price bars and data interval used to calculate ATR.
  • The lookback period and smoothing convention.
  • The stop’s reference price, ATR multiplier, and whether the stop can move after entry.
  • When a revised stop becomes active and how gaps or intrabar touches are handled.
  • The position-sizing rule, including whether position size changes to keep dollar risk fixed.

Then compare the ATR rule with the fixed-distance alternative using the same data, signal timing, fill convention, and cost model. Examine nearby lookbacks and multipliers as well as periods not used to tune the strategy. If only one carefully chosen setting works, the result may be fragile. ATR can make a threshold volatility-aware; it cannot establish that the underlying entry signal has an edge.

A practical audit before trusting the result

  1. Define the historical universe. Record which assets were eligible on each date. If point-in-time membership or delisted assets are unavailable, say so and treat the resulting test as limited.
  2. Check every input’s timestamp. Confirm that indicators and features use only data available at the decision time. Inspect negative shifts, full-sample aggregations, and higher-timeframe data handling.
  3. Separate signal time from fill time. Write down when the signal is knowable, when an order may be submitted, and the first price or event at which the simulator permits a fill.
  4. Freeze the rules before final evaluation. Keep a final evaluation period out of parameter selection, disclose how many variants were tried, and consider PBO or DSR diagnostics if the strategy came from a broad scan.
  5. Model execution and costs. Report gross and net results, commission assumptions, spread or slippage treatment, and limit-order fill rules. Check how plausible changes in costs affect the outcome.
  6. Test the ATR specification, not just its headline result. Record the calculation and stop rules, vary nearby parameters, and evaluate on unseen periods with the same execution discipline.
  7. Use forward testing as additional evidence. A forward test avoids using future bars in decisions, but it usually covers a smaller sample and cannot by itself establish behavior across different market regimes.

Even an untouched out-of-sample period or a forward test is evidence only about the sample and conditions observed. Neither guarantees future performance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.