Close-centered envelope · Length 3 · Factor 2.5
ATR Bands: the current close stays inside its own bands
This implementation plots close plus and minus a multiple of ATR. With a positive distance, a same-bar close cannot break either band because both bands move with that close. Before designing a signal, identify whether it uses a wick, the previous bar's band or a level frozen at entry.
Two lines centered on close
Upper = close + Distance
Lower = close − Distance
Midpoint = (Upper + Lower)/2 = close
Width = Upper − Lower = 2 × factor × ATR
Pineify's helper uses TradingView's RMA-based ATR. TradingView's ATR documentation explains true range and Wilder's original volatility measure. The close-centered envelope is the specific implementation documented here; other scripts called ATR Bands may use different anchors.
For a synthetic close of 180, ATR of 3 and factor 2.5, the upper line is 187.5, the lower is 172.5 and width is 15. The midpoint is 180 even though the script does not draw a middle line. These levels are arithmetic offsets, not observed support or resistance.
With the same ATR, changing the factor to 2 narrows each distance from 7.5 to 6, a 20% reduction. Changing it to 3.5 increases the distance to 10.5, a 40% increase. Neither calculation determines how frequently a wick will touch or whether a strategy wins.
The anchor has no moving-average smoothing, but ATR does. Length 3 is a recursive smoothing parameter, not a three-bar cutoff. Current high, low and close can all change before the bar finishes.
Three comparisons that must not be mixed
| Comparison | Can occur? | Information available |
|---|---|---|
| Current close above its current upper band | No, when factor × ATR is positive. | The upper band is that close plus a positive amount. |
| Current high at or above the final current upper band | Yes, a sufficiently large upper wick can reach it. | The final close and ATR are not known until the bar closes. |
| Current close above the previous completed upper band | Yes. This uses a prior-bar reference. | The reference was available before the current bar; the current closing condition is confirmed later. |
A prior-bar break without a current-band break
Suppose the previous completed close is 100 and ATR(3) is 2. Its bands with factor 2.5 are 105 and 95. The next bar has high 107, low 99 and close 106. Its true range is 8, so the updated ATR is (2 × 2 + 8)/3 = 4. The new bands are 116 and 96.
The close 106 exceeds the previous upper band 105 but is below its own upper band 116. A rule using the previous band is a separate experiment; replacing one comparison with the other changes the strategy rather than merely confirming it.
A same-bar wick can touch
In a separate synthetic case, the previous close is 100 and ATR(3) is 1. A bar with high 112, low 100 and close 100 has TR 12 and new ATR 14/3. Its final upper band is 100 + 2.5 × 14/3 ≈ 111.6667, so high 112 reaches it. Close 100 still lies strictly inside. This final historical comparison does not show the band's intrabar path or an executable order price.
For live alerts, specify the comparison and whether the whole event waits for bar close. TradingView's repainting documentation explains the difference between fluid realtime values and completed historical bars. An indicator display alone does not establish an intrabar fill sequence.
Pine Script implementation and its exact scope
The retained source matches Pineify's close-based helper. It fixes length 3 and factor 2.5 and plots green and red lines at width 2 with 50 transparency. There is no fill, midpoint plot, input menu, signal marker, alert condition or strategy order.
//@version=6
indicator(title="Average True Range Band", overlay=true, max_labels_count=500)
// ATR Bands — volatility bands around the close price using ATR
p_ta_atr_band(simple int length, simple float factor) =>
atr = ta.atr(length)
scaled_atr = atr * factor
upper = close + scaled_atr
lower = close - scaled_atr
[upper, lower]
[p_ind_1_upper, p_ind_1_lower] = p_ta_atr_band(3, 2.5)
plot(p_ind_1_upper, "ATR Band - Upper", color.rgb(0, 255, 0, 50), 2)
plot(p_ind_1_lower, "ATR Band - Lower", color.rgb(255, 0, 0, 50), 2)Open TradingView's Pine Editor using the Pine icon on the right toolbar, paste the source and select Add to chart. Check the displayed close and ATR on completed bars, then calculate both bands manually. Compare the same symbol, session, chart type and history when checking another implementation.

The function does not validate modified arguments. A useful adaptation should require a positive length and specify whether a zero factor is allowed. A zero factor or zero ATR collapses both bands to close; a negative factor reverses the named upper and lower levels. Unavailable ATR means unavailable bands.
A lower band is not automatically a trailing stop
For fixed factor k, the lower-band change is Δclose − k × ΔATR. It can decline even when close rises. Take close 100, ATR 2, k 2.5: lower is 95. If close next becomes 101 and ATR becomes 3, lower falls to 93.5.
To keep a long stop from moving downward, store an active stop and only replace it with a higher eligible candidate. Reset that state at each new trade and specify whether the update is active on the next bar or during the current bar. A level frozen at entry is an initial stop; a continuously recalculated lower band is a different rule.
The current upper band is above current close when the distance is positive. Moving a protective sell stop for a long position to that upper band is not simply a tighter below-market stop. Order type, trigger rules and execution timing must be checked separately.
If an entry occurs after a signal close, its fill can differ from the band's anchor. A band distance therefore is not necessarily the entry-to-stop distance. Stops also do not guarantee their trigger price as the fill price; see the SEC stop-order bulletin.
Compare anchors before comparing band signals
This envelope is centered on current close. Bollinger Bands commonly use a moving-average basis and a standard-deviation distance; Keltner-style channels use a moving-average basis with a range-based distance. Their exact averaging choices vary by implementation. A close can exceed a moving-average-centered upper band while it cannot exceed this same-close upper band with a positive distance.
All these plotted band levels have price units. Standard-deviation bands are not automatically percentages, and two standard deviations do not establish 95% market coverage or trade success. Compare a specified sample rather than translating a distribution rule into an assumed signal accuracy.
The width of these bands, 2 × factor × ATR, depends only on ATR when factor is fixed. Individual lines depend on both close and ATR. Both lines can rise while the width narrows, so inspect width rather than treating the upper line's direction alone as volatility expansion.
ATR Band questions
Specify the reference bar in a coding request
Ask Pineify to preserve the close ± ATR formula and expose length and factor inputs. For a custom signal, say whether it compares the current high with the final current band or the completed close with the previous band. Request stop orders separately. Review the code, compile it and test timing and costs; account access and usage depend on the current plan.
Explore the coding agent