Trend Direction Force Index, da Tradingview

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #253150 quote
    brian gilbertbrian gilbert
    Participant
    Senior

    Buonasera a tutti, eccomi di nuovo qua a chiedere il vostro aiuto… Ho trovato il codice di un indicatore piuttosto interessante su Tradingview, che a quanto sembra identifica sia i periodi di mercato laterale, sia le “esplosioni” di Momentum a mercato in trend. Ovviamente le 2 cose sono una specie di ricerca del Santo Graal per i traders, quindi mi piacerebbe poterlo vedere in azione sulla nostra piattaforma. E’ possibile tradurlo? Ve lo riporto qui sotto…

    ——————————————-TREND DIRECTION FORCE INDEX————————————–

    //@version=4

    study(“Trend Direction Force Index v2 – TDFI [wm]”, shorttitle = “TDFI v2 [wm]”, overlay = false)

    lookback = input(13, title = “Lookback”) 

    mmaLength = input(13, title = “MMA Length”) 

    mmaMode = input(title = “MMA Mode”, defval=”ema”, options=[“ema”, “wma”, “swma”, “vwma”, “hull”, “tema”])

    smmaLength = input(13) 

    smmaMode = input(title = “SMMA Mode”, defval=”ema”, options=[“ema”, “wma”, “swma”, “vwma”, “hull”, “tema”])

    nLength = input(3, title = “N Length”) 

    filterHigh = input(0.05, title = “Filter High”) 

    filterLow = input(-0.05, title = “Filter Low”) 

    price = input(close, “Period”)

    tema(src, len) =>

        ema1 = ema(src, len)

        ema2 = ema(ema1, len)

        ema3 = ema(ema2, len)

        (3 * ema1) – (3 * ema2) + ema3

        

    ma(mode, src, len) =>

         mode == “ema” ? ema(src, len) : 

         mode == “wma” ? wma(src, len) : 

         mode == “swma” ? swma(src) : 

         mode == “vwma” ? vwma(src, len) : 

         mode == “hull” ? wma((2 * wma(src, len / 2)) – wma(src, len), round(sqrt(len))) : 

         mode == “tema” ? tema(src, len) :

         sma(src, len)

         

    tdfi() =>

        mma = ma(mmaMode, price * 1000, mmaLength)

        smma = ma(smmaMode, mma, smmaLength)

        impetmma = mma – mma[1]

        impetsmma = smma – smma[1]

        divma = abs(mma – smma)

        averimpet = (impetmma + impetsmma) / 2

        tdf = pow(divma, 1) * pow(averimpet, nLength)

        tdf / highest(abs(tdf), lookback * nLength)

        

    signal = tdfi()

    c = signal > filterHigh ? color.green : signal < filterLow ? color.red : color.gray

    plot(signal, linewidth = 2, color = c)

    hline(filterHigh, color = color.black)

    hline(filterLow, color = color.black)

    —————————————————————————————————

    Grazie in anticipo e buonanotte.

    Paolo

    #253165 quote
    Iván GonzálezIván González
    Moderator
    Legend
    Ecco!
    //------------------------------------------//
    //PRC_Order Blocks and Breaker Blocks
    //version = 0
    //30.09.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //------------------------------------------//
    //-----Inputs-------------------------------//
    //------------------------------------------//
    lookback = 13
    mmaLength = 13
    smmaLength = 13
    nLength = 3
    filterHigh = 0.05
    filterLow = -0.05
    iprice = close
    matype=1
    //------------------------------------------//
    // --- Lógica del TDFI ---
    //------------------------------------------//
    // 1. Calcular mma (Media Móvil Principal)
    // mmaMode = "ema" (Opción por defecto)
    mma = Average[mmaLength,matype](iprice * 1000)
    // 2. Calcular smma (Media Móvil Suavizada, MA de mma)
    smma = Average[smmaLength,matype](mma)
    // 3. Calcular el TDFI
    impetmma = mma - mma[1]
    impetsmma = smma - smma[1]
    divma = ABS(mma - smma)
    averimpet = (impetmma + impetsmma) / 2
    // pow(divma, 1) es simplemente divma
    tdf = divma * POW(averimpet, nLength)
    // Normalización
    lookbackPeriod = lookback * nLength
    highestTDF = HIGHEST[lookbackPeriod](ABS(tdf))
    // Evitar división por cero
    IF highestTDF = 0 THEN
    signal = 0
    ELSE
    signal = tdf / highestTDF
    ENDIF
    // 4. Configurar ploteo y colores
    IF signal > filterHigh THEN
    r=0
    g=255
    b=0
    ELSIF signal < filterLow THEN
    r=255
    g=0
    b=0
    ELSE
    r=124
    g=124
    b=124
    ENDIF
    //------------------------------------------//
    RETURN signal COLOURED(r, g, b)style(line,2),filterHigh AS "Nivel Alto" STYLE(DottedLine),filterLow AS "Nivel Bajo" STYLE(DottedLine)
    
    #253189 quote
    Ciccarelli FrancoCiccarelli Franco
    Participant
    Senior
    Non si vede niente.
    #253190 quote
    jacquesgermainjacquesgermain
    Participant
    Veteran
    Bonjour cela fonctionne mais pas sur les prix à ajouter via nouveau panneau Ciao Funziona, ma non per i prezzi aggiunti tramite un nuovo pannello.
    robertogozzi and Iván González thanked this post
    #253202 quote
    robertogozzirobertogozzi
    Moderator
    Legend
    @brian gilbert Pubblica solo nella lingua del forum in cui stai postando. Ad esempio solo l’inglese nei forum di lingua inglese e il francese solo nei forum di lingua francese. Grazie 🙂
    #253210 quote
    Iván GonzálezIván González
    Moderator
    Legend
    L’indicatore viene inserito come nuovo pannello.
    2025-11-03_10-03.png 2025-11-03_10-03.png 2025-11-03_10-04.png 2025-11-03_10-04.png
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

TradingView to ProRealTime Translation Center

New Reply
Author
Summary

This topic contains 5 replies,
has 5 voices, and was last updated by Iván GonzálezIván González
11 months, 3 weeks ago.

Topic Details
Forum: TradingView to ProRealTime Translation Center Forum
Started: 10/30/2025
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...