Supertrend Calculator
Reproduce a transparent Supertrend series from entered bars, Wilder ATR, basic bands and the prior final-band state.
Enter chronological OHLC bars
Supertrend is path-dependent: keep every row in order and include enough warm-up history for the declared ATR period.
Whole number from 2 through 200, no longer than the entered history.
Positive decimal from 0.01 through 100; this is a scenario, not an optimized setting.
One row per bar: Label, High, Low, Close. Use commas, tabs or semicolons; omit a header row.
Latest Supertrend line and state
Entered Volatility Stop Overlays 1.0.0.
| Bar | Close | ATR | Final upper | Final lower | Supertrend | State |
|---|
How the recursive Supertrend line is calculated
Basic upper = HL2 + multiplier × ATR
Basic lower = HL2 − multiplier × ATR
Final bands retain or reset from prior bands according to the prior close
Active Supertrend = final lower in the up state; final upper in the down state
Version 1.0.0 calculates gap-aware true range and Wilder ATR first. Once the initial ATR becomes available, the basic upper and lower bands are midpoint plus or minus the ATR multiple. On that first ready bar, both final bands equal their basic bands, the disclosed boundary state is down, and the active Supertrend is the final upper band.
For each later bar, the basic upper replaces the previous final upper only when it is lower or the previous close was above the previous final upper; otherwise the prior upper is retained. The basic lower replaces the previous final lower only when it is higher or the previous close was below the previous final lower; otherwise the prior lower is retained.
State then depends on the prior active line. When the prior Supertrend was its final upper band, the state changes to up only if the current close is above the current final upper. When the prior line was its final lower band, the state changes to down only if current close is below current final lower. Strict comparisons mean equality does not flip state.
A careful interpretation workflow
Start with the visible inputs and row-level audit trail, then decide whether the entered history and declared convention answer your actual risk question. A precise line is not evidence that the line is optimal.
- Read the row table from the first ATR-ready bar; earlier rows are explicitly marked as warming up.
- Inspect final bands, not only basic bands, because retained prior values create the recursive path.
- Treat the direction label as model state rather than a standalone recommendation to buy or sell.
- Use completed bars if your rules act on close; this calculator cannot verify whether the final entered bar is complete.
- Compare platform results only after matching ATR smoothing, initialization, multiplier and equality conventions.
- Evaluate any strategy with costs, slippage, whipsaw controls and out-of-sample testing outside this page.
Worked example from the audited fixture
How to interpret the result
The two state changes prove that the audited example exercises both branches of the recursion. They do not prove profitable entries or exits. A live platform can differ because of intrabar updates, current-bar handling, source data, initialization, ATR warm-up, equality rules or an alternative published Supertrend variant.
ATR stop, Chandelier Exit and Supertrend compared
All three use ATR, but their anchors and state rules answer different questions. They should not be treated as duplicate names for the same stop. The table below keeps the differences visible before you transfer a value into a chart or risk worksheet.
| Overlay | Anchor | Path dependence | Primary output | Not included |
|---|---|---|---|---|
| ATR stop reference | Latest entered close | ATR recursion only | Symmetrical long/short reference | Volume and order rules |
| Chandelier Exit | Lookback highest high or lowest low | ATR plus rolling extrema | Long/short extrema-based reference | Crossing or fill verdict |
| Supertrend | HL2 basic bands retained by prior state | ATR plus recursive final bands and state | Active line and mechanical state | BUY/SELL recommendation |
The ATR Calculator isolates the underlying volatility series. The ATR Position Size Calculator then answers a separate question: how much volume corresponds to a chosen risk budget and ATR distance. Separating line placement from size helps prevent a wider volatility stop from silently increasing account risk.
Assumptions and limits
- At least the selected ATR-period number of OHLC rows is required; up to 2,000 rows are supported.
- The model initializes the first ATR-ready bar in the down state, matching the disclosed TradingView-style boundary.
- The current bar is included and treated exactly as entered; timestamps and bar completion are not validated.
- Different Supertrend implementations may use another ATR seed, warm-up, equality rule, source field or first state.
- A state change reflects only entered closes crossing recursive final bands; intrabar touches and fills are not modeled.
- No spread, commission, slippage, overnight gap, broker stop restriction or position risk is calculated.
- No historical profitability, forecast probability, optimal parameter, BUY/SELL instruction or personal advice is claimed.
Prepare OHLC data before calculating
Export completed bars from one symbol, one timeframe and one broker or data vendor. Keep them in chronological order from oldest to newest and include enough earlier history for the ATR recursion to warm up. A short pasted sample can reproduce the formula while still differing from a platform that initialized ATR hundreds of bars earlier.
Use raw price units consistently. Do not mix points, pips and quoted prices inside the OHLC rows. For currencies quoted to different decimal places, the formulas still operate in price units; any conversion to pips needs the symbol’s pip size. Metals, indices, crypto and CFDs can have contract and tick conventions that differ materially from spot FX.
Check high, low and close fields against the source before pasting. The calculator rejects a close outside the stated bar range, but it cannot discover a mislabeled timestamp, duplicated candle, daylight-saving shift, weekend rule or missing session. Record symbol, timeframe, time zone, source, dates, parameters and model version with any saved result.
If the level will inform a live order, separately check bid/ask side, current spread, tick size, minimum stop distance, guaranteed-stop rules, slippage, market gaps and position volume. These operational constraints are deliberately kept outside a descriptive entered-data calculator.
Frequently asked questions
- It builds HL2 basic bands from an ATR multiple, recursively retains or resets final bands using the prior close, and selects the active band from the prior state.
- Version 1.0.0 seeds with the first-period true-range mean and then uses Wilder recursive smoothing.
- At the first ATR-ready bar, final bands equal basic bands, the boundary state is down and the active line is the final upper band.
- When the previous active line was the final upper band, the current close must be strictly above the current final upper band.
- When the previous active line was the final lower band, the current close must be strictly below the current final lower band.
- Data, warm-up history, ATR seed, current-bar handling, source field, equality rules and formula variants can differ.
- No. Up and down are mechanical states in this calculation and are not standalone trade recommendations or forecasts.
- No. It does not backtest entries, exits, costs, slippage, parameter robustness or out-of-sample performance.
Sources and methodology
- TradingView — Supertrend — Documents the basic bands, recursive final bands and state logic used here.
- TradingView — Average True Range — Documents the true-range input and default RMA/Wilder smoothing.
- MQL5 Reference — iATR — Official MetaTrader 5 reference for the underlying ATR indicator input.
The operational contract is Entered Volatility Stop Overlays version 1.0.0. Formula branches, boundary initialization, fixture outputs, validation and the production-isolation guard are tested before a staging release. Source links explain methodology; they do not endorse this site or any trading outcome.
Continue the volatility and risk workflow
Compare chart feeds and stop-order terms
Before transferring an entered volatility line to execution, compare the broker’s symbol history, quote precision, spreads, commissions, stop-level rules and gap policy. An ATR series calculated from one chart feed need not reproduce exactly on another, and a reference price is not a guaranteed fill.
Risk and affiliate disclosure: Leveraged forex and CFD trading can result in substantial losses. These are affiliate links, so ForexMT4Indicators.com may receive compensation if you register or trade through them, at no additional cost to you. Availability and terms vary by jurisdiction and broker entity.

