Trend Direction Force Index, da Tradingview

Forums ProRealTime forum Italiano Supporto ProBuilder Trend Direction Force Index, da Tradingview

  • This topic has 1 reply, 2 voices, and was last updated 1 day ago by avatarIván.
Viewing 2 posts - 1 through 2 (of 2 total)
  • #253150

    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

    Ecco!

Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login