OPEN-SOURCE SCRIPT
ATR & Bar Range Stop Dashboard

# Title
**ATR & Bar Range Stop Dashboard**
## About this script
**ATR & Bar Range Stop Dashboard** is a volatility-based trade-planning tool designed to provide a quick estimate of reasonable stop-loss distance based on the current market's recent price movement.
Rather than using an arbitrary fixed stop distance, the indicator measures recent volatility using either:
* **Average True Range (ATR)**, or
* **Average Bar Range (High − Low)**
and calculates hypothetical long and short stop prices around the current market price or an optional manually entered reference price.
The purpose of the indicator is not to generate entries or trading signals. It is intended to provide a **volatility reference for stop placement and trade planning**.
A structural stop should still be based on the price level at which the trade thesis becomes invalid. This tool can then be used to evaluate whether that structural stop is unusually tight or wide relative to recent market volatility.
---
## How it works
The script calculates two measures of recent price movement:
**Average Bar Range**
This is the simple average of each candle's:
`High - Low`
over the selected lookback period.
The default lookback is **20 completed bars**.
**Average True Range**
ATR measures True Range over the selected ATR lookback period.
The default is:
`ATR(14)`
The script uses **completed bars for the volatility calculations** so the baseline is not continually distorted by the currently developing candle.
The user can select either **ATR** or **Bar Range** as the basis for the calculated Average Stop.
The basic stop distance is:
`Average Stop = Selected Volatility Measure × Stop Multiplier`
The default multiplier is **1.0x**.
---
## Stop calculations
The dashboard calculates hypothetical stops on both sides of the reference price.
**Long Stop**
`Reference Price - Average Stop - Buffer`
**Short Stop**
`Reference Price + Average Stop + Buffer`
Final stop prices are rounded to the symbol's valid minimum tick increment.
The calculated stops are intended as **volatility-based reference levels**, not automatic recommendations to place an order at those exact prices.
---
## Adaptive buffer
An additional buffer places the calculated stop slightly outside the raw volatility boundary.
### Futures
In Auto mode, the futures buffer is:
`max(2 ticks, 10% of Average Stop)`
with an adjustable maximum buffer percentage.
The default maximum is **25% of Average Stop**.
This provides a small minimum buffer in lower-volatility conditions while allowing the buffer to expand as volatility increases.
### Stocks and ETFs
The default Auto buffer is:
`10% of Average Stop`
subject to the same adjustable maximum buffer percentage.
### Manual buffer
Users can disable Auto mode and specify the buffer directly in **number of ticks**.
---
## Timeframe behavior
By default, all volatility calculations use the **current chart timeframe**.
For example:
* 2-minute chart → 2-minute volatility
* 5-minute chart → 5-minute volatility
* 15-minute chart → 15-minute volatility
* Daily chart → daily volatility
A **Manual Timeframe Override** is also available when the trader wants the dashboard to reference volatility from a different timeframe.
For example, a trader executing on a 2-minute chart may choose to calculate the stop using 5-minute volatility.
---
## Reference price
By default, the script calculates the hypothetical stop levels from the **current market price**.
An optional **Manual Entry Price** can be enabled.
This is useful after entering a trade or when planning an entry at a specific price because the stop calculations remain anchored to that reference price rather than moving continuously with the market.
The dashboard still displays the live Current Price separately.
---
## Dashboard modes
### Minimal
Designed for active trading and displays only:
* Current Price
* Average Stop and its basis
* Long Stop
* Short Stop
The **Long Stop is displayed in green** and the **Short Stop in red** for quick identification.
### Full
Displays additional volatility information:
* Average Bar Range
* ATR
* Current Bar Range
* Current Bar / Average Bar ratio
* Current Price
* Average Stop and calculation basis
* Buffer
* Long Stop
* Short Stop
---
## Display options
The dashboard can be customized using:
**Table Size**
* Tiny
* Small
* Normal
* Large
* Huge
**Horizontal Placement**
* Left
* Center
* Right
**Vertical Placement**
* Top
* Middle
* Bottom
These controls provide all nine standard TradingView table-placement combinations.
---
## Suggested interpretation
The indicator is most useful as a **context tool rather than a mechanical stop system**.
For example, if a proposed structural stop is only 0.3 ATR away from the entry while normal bars are already considerably larger than that distance, the stop may be vulnerable to ordinary market noise.
Conversely, a structural stop several ATRs away may indicate that the trade requires unusually large risk relative to current volatility.
The indicator does not determine whether the underlying trade setup is valid.
A practical workflow is:
1. Identify the trade setup.
2. Determine the price level that structurally invalidates the setup.
3. Compare that distance with the dashboard's volatility-based Average Stop.
4. Determine whether the structural stop allows acceptable risk.
5. Adjust position size rather than artificially tightening a structurally necessary stop.
---
## Default settings
**Volatility**
* Average Bar Range Length: `20`
* ATR Length: `14`
**Stop**
* Stop Basis: `ATR`
* Stop Multiplier: `1.0x`
**Buffer**
* Mode: `Auto`
* Auto Buffer: `10%`
* Futures Minimum Buffer: `2 ticks`
* Maximum Auto Buffer: `25%`
**Timeframe**
* Current chart timeframe
**Display**
* Minimal
* Small
* Top Right
All parameters are configurable.
---
## Important notes
This indicator:
* Does **not** generate buy or sell signals.
* Does **not** determine market direction.
* Does **not** automatically identify structural invalidation.
* Does **not** determine position size.
* Does **not** guarantee that a calculated stop will avoid being triggered.
* Is intended as a volatility and trade-planning tool.
ATR and average bar range describe **recent historical volatility**. Future volatility can change rapidly, particularly around economic releases, earnings, market opens, news events, or periods of reduced liquidity.
Traders should use the calculated levels together with market structure, risk management, and their own trading methodology.
---
# Release notes — Version 1.0
**Initial release**
* Added ATR-based stop-distance calculation.
* Added Average Bar Range alternative to ATR.
* Added configurable stop multiplier.
* Uses completed bars for baseline volatility calculations.
* Added automatic chart-timeframe detection.
* Added optional manual timeframe override.
* Added live Current Price display.
* Added optional Manual Entry Price for fixed stop calculations.
* Added automatic futures and equity buffer logic.
* Futures Auto Buffer defaults to the greater of 2 ticks or 10% of Average Stop.
* Stocks and ETFs default to a 10% Average Stop buffer.
* Added adjustable maximum Auto Buffer.
* Added manual tick-based buffer override.
* Added Long and Short stop price calculations rounded to valid minimum tick increments.
* Added Minimal and Full dashboard modes.
* Average Stop clearly identifies whether ATR or Bar Range is being used.
* Added configurable table size.
* Added Left / Center / Right and Top / Middle / Bottom table positioning.
* Added green Long Stop and red Short Stop highlighting.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.