Indicator · Pine Script v5 · On the chart

Radius Trend [ChartPrime]

by theonetrade· code credited to ChartPrime

The Radius Trend indicator tracks directional trend changes on the main price chart by constructing a dynamic trailing band based on 100-period average price range distances.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code82
Settings2inputs
LicenceMIT
Last update2 weeks ago8 Nov 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

82 lines of Pine Script v5 from assets/indicator/bit-exact/radius_trend_chartprime_4KIHf36j.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

radius_trend_chartprime_4KIHf36j.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©ChartPrime

//@version=5
indicator("Radius Trend [ChartPrime]", overlay = true)

// --------------------------------------------------------------------------------------------------------------------}
// 𝙐𝙎𝙀𝙍 𝙄𝙉𝙋𝙐𝙏𝙎
// --------------------------------------------------------------------------------------------------------------------{
// @variable Step size for radius adjustment
float step       = input.float(0.15, "Radius Step", step = 0.001)
// @variable Multiplier for initial distance calculation
float multi      = input.float(2, "Start Points Distance", step = 0.1)

// Initialize variables
bool trend       = na
var float multi1 = 0.
var float multi2 = 0.
int n            = 3
var float band   = 0.

// --------------------------------------------------------------------------------------------------------------------}
// 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// --------------------------------------------------------------------------------------------------------------------{
// Calculate distances for band placement
float distance  = ta.sma(math.abs(high-low), 100) * multi
float distance1 = ta.sma(math.abs(high-low), 100) * 0.2

// Initialize trend and band on the 101st bar
if bar_index == 101
    trend := true
    band := low * 0.8

// Update trend based on price relation to band
if close < band
    trend := false

if close > band
    trend := true

// Adjust band on trend changes
if trend[1] == false and ta.change(trend)
    band := low - distance

if trend[1] == true and ta.change(trend)
    band := high + distance

// Apply step angle to trend lines
if bar_index % n == 0 and trend
    multi1 := 0
    multi2 += step    
    band   += distance1 * multi2

if bar_index % n == 0 and not trend
    multi1 += step
    multi2 := 0   
    band   -= distance1 * multi1

// Smooth the band
Sband = ta.sma(band, n)

// Set color based on trend
color      = trend ? #54b6d4 : #cf2b2b

// Calculate upper and lower bands
band_upper = ta.sma(band + distance*0.5, n)
band_lower = ta.sma(band - distance*0.5, n)
band1      = trend ? band_upper : band_lower

// --------------------------------------------------------------------------------------------------------------------}
// 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉
// --------------------------------------------------------------------------------------------------------------------{

// Plot the outer band
plot(band1, color = bar_index % 2 == 0 ? color.new(chart.fg_color, 50) : na)

// Plot the main band and fill area
p1 = plot(ta.change(trend) ? na : Sband, style = plot.style_linebr, color = color.gray)
p2 = plot(ta.sma(hl2, 20), display = display.none)

fill(p1, p2, band, ta.sma(hl2, 20), color.new(color, 60), na)
// --------------------------------------------------------------------------------------------------------------------}

Overview

When price crosses the band, the trend state flips, resetting the offset distance and applying incremental step adjustments to widen or tighten the boundary over time. The indicator plots dynamic trailing lines and fills the area between the radius band and a 20-period median price average. User inputs control the radius step size and initial distance multiplier.

Details

Published by

theonetrade on GitHub

Code credit

ChartPrime, as written in the script's header

Draws

On the price chart

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

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
Radius Stepfloat0.15step
Start Points Distancefloat2multi
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

[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 5 years ago · None stated GitHub repository of [RS]Donchian Fans

Dynamic Linear Regression

by TradersPost
228 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 4 months ago · None stated GitHub repository of Dynamic Linear Regression

ATR Trailing Stop

by mihakralj
99 stars

Calculates an ATR-based trailing stop overlaid on the price chart to assist with trend identification and stop placement. Using a specified ATR period and multiplier, it projects upper and lower bounds around the closing price. The stop line ratchets up during

Indicator v5 TrendVolatility & bands
Updated 8 weeks ago · Apache-2.0 GitHub repository of ATR Trailing Stop

Moon Dev Lunar Sniper

by moondevonyt
98 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 2 months ago · Custom licence GitHub repository of Moon Dev Lunar Sniper

SuperTrend & Pivots

by dcaoyuan
55 stars

This overlay indicator plots a SuperTrend line on the price chart using a fixed ATR length of 10 and a factor of 3. When the trend direction is up it draws a green line and a light green fill toward the candle midpoint; when down it draws a red line and a ligh

Indicator v6 TrendVolatility & bands
Updated 7 months ago · Apache-2.0 GitHub repository of SuperTrend & Pivots

More Trend scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers