OPEN-SOURCE SCRIPT
ATR Stop Loss Calibrator - Volatility Exit Ladder

ATR Stop Loss Calibrator - Volatility Exit Ladder is an ATR-based exit-reference overlay designed to compare multiple volatility-scaled price distances from a user-selected reference.
The script does not generate entries, market-direction signals, take-profit targets, position sizes, trade recommendations, or broker orders. The terms "Long" and "Short" only identify whether an ATR distance is drawn below or above the active reference price.
Its primary purpose is to help users study how different ATR multipliers, reference models, ATR update policies, and ratcheting methods affect potential exit-reference levels.
Core calculation
The script first calculates True Range as:
True Range = max(
High - Low,
abs(High - Previous Close),
abs(Low - Previous Close)
)
The selected smoothing method is then applied to True Range to calculate ATR.
The available ATR smoothing methods are:
Wilder RMA
EMA
SMA
WMA
Each ladder level is calculated from the active reference price and the ATR value currently in use:
Long Tier n = Reference - ATR Used x Tier Multiplier n
Short Tier n = Reference + ATR Used x Tier Multiplier n
The default multipliers are:
Tier 1 = 1.0 ATR
Tier 2 = 2.0 ATR
Tier 3 = 3.0 ATR
Users can freely modify all three multipliers.
The script keeps the effective tiers in strictly ascending order. If the entered values are out of sequence, the levels are normalized using a minimum 0.05 ATR separation. The readout reports when this normalization has occurred.
Core tier
One of the three tiers can be selected as the Core reference tier.
The Core tier:
Receives the strongest visual emphasis
Is used for the Long and Short cushion calculations
Is used by the reach-state logic
Is used by the core-level alert conditions
The other two tiers remain visible as secondary reference distances.
This makes it possible to compare a primary exit-distance assumption against tighter and wider alternatives without treating every line as equally important.
Reference models
The script provides six reference models.
1. Confirmed bar step
This is the default model.
It uses the selected source value from the previous completed bar together with the previous completed ATR value.
With the default Close source, the levels are recalculated from the prior bar's confirmed close.
This mode updates once per completed bar and is intended for users who prefer stable, confirmed-bar reference values.
2. Live rolling
This model uses the selected source value and developing ATR value from the current bar.
The levels can therefore move while the realtime bar is open.
This mode is intended for users who deliberately want an intrabar volatility ruler rather than a completed-bar reference.
3. Daily snapshot
This model creates a reference at the beginning of each new daily period.
The reference can use either:
The new period's opening price
The previous chart bar's closing price
4. Weekly snapshot
This model uses the same snapshot process at the beginning of each new weekly period.
5. Monthly snapshot
This model uses the same snapshot process at the beginning of each new monthly period.
6. Manual anchor
This model allows the user to enter an independent reference price and start time.
The anchor begins on the first chart bar whose opening time is at or after the selected timestamp.
This can be used to study ATR distances from a price chosen through the user's own analysis. The script does not decide where the manual reference should be placed.
ATR behavior for locked references
Daily, Weekly, Monthly, and Manual references are locked-reference models.
For these models, the ATR value can operate in one of three ways.
Frozen at anchor
The ATR captured when the reference begins remains fixed until the reference resets.
This creates a stable volatility unit for the entire reference cycle.
Confirmed each bar
The reference price remains locked, while the ATR distance is recalculated from the previous completed bar.
This allows the ladder width to adapt to confirmed changes in volatility without moving the underlying reference price.
Live each bar
The reference price remains locked, while the developing ATR value is used.
The ladder can therefore expand or contract while the realtime bar is open.
Exit-distance behavior
Locked-reference models also provide three level behaviors.
1. Non-ratcheting ladder
Each level remains a direct ATR distance from the locked reference.
The levels may still change if Confirmed each bar or Live each bar is selected as the ATR update policy.
2. Immediate ratchet
The ratchet activates as soon as the reference cycle begins.
For the Long side, the script tracks the highest favorable price reached after the anchor and allows the levels to move upward, but not downward.
For the Short side, the script tracks the lowest favorable price reached after the anchor and allows the levels to move downward, but not upward.
3. Delayed ratchet
The ratchet remains inactive until price has moved favorably by a user-selected number of anchor ATR units.
The activation distance is measured from the locked reference using the ATR captured when the reference cycle began.
After activation, the Long levels can only tighten upward and the Short levels can only tighten downward.
Ratchet update timing
Ratchet calculations can use either:
Confirmed bars
Live extremes
Confirmed bars update the favorable extreme and ratchet levels only after a bar closes.
Live extremes allow the ratchet to respond to the developing high or low of the current realtime bar.
Reach evaluation
The selected Core tier can be evaluated using either Close or Wick logic.
Close mode
A Long Core level is considered reached when the closing price is at or below the level.
A Short Core level is considered reached when the closing price is at or above the level.
Wick mode
A Long Core level is considered reached when the bar's low touches or crosses the level.
A Short Core level is considered reached when the bar's high touches or crosses the level.
Confirmed-bar events are enabled by default.
When confirmed-bar ratcheting is used, the current bar is evaluated against the level that existed before that bar was completed. The script does not tighten a level from the current bar's favorable extreme and then assume that the same bar subsequently reached that newly calculated level.
This avoids making an unsupported assumption about whether the bar's high or low occurred first.
The detailed readout can distinguish between:
Not reached
Wick reached
Close beyond
Visual design
The default chart view uses a compact current-level projection rail near the latest bars.
It does not draw six full-width historical bands across the entire chart by default.
The rail includes:
A dashed reference level
Three optional Long-side ATR levels
Three optional Short-side ATR levels
A solid, visually emphasized Core tier
Dotted or dashed secondary tiers
A compact vertical spine connecting each side's visible levels
The Long side uses cyan by default.
The Short side uses pink by default.
The active reference uses yellow by default.
All colors, line widths, visible tiers, rail length, right extension, tag size, and display options can be modified.
Right-edge tags
The default Core only setting displays no more than three primary tags:
Reference
Long Core
Short Core
An All tiers mode is available for users who want to inspect every individual level.
The tags can also be disabled.
Historical research view
The historical ATR path is disabled by default to preserve candle visibility.
When enabled, it displays the recent history of the reference and selected tiers over a user-defined number of bars.
An optional historical ribbon can be added between the reference and the selected Core tier.
The historical view is intended for research and comparison. The compact current rail remains the default presentation.
Readout
The compact readout summarizes:
Active reference price
ATR value in use
ATR as a percentage of the reference
Selected Core tier and multiplier
Long Core price and remaining cushion in ATR units
Short Core price and remaining cushion in ATR units
Current display status
The detailed layout additionally shows:
Reference model
Locked-reference behavior
Ratchet activation state
Core-level reach state
The panel location and text size can be changed from the settings.
Data Window outputs
The script provides the following research values in TradingView's Data Window:
Active reference
ATR used
ATR as a percentage of the reference
Long Tier 1
Long Tier 2
Long Tier 3
Short Tier 1
Short Tier 2
Short Tier 3
Long Core
Short Core
Long cushion in ATR units
Short cushion in ATR units
These outputs allow users to inspect exact numerical values without adding more text to the chart or indicator status line.
Alerts
The following alert conditions are available:
Long ATR Core reference reached
Short ATR Core reference reached
Any displayed ATR Core reference reached
Long delayed ratchet activated
Short delayed ratchet activated
Locked ATR reference reset
Reach alerts follow the selected Close or Wick test and the Confirmed-bar events setting.
Suggested workflow
1. Select whether to display Both sides, Long only, or Short only.
2. Choose the reference model that matches the intended study.
3. Select the ATR length and smoothing method.
4. Enter three ATR multipliers and choose the primary Core tier.
5. For Daily, Weekly, Monthly, or Manual references, select the ATR update policy and optional ratchet behavior.
6. Select Close or Wick reach evaluation.
7. Keep Confirmed-bar events enabled when stable completed-bar alerts are preferred.
8. Use the compact current rail for normal chart viewing.
9. Enable the historical path only when reviewing how the levels behaved across recent bars.
Example research configurations
Confirmed bar step can be used to compare current price with ATR distances calculated from the prior completed bar.
Daily snapshot with Frozen at anchor can be used to maintain one fixed volatility unit from the daily period open or previous close.
Manual anchor with Delayed ratchet can be used to study how an independently selected reference would behave after a favorable ATR-based excursion.
These are research configurations, not trade recommendations.
Default configuration
The default configuration uses:
Both Long and Short sides
Confirmed bar step
Close as the rolling reference source
ATR length 14
Wilder RMA smoothing
1.0, 2.0, and 3.0 ATR tiers
Tier 2 as the Core tier
Non-ratcheting behavior
Close-based reach evaluation
Confirmed-bar events
Current projection rail enabled
Historical path disabled
Reach markers disabled
Core-only right-edge tags
Compact readout
Calculation behavior
The default Confirmed bar step model uses completed-bar source and ATR values.
The default confirmed event setting also waits for the bar to close before generating a reach event.
Live rolling, Live each bar, Live extremes, or disabling confirmed-bar events intentionally allows values or event states to change while the realtime bar is developing.
The lines projected to the right side of the latest bar are visual extensions only. They do not access future prices or future chart data.
Limitations
ATR is a backward-looking measurement of historical price range. It does not predict future volatility, market direction, reversal probability, or execution quality.
The displayed levels are analytical references. They are not stop orders and are not transmitted to a broker.
Actual order execution may differ from a displayed level because of gaps, spread, slippage, liquidity, market closures, broker rules, or instrument-specific contract conditions.
Results depend on the chart symbol, timeframe, available price history, exchange calendar, and data feed.
Synthetic chart types can produce levels from synthetic OHLC values rather than directly traded prices. Standard price charts are preferable when the levels are being compared with executable market prices.
A narrower ATR multiple is not automatically better, and a wider multiple is not automatically safer. Appropriate distances depend on the user's method, holding period, instrument, risk limits, and execution environment.
"Calibrator" refers to the visual comparison of user-selected ATR distances. The script does not optimize settings, score multipliers, or identify a best parameter.
This indicator is provided for analytical and educational use. It does not constitute investment, financial, or trading advice. All analysis, risk decisions, and order placement remain the user's responsibility.
The script does not generate entries, market-direction signals, take-profit targets, position sizes, trade recommendations, or broker orders. The terms "Long" and "Short" only identify whether an ATR distance is drawn below or above the active reference price.
Its primary purpose is to help users study how different ATR multipliers, reference models, ATR update policies, and ratcheting methods affect potential exit-reference levels.
Core calculation
The script first calculates True Range as:
True Range = max(
High - Low,
abs(High - Previous Close),
abs(Low - Previous Close)
)
The selected smoothing method is then applied to True Range to calculate ATR.
The available ATR smoothing methods are:
Wilder RMA
EMA
SMA
WMA
Each ladder level is calculated from the active reference price and the ATR value currently in use:
Long Tier n = Reference - ATR Used x Tier Multiplier n
Short Tier n = Reference + ATR Used x Tier Multiplier n
The default multipliers are:
Tier 1 = 1.0 ATR
Tier 2 = 2.0 ATR
Tier 3 = 3.0 ATR
Users can freely modify all three multipliers.
The script keeps the effective tiers in strictly ascending order. If the entered values are out of sequence, the levels are normalized using a minimum 0.05 ATR separation. The readout reports when this normalization has occurred.
Core tier
One of the three tiers can be selected as the Core reference tier.
The Core tier:
Receives the strongest visual emphasis
Is used for the Long and Short cushion calculations
Is used by the reach-state logic
Is used by the core-level alert conditions
The other two tiers remain visible as secondary reference distances.
This makes it possible to compare a primary exit-distance assumption against tighter and wider alternatives without treating every line as equally important.
Reference models
The script provides six reference models.
1. Confirmed bar step
This is the default model.
It uses the selected source value from the previous completed bar together with the previous completed ATR value.
With the default Close source, the levels are recalculated from the prior bar's confirmed close.
This mode updates once per completed bar and is intended for users who prefer stable, confirmed-bar reference values.
2. Live rolling
This model uses the selected source value and developing ATR value from the current bar.
The levels can therefore move while the realtime bar is open.
This mode is intended for users who deliberately want an intrabar volatility ruler rather than a completed-bar reference.
3. Daily snapshot
This model creates a reference at the beginning of each new daily period.
The reference can use either:
The new period's opening price
The previous chart bar's closing price
4. Weekly snapshot
This model uses the same snapshot process at the beginning of each new weekly period.
5. Monthly snapshot
This model uses the same snapshot process at the beginning of each new monthly period.
6. Manual anchor
This model allows the user to enter an independent reference price and start time.
The anchor begins on the first chart bar whose opening time is at or after the selected timestamp.
This can be used to study ATR distances from a price chosen through the user's own analysis. The script does not decide where the manual reference should be placed.
ATR behavior for locked references
Daily, Weekly, Monthly, and Manual references are locked-reference models.
For these models, the ATR value can operate in one of three ways.
Frozen at anchor
The ATR captured when the reference begins remains fixed until the reference resets.
This creates a stable volatility unit for the entire reference cycle.
Confirmed each bar
The reference price remains locked, while the ATR distance is recalculated from the previous completed bar.
This allows the ladder width to adapt to confirmed changes in volatility without moving the underlying reference price.
Live each bar
The reference price remains locked, while the developing ATR value is used.
The ladder can therefore expand or contract while the realtime bar is open.
Exit-distance behavior
Locked-reference models also provide three level behaviors.
1. Non-ratcheting ladder
Each level remains a direct ATR distance from the locked reference.
The levels may still change if Confirmed each bar or Live each bar is selected as the ATR update policy.
2. Immediate ratchet
The ratchet activates as soon as the reference cycle begins.
For the Long side, the script tracks the highest favorable price reached after the anchor and allows the levels to move upward, but not downward.
For the Short side, the script tracks the lowest favorable price reached after the anchor and allows the levels to move downward, but not upward.
3. Delayed ratchet
The ratchet remains inactive until price has moved favorably by a user-selected number of anchor ATR units.
The activation distance is measured from the locked reference using the ATR captured when the reference cycle began.
After activation, the Long levels can only tighten upward and the Short levels can only tighten downward.
Ratchet update timing
Ratchet calculations can use either:
Confirmed bars
Live extremes
Confirmed bars update the favorable extreme and ratchet levels only after a bar closes.
Live extremes allow the ratchet to respond to the developing high or low of the current realtime bar.
Reach evaluation
The selected Core tier can be evaluated using either Close or Wick logic.
Close mode
A Long Core level is considered reached when the closing price is at or below the level.
A Short Core level is considered reached when the closing price is at or above the level.
Wick mode
A Long Core level is considered reached when the bar's low touches or crosses the level.
A Short Core level is considered reached when the bar's high touches or crosses the level.
Confirmed-bar events are enabled by default.
When confirmed-bar ratcheting is used, the current bar is evaluated against the level that existed before that bar was completed. The script does not tighten a level from the current bar's favorable extreme and then assume that the same bar subsequently reached that newly calculated level.
This avoids making an unsupported assumption about whether the bar's high or low occurred first.
The detailed readout can distinguish between:
Not reached
Wick reached
Close beyond
Visual design
The default chart view uses a compact current-level projection rail near the latest bars.
It does not draw six full-width historical bands across the entire chart by default.
The rail includes:
A dashed reference level
Three optional Long-side ATR levels
Three optional Short-side ATR levels
A solid, visually emphasized Core tier
Dotted or dashed secondary tiers
A compact vertical spine connecting each side's visible levels
The Long side uses cyan by default.
The Short side uses pink by default.
The active reference uses yellow by default.
All colors, line widths, visible tiers, rail length, right extension, tag size, and display options can be modified.
Right-edge tags
The default Core only setting displays no more than three primary tags:
Reference
Long Core
Short Core
An All tiers mode is available for users who want to inspect every individual level.
The tags can also be disabled.
Historical research view
The historical ATR path is disabled by default to preserve candle visibility.
When enabled, it displays the recent history of the reference and selected tiers over a user-defined number of bars.
An optional historical ribbon can be added between the reference and the selected Core tier.
The historical view is intended for research and comparison. The compact current rail remains the default presentation.
Readout
The compact readout summarizes:
Active reference price
ATR value in use
ATR as a percentage of the reference
Selected Core tier and multiplier
Long Core price and remaining cushion in ATR units
Short Core price and remaining cushion in ATR units
Current display status
The detailed layout additionally shows:
Reference model
Locked-reference behavior
Ratchet activation state
Core-level reach state
The panel location and text size can be changed from the settings.
Data Window outputs
The script provides the following research values in TradingView's Data Window:
Active reference
ATR used
ATR as a percentage of the reference
Long Tier 1
Long Tier 2
Long Tier 3
Short Tier 1
Short Tier 2
Short Tier 3
Long Core
Short Core
Long cushion in ATR units
Short cushion in ATR units
These outputs allow users to inspect exact numerical values without adding more text to the chart or indicator status line.
Alerts
The following alert conditions are available:
Long ATR Core reference reached
Short ATR Core reference reached
Any displayed ATR Core reference reached
Long delayed ratchet activated
Short delayed ratchet activated
Locked ATR reference reset
Reach alerts follow the selected Close or Wick test and the Confirmed-bar events setting.
Suggested workflow
1. Select whether to display Both sides, Long only, or Short only.
2. Choose the reference model that matches the intended study.
3. Select the ATR length and smoothing method.
4. Enter three ATR multipliers and choose the primary Core tier.
5. For Daily, Weekly, Monthly, or Manual references, select the ATR update policy and optional ratchet behavior.
6. Select Close or Wick reach evaluation.
7. Keep Confirmed-bar events enabled when stable completed-bar alerts are preferred.
8. Use the compact current rail for normal chart viewing.
9. Enable the historical path only when reviewing how the levels behaved across recent bars.
Example research configurations
Confirmed bar step can be used to compare current price with ATR distances calculated from the prior completed bar.
Daily snapshot with Frozen at anchor can be used to maintain one fixed volatility unit from the daily period open or previous close.
Manual anchor with Delayed ratchet can be used to study how an independently selected reference would behave after a favorable ATR-based excursion.
These are research configurations, not trade recommendations.
Default configuration
The default configuration uses:
Both Long and Short sides
Confirmed bar step
Close as the rolling reference source
ATR length 14
Wilder RMA smoothing
1.0, 2.0, and 3.0 ATR tiers
Tier 2 as the Core tier
Non-ratcheting behavior
Close-based reach evaluation
Confirmed-bar events
Current projection rail enabled
Historical path disabled
Reach markers disabled
Core-only right-edge tags
Compact readout
Calculation behavior
The default Confirmed bar step model uses completed-bar source and ATR values.
The default confirmed event setting also waits for the bar to close before generating a reach event.
Live rolling, Live each bar, Live extremes, or disabling confirmed-bar events intentionally allows values or event states to change while the realtime bar is developing.
The lines projected to the right side of the latest bar are visual extensions only. They do not access future prices or future chart data.
Limitations
ATR is a backward-looking measurement of historical price range. It does not predict future volatility, market direction, reversal probability, or execution quality.
The displayed levels are analytical references. They are not stop orders and are not transmitted to a broker.
Actual order execution may differ from a displayed level because of gaps, spread, slippage, liquidity, market closures, broker rules, or instrument-specific contract conditions.
Results depend on the chart symbol, timeframe, available price history, exchange calendar, and data feed.
Synthetic chart types can produce levels from synthetic OHLC values rather than directly traded prices. Standard price charts are preferable when the levels are being compared with executable market prices.
A narrower ATR multiple is not automatically better, and a wider multiple is not automatically safer. Appropriate distances depend on the user's method, holding period, instrument, risk limits, and execution environment.
"Calibrator" refers to the visual comparison of user-selected ATR distances. The script does not optimize settings, score multipliers, or identify a best parameter.
This indicator is provided for analytical and educational use. It does not constitute investment, financial, or trading advice. All analysis, risk decisions, and order placement remain the user's responsibility.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.