What the strategy is trying to do
This is an open-source script by Bcullen175. The script title is “ATR Mean Reversion”; the publication page calls it “ATR Mean Reversion Strategy V1.” It treats open plus or minus ATR as a short-term channel and plots an EMA as the mean. The idea is simple: wait for the low to poke through the lower band, then look for a return toward the average, or get stopped out first. The author's chart is BINANCE:BTCUSDT on the 5-minute timeframe, so this entry is filed under BTC. The script does not hard-code a symbol and will load on other charts, but the guide and the image follow that publication chart.
It opens longs only; there is no short branch. The strategy declaration sets initial_capital at 100000, sizes each entry at 100% of equity, and uses a 0.006% commission, which a comment attributes to IC Markets. Both the size and the fee are aggressive relative to typical bitcoin venues, so change them before you read the tester.

How the indicators are calculated
- ATR and the moving average share one period, default 10. ATR is ta.atr(period). The average is an EMA of Source, and Source defaults to the close.
- The plotted upper band is open + ATR and the lower band is open − ATR, not close plus or minus ATR. The white midline is the EMA.
- A date filter uses i_startTime (default 1995-01-01 13:30 UTC) and i_endTime (default 2099-01-01 19:30 UTC). Entries are considered only when the bar time falls inside that window. With the defaults, the filter is effectively always on.
- While a long is open, stopPrice is buyPrice − SLx × ATR. SLx defaults to 1.5. The source also computes stopDistance, but that value is not used in any order condition.
- buyPrice is stored with var. On the bar after a buy signal, if the previous bar met buyCondition, buyPrice is set to that later bar's open. It is not the fill's average price, and it is not the open of the signal bar itself.
Entry rules
- Long (order name Long): the low is below open − ATR, there is no open position, and the date filter passes.
- There is no short entry.
- The source does not wait for barstate.isconfirmed. On a 5-minute chart, whether the low has broken the lower band can still change before the bar ends; whether a fill stands depends on your TradingView order settings.
Exits and position size
- Stop exit: a long is open and the low trades below stopPrice (buyPrice minus 1.5 × ATR, with the multiple adjustable).
- sellCondition has two branches, and either one is enough: a long is open, the high is above the EMA, and the close is below the prior low; or the high is above open + ATR. The second branch does not restate that a position must be open, but strategy.close does nothing if there is no trade.
- If the stop or sellCondition fires, the script calls strategy.close("Long") and clears buyPrice.
- A bar that both undercuts the lower band and clears the upper band can satisfy the entry and the second exit on the same bar. What fills then depends on the tester's order processing.
- Because buyPrice is assigned only on the bar after the signal, stopPrice on the entry bar still uses the previous value. That starts at 0, so the stop is a small negative number and will not be hit on that bar. The stop measured from the next open only applies from the following bar.
- Each entry is 100% of equity. What that notional is worth changes with the symbol and equity, so treat the size as your own risk setting.
Inputs (source defaults)
| Input | Default | Role |
|---|---|---|
| SL Multiplier | 1.5 | The stop is buyPrice minus this multiple times ATR. The author cautions against setting it too low; choose your own value. |
| Source | close | Price source for the EMA. |
| ATR & MA PERIOD | 10 | Shared length for ATR and the EMA. |
| Start Filter / End Filter | 1995-01-01 to 2099-01-01 | Entries are only considered inside this window. |
Things to know before using it
- The default size is 100% of equity, and commission is only 0.006%. Live bitcoin fees and slippage are usually higher, so tester results are not a live forecast.
- The stop is anchored to the next bar's open, not to the strategy's average fill. If the fill on the signal bar is far from that later open, the stop distance will not match what you expected.
- The channel is open plus or minus ATR. Changing Source only moves the EMA; it does not change the entry band.
- There is no short side and no separate take-profit order. The branch that waits for a return toward the average also needs the close to fall through the prior low.
- The script plots the channel, the EMA, buyPrice, and stopPrice. That is display only. Some tooltip text is misspelled; that does not change the logic as written.
Installing it on TradingView
- Download the .pine file from Coinpred (active membership required, see below), or check the original page for a newer version.
- Open the Pine Editor, create a blank script, paste the full source, and save.
- Click Add to chart. To match the author image, start with BINANCE:BTCUSDT on the 5-minute timeframe.
- Review the position size, commission, ATR length, and stop multiple in the strategy properties, then inspect fills in the Strategy Tester.
- Past tester results do not guarantee future returns.
About backtest figures
Source, license and version
- Source: https://www.tradingview.com/script/O4t4zTd3-ATR-Mean-Reversion-Strategy-V1/
- Author: Bcullen175. Source version 1.0 (Pine v5), scriptAccess=open_no_auth.
- License: Mozilla Public License 2.0. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified full source.
- Members can download the .pine file on this page to study the rules. Judge the risk yourself, and follow your venue's rules.



