Indicator · Pine Script v4 · On the chart

Chad's Average True Range ATR (@tradeprophet)

by TPCharts

This indicator projects daily Average True Range (ATR) support and resistance levels onto the main price chart based on the daily open price.

View on GitHub

Repaints

GitHub stars10on the repository
Pine versionv4older, still runs
Lines of code67
Settings6inputs
LicenceGPL-3.0
Last update5 years ago1 Dec 2020

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

67 lines of Pine Script v4 from Chad's ATR.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

Chad's ATR.pine
//@version=4
study("Chad'\s Average True Range [ATR] (@tradeprophet)","Chad\'s ATR (@tradeprophet)", true)

ds(str) => label.new(bar_index, high, str)
dsl(str) =>
    if barstate.islast
        ds(str)
d(val) => ds(tostring(val))
dl(val) => dsl(tostring(val))


period = input(20, "Period")
isOuterPlotShown = input(false, "Show Outer Plot?")
isOuterBandLinesShown = input(true, "Show Outer Band Lines?")
isATRLinesShown = input(true, "Show ATR Lines?")
outerMultiplier = input(2, "Outer Multiplier")

dailyOpen = security(syminfo.tickerid, "D", open)

atrPeriod = input(20, minval=1, title='ATR Period')
atrActual = security(syminfo.tickerid, "D", atr(atrPeriod))
outerSpread = atrActual * outerMultiplier

upperATRPrice = dailyOpen + atrActual
lowerATRPrice = dailyOpen - atrActual


// ATR Lines & Labels
upperATRLine = line.new(x1=bar_index-1, y1=upperATRPrice, x2=bar_index, y2=upperATRPrice, extend=extend.right, color=color.black)
line.delete(upperATRLine[1])

upperATRLabel = label.new(bar_index, upperATRPrice, text="D ATR", style=label.style_none)
label.delete(upperATRLabel[1])

lowerATRLine = line.new(x1=bar_index-1, y1=lowerATRPrice, x2=bar_index, y2=lowerATRPrice, extend=extend.right, color=color.black)
line.delete(lowerATRLine[1])

lowerATRLabel = label.new(bar_index, lowerATRPrice, text="D ATR", style=label.style_none)
label.delete(lowerATRLabel[1])

//
// Outer ATR Lines & Labels
//

// Upper
upperATRBandPrice = upperATRPrice + outerSpread
// upperATRBandPlot = plot(upperATRBandPrice, color=color.gray, linewidth=2, transp=100)
// upperATRPlot = plot(upperATRPrice, color=color.gray, linewidth=2, transp=100)
// fill(upperATRBandPlot, upperATRPlot, color.black)

upperATRBandLine = line.new(x1=bar_index-1, y1=upperATRBandPrice, x2=bar_index, y2=upperATRBandPrice, extend=extend.right, color=color.black)
line.delete(upperATRBandLine[1])

upperATRBandLabel = label.new(bar_index, upperATRBandPrice, text="D ATR BAND", style=label.style_none)
label.delete(upperATRBandLabel[1])

// Lower
lowerATRBandPrice = lowerATRPrice - outerSpread
// lowerATRBandPlot = plot(lowerATRBandPrice, color=color.gray, linewidth=2, transp=100)
// lowerATRPlot = plot(lowerATRPrice, color=color.gray, linewidth=2, transp=100)
// fill(lowerATRBandPlot, lowerATRPlot, color.black)

lowerATRBandLine = line.new(x1=bar_index-1, y1=lowerATRBandPrice, x2=bar_index, y2=lowerATRBandPrice, extend=extend.right, color=color.black)
line.delete(lowerATRBandLine[1])

lowerATRBandLabel = label.new(bar_index, lowerATRBandPrice, text="D ATR BAND", style=label.style_none)
label.delete(lowerATRBandLabel[1])

Overview

Chad's Average True Range ATR (@tradeprophet) calculates upper and lower ATR levels along with outer ATR band lines using a configurable multiplier. Dynamic horizontal lines and labels are rendered directly on the chart to identify key daily volatility bounds. Users can adjust the ATR length, outer multiplier, and toggle line displays. Note that the script uses daily security calls in Pine Script v4 without disabling lookahead, which introduces lookahead bias on historical bars.

Details

Published by

TPCharts on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Volatility & bands, Support & resistance

Markets

Any symbol

Timeframes

M15-H1

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Periodint20period
Show Outer Plot?boolfalseisOuterPlotShown
Show Outer Band Lines?booltrueisOuterBandLinesShown
Show ATR Lines?booltrueisATRLinesShown
Outer Multiplierint2outerMultiplier
ATR Periodint20atrPeriod
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

ICT Liquidity Void Fill

by ArunKBhaskar
575 stars

This overlay indicator marks ICT liquidity void fills on the price chart and can show long and short signals. It places a Fibonacci level inside a displacement candle, defaulting to the midpoint, and draws lines in a chosen style. Optional filters limit the fi

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Void Fill

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

Snag - VWAP

by dearvn
257 stars

This indicator plots a custom Anchored Volume-Weighted Average Price (VWAP) directly on the price chart along with optional standard deviation bands. Users can anchor the VWAP to standard time periods like sessions, weeks, or months, or to corporate events suc

Indicator v5 Moving averagesVolatility & bands Repaints
Updated 6 weeks ago · None stated GitHub repository of Snag - VWAP

Candlestick Patterns

by harryguiacorn
219 stars

This indicator plots optional candlestick pattern signals on the price chart. It detects engulfing bars, inside bars, HOLP and LOHP, kicker patterns, body-mass extremes, higher highs and lower lows, ATR warnings, and four-bar fractals. Optional pivot marks use

Indicator v5 Candlestick patternsVolatility & bands
Updated 1 year ago · None stated GitHub repository of Candlestick Patterns

Dynamic Linear Regression

by TradersPost
218 stars

Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin

Indicator v6 TrendSupport & resistance
Updated 3 months ago · None stated GitHub repository of Dynamic Linear Regression

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers