Indicator · Pine Script v6 · On the chart

ATR Rope

by regalouisei· code credited to SamRecio

This overlay indicator smooths a chosen price source with a rope-style range filter.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code114
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 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

114 lines of Pine Script v6 from pinescript/editors_picks/atr-rope.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

atr-rope.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SamRecio

//@version=6
indicator("ATR Rope", overlay = true)

///_____________________________________________________________________________________________________________________
///Inputs
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

var params = "Parameters"
src = nz(input.source(close, title = "Source", group = params))
len = input.int(14, title = "ATR Len", group = params)
multi = input.float(1.5, title = "Multi", step = 0.25, minval = 0, group = params)

var disp = "Display"
rng_tog = input.bool(true, title = "Consolidation Ranges", group = disp)
atr_tog = input.bool(false, title = "ATR Channel", group = disp)

var cols = "Colors"
up_col = input.color(#3daa45, title = "Up Color", group = cols)
down_col = input.color(#ff033e, title = "Down Color", group = cols)
flat_col = input.color(#004d92, title = "Flat Color", inline = "3", group = cols)
rng_col = input.color(#004d9233, title = "", inline = "3", group = cols)

///_____________________________________________________________________________________________________________________
///Function
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

//Smooths a Source similar to Rope Stabilization in a Drawing Application. OR a "Range Filter" as some might say ;)
rope_smoother(float _src, float _threshold) =>

    var float _rope = _src

    _move = _src - _rope //Movement from Rope

    _rope += math.max(math.abs(_move) - nz(_threshold), 0) * math.sign(_move) //Directional Movement beyond the Threshold
    
    [_rope,_rope+_threshold,_rope-_threshold] //[Rope, Upper, Lower]

///_____________________________________________________________________________________________________________________
///Rope Calcs
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

//Calculating Rope
atr = ta.atr(len)*multi

[rope,upper,lower] = rope_smoother(src,atr)

//Directional Detection
var dir = 0

dir := rope > rope[1] ? 1 : rope < rope[1] ? -1 : dir

if ta.cross(src,rope)
    dir := 0

//Directional Color Assignment    
col = dir > 0 ? up_col : dir < 0 ? down_col : flat_col

///_____________________________________________________________________________________________________________________
///Consolidation Ranges
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

//High and Low Output Lines
var float c_hi = na
var float c_lo = na

//Counters for Accumulating Averages
var float h_sum = 0
var float l_sum = 0
var int c_count = 0

//Flip-Flop
var ff = true

//Flip Flop, Pip Slip Top,
//Bear Drop, Bull Pop, Lunch Time Chop,
//Tight Stop, Desktop Prop.
if dir == 0

    if dir[1] != 0
        h_sum := 0
        l_sum := 0
        c_count := 0
        ff := not ff

    h_sum += upper
    l_sum += lower
    c_count += 1
    c_hi := h_sum/c_count
    c_lo := l_sum/c_count

///_____________________________________________________________________________________________________________________
///Display
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

//Rope
plot(rope, linewidth = 3, color = col, title = "Rope", force_overlay = true)

//Channel
plot(upper, display = atr_tog?display.all:display.none, color = col, title = "Upper", force_overlay = true)
plot(lower, display = atr_tog?display.all:display.none, color = col,  title = "Lower", force_overlay = true)

//Consolidation Ranges

h1 = plot(ff?na:c_hi, style = plot.style_linebr, color = color.new(rng_col,0), display = rng_tog?display.all:display.none, title = "Range High 1")
l1 = plot(ff?na:c_lo, style = plot.style_linebr, color = color.new(rng_col,0), display = rng_tog?display.all:display.none, title = "Range Low 1")

h2 = plot(ff?c_hi:na, style = plot.style_linebr, color = color.new(rng_col,0), display = rng_tog?display.all:display.none, title = "Range High 2")
l2 = plot(ff?c_lo:na, style = plot.style_linebr, color = color.new(rng_col,0), display = rng_tog?display.all:display.none, title = "Range Low 2")

fill(h1,l1,rng_col, display = rng_tog?display.all:display.none, title = "Range 1 Fill")
fill(h2,l2,rng_col, display = rng_tog?display.all:display.none, title = "Range 2 Fill")

Overview

ATR Rope moves the line only when price travels beyond an ATR length multiplied by a user multiplier, then colors the rope up, down, or flat from its slope and from source crosses. ATR length and multiplier set the threshold, while toggles show consolidation ranges and an ATR channel on the price chart. The script is truncated before the range drawing logic, and it has no trade entries or exits.

Details

Published by

regalouisei on GitHub

Code credit

SamRecio, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Volatility & bands

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.

Settings

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

SettingTypeDefaultVariable
SourcesourcecloseSource
ATR Lenint14len
Multifloat1.5multi
Consolidation Rangesbooltruerng_tog
ATR Channelboolfalseatr_tog
Up Colorcolor#3daa45up_col
Down Colorcolor#ff033edown_col
Flat Colorcolor#004d92flat_col
rng_colcolor#004d9233rng_col
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

Chandelier Exit

by everget
948 stars

This indicator plots an ATR-based Chandelier Exit trailing stop on the price chart. It tracks a long stop under recent highs and a short stop above recent lows, then switches direction when price crosses the opposite stop. Buy and sell labels mark those flips.

Indicator v6 Volatility & bandsTrend Repaints
Updated 10 days ago · GPL-3.0 GitHub repository of Chandelier Exit

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
330 stars

Range Filter [Alorse] is a technical indicator overlay for TradingView designed to filter market volatility and identify price trends. It calculates a smoothed range based on historical volatility using a configurable sampling period and multiplier applied to

Indicator v5 TrendVolatility & bands
Updated 2 months ago · None stated GitHub repository of Range Filter [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

[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

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