Indicator · Pine Script v6 · On the chart

ATR Levels

by trugurpala

This indicator calculates the Average True Range and a Simple Moving Average of closing prices.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code29
Settings4inputs
LicenceMIT
Last update2 months ago3 Aug 2026

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

29 lines of Pine Script v6 from examples/indicators/07_atr_levels.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

07_atr_levels.pine
//@version=6
// ATR Dynamic Support/Resistance Levels — github.com/trugurpala/pinescriptv6
// Author: Ugur Pala · mail@ugurpala.com
indicator("ATR Levels [trugurpala]", overlay=true)

// ── Inputs ───────────────────────────────────────────────────────────────────
int   atrLen = input.int(14, "ATR Length", minval=1)
float mult1  = input.float(1.0, "Level 1", step=0.1)
float mult2  = input.float(2.0, "Level 2", step=0.1)
float mult3  = input.float(3.0, "Level 3", step=0.1)

// ── Calculations ─────────────────────────────────────────────────────────────
float atrVal = ta.atr(atrLen)
float basis  = ta.sma(close, atrLen)

// ── Visuals ──────────────────────────────────────────────────────────────────
plot(basis,               "Basis", color.orange, linewidth=2)
plot(basis + mult1*atrVal,"R1",    color.new(color.red,   50))
plot(basis + mult2*atrVal,"R2",    color.new(color.red,   30))
plot(basis + mult3*atrVal,"R3",    color.red,             linewidth=2)
plot(basis - mult1*atrVal,"S1",    color.new(color.green, 50))
plot(basis - mult2*atrVal,"S2",    color.new(color.green, 30))
plot(basis - mult3*atrVal,"S3",    color.green,           linewidth=2)

if barstate.islast
    label.new(bar_index + 2, basis + mult3*atrVal,
        "ATR: " + str.tostring(math.round(atrVal, 2)),
        style=label.style_label_left,
        color=color.new(color.gray, 70), textcolor=color.white)

Overview

ATR Levels plots a central basis line along with dynamic support and resistance levels derived from multiples of the ATR. The main settings control the ATR length and the multipliers for the three resistance and three support levels. It draws all plots directly on the price chart. The levels update in real time as new price bars form. There are no entry or exit rules since this is not a strategy. It has no stop loss or position sizing.

Details

Published by

trugurpala on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance, Volatility & bands, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

aialgorithmic-tradingclaude-codecodexcoding-agentsgithub-copilotopen-sourcepine-scriptpine-script-v6technical-analysis

Settings

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

SettingTypeDefaultVariable
ATR Lengthint14atrLen
Level 1float1.0mult1
Level 2float2.0mult2
Level 3float3.0mult3
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

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

MA Envelope (MAE)

by mihakralj
99 stars

The MA Envelope indicator calculates upper and lower channel bands shifted by a user-defined percentage around a baseline moving average. It supports Simple Moving Average, Exponential Moving Average, and Weighted Moving Average calculation types. The script p

Indicator v6 Moving averagesSupport & resistance
Updated 4 weeks ago · Apache-2.0 GitHub repository of MA Envelope (MAE)

Moon Dev GEX Walls & Trap

by moondevonyt
92 stars

This indicator estimates gamma exposure levels and intraday context for index instruments like SPY and ES. It calculates VWAP with standard deviation bands as a gamma flip proxy, highlighting market regimes through background colors. It plots prior day high, l

Indicator v5 Support & resistanceSessions & time
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Walls & Trap

Median

by TWODS-CAPITAL
37 stars

The Median indicator calculates the median of a selected source series such as the high-low average over a user-defined length and plots it as a red line on the price chart. It draws an EMA of the median as a blue line and fills the space between them, changin

Indicator v5 Moving averagesVolatility & bands
Updated 3 years ago · MIT GitHub repository of Median
20 stars

This indicator calculates a base moving average (EMA, SMA, WMA, or HMA) and projects multiple symmetrical envelope bands around it directly on the price chart. Users can adjust the length, source, moving average type, and initial envelope multiplier. Additiona

Indicator v5 Moving averagesVolatility & bands
Updated 1 year ago · None stated GitHub repository of Multiple Moving Average Envelope

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