Indicatore Evasive SuperTrend LuxAlgo in ProRealCode

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #258461 quote
    brian gilbert
    Participant
    Junior

    Buonasera, ho trovato su Tradingview un indicatore che mi sembra davvero interessante, in pratica un Supertrend con filtro di rumore che si adatta particolarmente bene, e volevo sapere se è possibile tradurlo in Prorealcode…. il link della relativa pagina è: https://it.tradingview.com/script/tfC7w3jE-Evasive-SuperTrend-LuxAlgo/

    e lo script ve lo riporto qui sotto:

    ————————————————————————————————————————————-

    // 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)

    ————————————————————————————————————–

    grazie in anticipo a tutti.

    #258466 quote
    Iván González
    Moderator
    Master

    Please post your conversion requests from TradingView to ProRealTime in this group:

    TradingView to ProRealTime Translation Center

    I’ve just transferred your topic; it will be for the next request 🙂

    #258470 quote
    brian gilbert
    Participant
    Junior

    Grazie, non lo sapevo perchè mancavo da qualche settimana…. una domanda: devo scrivere in inglese o in italiano come nel precedente Forum? Comunque vi ringrazio in anticipo per il vostro lavoro.

    #258471 quote
    Iván González
    Moderator
    Master

    Hi! The indicator has been translated. Here it is:

    //----------------------------------------------
    // PRC_Evasive SuperTrend [by LuxAlgo]
    // version = 0
    // 25.02.2026
    // Iván González @ www.prorealcode.com
    // Sharing ProRealTime knowledge
    //----------------------------------------------
    // === INPUTS ===
    lengthATR = 10 // ATR Length
    mult = 3.0 // Base Multiplier
    noiseThresh = 1.0 // Noise Threshold (xATR)
    expAlpha = 0.5 // Expansion Alpha (xATR)
    showLabels = 1 // Show Signal Labels (1=yes, 0=no)
    showFills = 1 // Show Gradient Fills (1=yes, 0=no)
    
    // === COLORS ===
    bullR = 8
    bullG = 153
    bullB = 129
    bearR = 242
    bearG = 54
    bearB = 69
    
    // === CORE CALCULATIONS ===
    myATR = averagetruerange[lengthATR]
    src = (high + low) / 2
    upperBase = src + mult * myATR
    lowerBase = src - mult * myATR
    
    // === INITIALIZATION ===
    once trend = 1
    
    // === PREVIOUS BAND ===
    
    if barindex <= lengthATR then
       if trend = 1 then
          prevBand = lowerBase
       else
          prevBand = upperBase
       endif
    else
       prevBand = stBand[1]
    endif
    
    // === NOISE DETECTION ===
    noiseDist = abs(close - prevBand)
    if noiseDist < (myATR * noiseThresh) then
       isNoisy = 1
    else
       isNoisy = 0
    endif
    
    // === ADAPTIVE BAND CALCULATION ===
    if trend = 1 then
       if isNoisy then
          stBand = prevBand - (myATR * expAlpha)
       else
          stBand = max(lowerBase, prevBand)
       endif
       if close < stBand then
          trend = -1
          stBand = upperBase
       endif
    else
       if isNoisy then
          stBand = prevBand + (myATR * expAlpha)
       else
          stBand = min(upperBase, prevBand)
       endif
       if close > stBand then
          trend = 1
          stBand = lowerBase
       endif
    endif
    
    // === TREND CHANGE DETECTION ===
    if barindex > 0 and trend <> trend[1] then
       trendChanged = 1
    else
       trendChanged = 0
    endif
    
    // === DYNAMIC COLORS + ALPHA ===
    if trend = 1 then
       r = bullR
       g = bullG
       b = bullB
    else
       r = bearR
       g = bearG
       b = bearB
    endif
    
    if isNoisy then
       lineAlpha = 100
    else
       lineAlpha = 255
    endif
    
    // === SWITCH DOT ===
    if trendChanged then
       drawpoint(barindex, stBand, 3) coloured(r, g, b)
    endif
    
    // === SIGNAL LABELS ===
    if showLabels and trendChanged then
       if trend = 1 then
          drawtext("BULL", barindex, stBand-0.5*myatr, Dialog, Bold, 8) coloured(bullR, bullG, bullB)
       else
          drawtext("BEAR", barindex, stBand+0.5*myatr, Dialog, Bold, 8) coloured(bearR, bearG, bearB)
       endif
    endif
    
    // === FILL ===
    if showFills then
       alphaFill = 60
    else
       alphaFill = 0
    endif
    colorbetween(src, stBand, r, g, b, alphaFill)
    
    
    return stBand as "Evasive ST" coloured(r, g, b, lineAlpha) style(line, 2)
    

    Regarding the language to use in this new group, please use English so everyone can benefit. Thank you for your understanding.

    brian gilbert thanked this post
    #258475 quote
    brian gilbert
    Participant
    Junior
    <p>THANK YOU VERY MUCH, IVAN, FOR YOUR USUAL SPEED, EFFICIENCY AND COMPETENCE, AND ALSO FOR THE CLARIFICATION ABOUT THE LANGUAGE!!</p>
    #258483 quote
    robertogozzi
    Moderator
    Master


    brian gilbert wrote: Grazie, non lo sapevo perchè mancavo da qualche settimana…. una domanda: devo scrivere in inglese o in italiano come nel precedente Forum? Comunque vi ringrazio in anticipo per il vostro lavoro.

    Devi sempre usare la lingua del forum prescelto. Se hai scelto un forum Italiano usa sempre l’Italiano, se hai scelto quello Inglese usa l’Inglese ecc…


    brian gilbert thanked this post
    #258491 quote
    brian gilbert
    Participant
    Junior

    Grazie Roberto della tua risposta, ma…. mi sorge un piccolo dubbio: più sopra Ivan mi dice di usare l’inglese, adesso tu mi dici di scrivere in italiano…. qual è la regola giusta da tener presente? Grazie in anticipo della tua chiarificazione e della tua pazienza.

    #258500 quote
    robertogozzi
    Moderator
    Master

    In realtà nei gruppi non c’è una differenziazione come nei forum, dove invece c’è una bandiera corrispondente alla lingua del forum prescelto, per cui credo sia corretto il suggerimento di Ivan.


    brian gilbert thanked this post
    #258502 quote
    brian gilbert
    Participant
    Junior

    ok, grazie

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

TradingView to ProRealTime Translation Center

New Reply
Author
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by brian gilbert
2 days, 4 hours ago.

Topic Details
Forum: TradingView to ProRealTime Translation Center Forum
Started: 02/24/2026
Status: Active
Attachments: No files
Logo Logo
Loading...