Indicator · Pine Script v6 · On the chart

Evasive SuperTrend [LuxAlgo]

by theonetrade· code credited to LuxAlgo

Evasive SuperTrend [LuxAlgo] is a trend-following overlay that modifies standard Supertrend logic to reduce whipsaws during noisy price action.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code116
Settings6inputs
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

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

evasive_supertrend_luxalgo_tfC7w3jE.pine
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=6
indicator("Evasive SuperTrend [LuxAlgo]", "LuxAlgo - Evasive SuperTrend", overlay = true, max_labels_count = 500)

//---------------------------------------------------------------------------------------------------------------------}
// Constants
//---------------------------------------------------------------------------------------------------------------------{
color BULL_COLOR            = #089981
color BEAR_COLOR            = #f23645

//---------------------------------------------------------------------------------------------------------------------}
// Inputs
//---------------------------------------------------------------------------------------------------------------------{
string ST_GROUP             = 'Supertrend Settings'
int lengthInput             = input.int(10, 'ATR Length', minval = 1, group = ST_GROUP)
float multiplierInput       = input.float(3.0, 'Base Multiplier', minval = 0.1, step = 0.1, group = ST_GROUP)

string NOISE_GROUP          = 'Noise Avoidance Logic'
float thresholdInput        = input.float(1.0, 'Noise Threshold (xATR)', minval = 0.1, step = 0.1, group = NOISE_GROUP, tooltip = 'If price gets closer to the band than this value, the band is pushed away.')
float alphaInput            = input.float(0.5, 'Expansion Alpha (xATR)', minval = 0, step = 0.1, group = NOISE_GROUP, tooltip = 'Distance (in ATRs) to push the band away when noise is detected.')

string VISUAL_GROUP         = 'Visualization'
bool showLabelsInput        = input.bool(true, 'Show Signal Labels', group = VISUAL_GROUP)
bool showFillsInput         = input.bool(true, 'Show Gradient Fills', group = VISUAL_GROUP)

//---------------------------------------------------------------------------------------------------------------------}
// Core Calculations
//---------------------------------------------------------------------------------------------------------------------{
// ATR Calculation
float atr = ta.atr(lengthInput)

// Supertrend Variables
var float stBand      = na
var int trend         = 1 // 1 for Bull, -1 for Bear

float src = hl2
float upperBase = src + multiplierInput * atr
float lowerBase = src - multiplierInput * atr

// Previous Band (needed for noise check)
float prevBand = nz(stBand[1], trend == 1 ? lowerBase : upperBase)

// Noise Avoidance Condition
// Logic: If price is closer to the band than (ATR * threshold), it's noisy
bool isNoisy = math.abs(close - prevBand) < (atr * thresholdInput)

// Band Calculation with Adaptive Expansion
if trend == 1
    // BULL TREND: If noisy, move band DOWN (away from price). 
    // This overrides the standard "only move up" math.max rule.
    if isNoisy
        stBand := prevBand - (atr * alphaInput)
    else
        stBand := math.max(lowerBase, prevBand)
    
    // Check for Trend Flip
    if close < stBand
        trend := -1
        stBand := upperBase
else
    // BEAR TREND: If noisy, move band UP (away from price).
    // This overrides the standard "only move down" math.min rule.
    if isNoisy
        stBand := prevBand + (atr * alphaInput)
    else
        stBand := math.min(upperBase, prevBand)
    
    // Check for Trend Flip
    if close > stBand
        trend := 1
        stBand := lowerBase

bool trendChanged = trend != trend[1]

//---------------------------------------------------------------------------------------------------------------------}
// Visuals
//---------------------------------------------------------------------------------------------------------------------{
color stColor = trend == 1 ? BULL_COLOR : BEAR_COLOR

// Switch Dot
plot(trendChanged ? stBand : na, "Trend Switch Dot", color = stColor, style = plot.style_circles, linewidth = 4, join = false)

// Main Band - Two plots used to handle conditional line styles (Solid vs Dotted)
// Invisible plot used as anchor for the gradient fill
plotId = plot(stBand, "Band for Fill", color = na)

// Solid Line (Normal mode) - style_linebr prevents gaps when switching to dotted
plot(isNoisy ? na : stBand, "Solid Band", color = stColor, linewidth = 2, style = plot.style_linebr)

// Dotted Line (Expansion/Noise mode)
plot(isNoisy ? stBand : na, "Dotted Band", color = stColor, linewidth = 2, style = plot.style_linebr, linestyle = plot.linestyle_dotted)

srcId  = plot(src, "Source", color = na)

// Gradient Fill (Strictly following: less transparent near price)
float topValue    = math.max(src, stBand)
float bottomValue = math.min(src, stBand)
color topFillColor    = trend == 1 ? color.new(BULL_COLOR, 50) : color.new(BEAR_COLOR, 100)
color bottomFillColor = trend == 1 ? color.new(BULL_COLOR, 100) : color.new(BEAR_COLOR, 50)

fill(plotId, srcId, topValue, bottomValue, topFillColor, bottomFillColor, 
     title   = "Trend Fill", 
     display = showFillsInput ? display.all : display.none)

// Signal Labels
if showLabelsInput and trendChanged
    label.new(bar_index, stBand, 
         text = trend == 1 ? "BULL" : "BEAR", 
         color = stColor, 
         textcolor = #FFFFFF, 
         style = trend == 1 ? label.style_label_up : label.style_label_down, 
         size = size.tiny)

//---------------------------------------------------------------------------------------------------------------------}

Overview

Evasive SuperTrend [LuxAlgo] tracks volatility using an ATR multiplier applied to the median price. When price comes within a specified ATR noise threshold of the trailing band, the script actively pushes the band further away by an expansion alpha offset. This prevents premature trend flips during consolidation while plotting directional trend lines, signal labels, and gradient fills on the chart.

Details

Published by

theonetrade on GitHub

Code credit

LuxAlgo, 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
ATR Lengthint10lengthInput
Base Multiplierfloat3.0multiplierInput
Noise Threshold (xATR)float1.0thresholdInput
Expansion Alpha (xATR)float0.5alphaInput
Show Signal LabelsbooltrueshowLabelsInput
Show Gradient FillsbooltrueshowFillsInput
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