convertion de l’indicateur SUPERTRENDED MOVING AVERAGES

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #245798 quote
    Samir pluquin
    Participant
    New

    Bonjour,

    Pouvez vous traduire cette indicateur de tradingview svp

    ci dessous le code source de l’indicateur

    merci à vous

    /// code source ////

    //@version=5

    indicator(‘SuperTrended Moving Averages’, ‘ST MA’, overlay=true, format=format.price, precision=2, timeframe=”, timeframe_gaps=false)
    src = input(close, title=’Source’)
    mav = input.string(title=’Moving Average Type’, defval=’EMA’, options=[‘SMA’, ‘EMA’, ‘WMA’, ‘DEMA’, ‘TMA’, ‘VAR’, ‘WWMA’, ‘ZLEMA’, ‘TSF’, ‘HULL’, ‘TILL’])
    length = input.int(100, ‘Moving Average Length’, minval=1)
    Periods = input(title=’ATR Period’, defval=10)
    Multiplier = input.float(title=’ATR Multiplier’, step=0.1, defval=0.5)
    changeATR = input(title=’Change ATR Calculation Method ?’, defval=true)
    showsignals = input(title=’Show Buy/Sell Signals ?’, defval=false)
    highlighting = input(title=’Highlighter On/Off ?’, defval=true)

    T3a1 = input.float(0.7, ‘TILLSON T3 Volume Factor’, step=0.1)

    Var_Func(src, length) =>
    valpha = 2 / (length + 1)
    vud1 = src > src[1] ? src – src[1] : 0
    vdd1 = src < src[1] ? src[1] - src : 0 vUD = math.sum(vud1, 9) vDD = math.sum(vdd1, 9) vCMO = nz((vUD - vDD) / (vUD + vDD)) VAR = 0.0 VAR := nz(valpha * math.abs(vCMO) * src) + (1 - valpha * math.abs(vCMO)) * nz(VAR[1]) VAR VAR = Var_Func(src, length) DEMA = 2 * ta.ema(src, length) - ta.ema(ta.ema(src, length), length) Wwma_Func(src, length) =>
    wwalpha = 1 / length
    WWMA = 0.0
    WWMA := wwalpha * src + (1 – wwalpha) * nz(WWMA[1])
    WWMA
    WWMA = Wwma_Func(src, length)
    Zlema_Func(src, length) =>
    zxLag = length / 2 == math.round(length / 2) ? length / 2 : (length – 1) / 2
    zxEMAData = src + src – src[zxLag]
    ZLEMA = ta.ema(zxEMAData, length)
    ZLEMA
    ZLEMA = Zlema_Func(src, length)
    Tsf_Func(src, length) =>
    lrc = ta.linreg(src, length, 0)
    lrc1 = ta.linreg(src, length, 1)
    lrs = lrc – lrc1
    TSF = ta.linreg(src, length, 0) + lrs
    TSF
    TSF = Tsf_Func(src, length)
    HMA = ta.wma(2 * ta.wma(src, length / 2) – ta.wma(src, length), math.round(math.sqrt(length)))
    T3e1 = ta.ema(src, length)
    T3e2 = ta.ema(T3e1, length)
    T3e3 = ta.ema(T3e2, length)
    T3e4 = ta.ema(T3e3, length)
    T3e5 = ta.ema(T3e4, length)
    T3e6 = ta.ema(T3e5, length)
    T3c1 = -T3a1 * T3a1 * T3a1
    T3c2 = 3 * T3a1 * T3a1 + 3 * T3a1 * T3a1 * T3a1
    T3c3 = -6 * T3a1 * T3a1 – 3 * T3a1 – 3 * T3a1 * T3a1 * T3a1
    T3c4 = 1 + 3 * T3a1 + T3a1 * T3a1 * T3a1 + 3 * T3a1 * T3a1
    T3 = T3c1 * T3e6 + T3c2 * T3e5 + T3c3 * T3e4 + T3c4 * T3e3

    getMA(src, length) =>
    ma = 0.0
    if mav == ‘SMA’
    ma := ta.sma(src, length)
    ma

    if mav == ‘EMA’
    ma := ta.ema(src, length)
    ma

    if mav == ‘WMA’
    ma := ta.wma(src, length)
    ma

    if mav == ‘DEMA’
    ma := DEMA
    ma

    if mav == ‘TMA’
    ma := ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)
    ma

    if mav == ‘VAR’
    ma := VAR
    ma

    if mav == ‘WWMA’
    ma := WWMA
    ma

    if mav == ‘ZLEMA’
    ma := ZLEMA
    ma

    if mav == ‘TSF’
    ma := TSF
    ma

    if mav == ‘HULL’
    ma := HMA
    ma

    if mav == ‘TILL’
    ma := T3
    ma
    ma

    MA = getMA(src, length)

    atr2 = ta.sma(ta.tr, Periods)
    atr = changeATR ? ta.atr(Periods) : atr2
    up = MA – Multiplier * atr
    up1 = nz(up[1], up)
    up := close[1] > up1 ? math.max(up, up1) : up
    dn = MA + Multiplier * atr
    dn1 = nz(dn[1], dn)
    dn := close[1] < dn1 ? math.min(dn, dn1) : dn trend = 1 trend := nz(trend[1], trend) trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend upPlot = plot(trend == 1 ? up : na, title='Up Trend', color=color.new(color.green, 100), linewidth=0, style=plot.style_linebr) buySignal = trend == 1 and trend[1] == -1 plotshape(buySignal ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 100)) plotshape(buySignal and showsignals ? up : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0)) dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=0, color=color.new(color.red, 100)) sellSignal = trend == -1 and trend[1] == 1 plotshape(sellSignal ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 100)) plotshape(sellSignal and showsignals ? dn : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0)) mPlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0) colorup = input.color(defval = color.new(color.green, 60), title = "ColorU", inline = 'color') colordown = input.color(defval = color.new(color.red, 60), title = "ColorD", inline = 'color') longFillColor = highlighting ? trend == 1 ? colorup : color.white : color.new(color.white, 100) shortFillColor = highlighting ? trend == -1 ? colordown : color.white : color.new(color.white, 100) fill(mPlot, upPlot, title='UpTrend Highligter', color=longFillColor) fill(mPlot, dnPlot, title='DownTrend Highligter', color=shortFillColor) alertcondition(buySignal, title='SuperTrend Buy', message='SuperTrend Buy!') alertcondition(sellSignal, title='SuperTrend Sell', message='SuperTrend Sell!') changeCond = trend != trend[1] alertcondition(changeCond, title='SuperTrend Direction Change', message='SuperTrend has changed direction!')

    #245869 quote
    Iván González
    Moderator
    Master
    //----------------------------------------//
    //PRC_Supertrended Moving average
    //version = 0
    //14.04.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //----------------------------------------//
    // Inputs
    //----------------------------------------//
    src=close
    
    mav=1 // Moving average type 0=SMA 1=EMA 2=WMA...
    length=100
    t3a1=0.7 // Tillson T3 volume factor
    
    periods=10
    multiplier=0.5
    
    changeAtr=1
    showsignals=1
    
    //----------------------------------------//
    // Calculations
    //----------------------------------------//
    if barindex>length then
    // VAR   
    valpha=2/(length+1)
    if src>src[1] then
    vud1=src-src[1]
    else
    vud1=0
    endif
    if src<src[1] then
    vdd1=src[1]-src
    else
    vdd1=0
    endif
    vUD=summation[9](vud1)
    vDD=summation[9](vdd1)
    vcmo=(vud-vdd)/(vud+vdd)
       
    var=valpha*abs(vcmo)*src+(1-valpha*abs(vcmo))*var[1]
    //WWMA
    wwalpha=1/length
    wwma=0
    wwma=wwalpha*src+(1-wwalpha)*wwma[1]
    //
    t3e1=average[length,1](src)
    t3e2=average[length,1](t3e1)
    t3e3=average[length,1](t3e2)
    t3e4=average[length,1](t3e3)
    t3e5=average[length,1](t3e4)
    t3e6=average[length,1](t3e5)
    t3c1=-t3a1*t3a1*t3a1
    t3c2=3*t3a1*t3a1+3*t3a1*t3a1*t3a1
    t3c3=-6*t3a1*t3a1-3*t3a1-3*t3a1*t3a1*t3a1
    t3c4=1+3*t3a1+t3a1*t3a1*t3a1+3*t3a1*t3a1
    t3=t3c1*t3e6+t3c2*t3e5+t3c3*t3e4+t3c4*t3e3
    endif
    
    //----------------------------------------//
    // Moving Average
    //----------------------------------------//
    if mav=0 then//SMA
    MA=average[length](src)
    elsif mav=1 then//EMA
    MA=average[length,1](src)
    elsif mav=2 then//WMA
    MA=average[length,2](src)
    elsif mav=3 then//DEMA
    MA=dema[length](src)
    elsif mav=4 then//TMA
    MA=average[floor(length/2)+1](average[ceil(length/2)](src))
    elsif mav=5 then//var
    MA=var
    elsif mav=6 then//wwma
    MA=wwma
    elsif mav=7 then //ZLema
    MA=average[length,8](src)
    elsif mav=8 then //Hull
    MA=average[length,7](src)
    else //TILL
    MA = t3
    endif
    //----------------------------------------//
    // Average True Range
    //----------------------------------------//
    atr2=average[periods](tr)
    if changeAtr then
    atr=averagetruerange[periods](close)
    else
    atr=atr2
    endif
    //----------------------------------------//
    // Supertrend
    //----------------------------------------//
    up=MA-multiplier*atr
    up1=up[1]
    if close[1]>up1 then
    up=max(up,up1)
    else
    up=up
    endif
    
    dn=MA+multiplier*atr
    dn1=dn[1]
    if close[1]<dn1 then
    dn=min(dn,dn1)
    else
    dn=dn
    endif
    
    once trend=1
    
    if trend=-1 and close>dn1 then
    trend=1
    elsif trend=1 and close<up1 then
    trend=-1
    else
    trend=trend
    endif
    
    if trend=1 then
    st=up
    aup=255
    adn=0
    elsif trend=-1 then
    st=dn
    adn=255
    aup=0
    else
    aup=0
    adn=0
    endif
    //----------------------------------------//
    // Signals
    //----------------------------------------//
    buysignal = trend=1 and trend[1]=-1
    sellsignal = trend[1]=1 and trend=-1
    
    if showsignals and buysignal then
    drawarrowup(barindex,low-0.35*atr)coloured("green")
    elsif showsignals and sellsignal then
    drawarrowdown(barindex,high+0.35*atr)coloured("red")
    endif
    //----------------------------------------//
    // Highlighting
    //----------------------------------------//
    if MA then
    mplot=(open+high+low+close)/4
    colorbetween(mplot,st,"red",adn*0.1)
    colorbetween(mplot,st,"green",aup*0.1)
    endif
    //----------------------------------------//
    return
    Samir pluquin thanked this post
    #245894 quote
    Samir pluquin
    Participant
    New

    Bonjour,

    Merci beaucoup pour la conversion mais pouvez vous m’expliquer comment le convertir avec la moyenne mobile HULL svp

    merci beaucoup de votre aide

    Cordialement

    #245896 quote
    jacquesgermain
    Participant
    Senior

    Bonjour

    pour travailler avec la avec la moyenne mobile HULL il faut passer de mav=1 à mav=8 ligne 12 dans le code

    Samir pluquin and Iván González thanked this post
    #245897 quote
    Samir pluquin
    Participant
    New

    oui en effet je viens de modifier le code cela fonctionne =)

     

    Je vous remercie beaucoup de votre retour

     

    Cordialement

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

convertion de l’indicateur SUPERTRENDED MOVING AVERAGES


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Samir pluquin
9 months, 3 weeks ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 04/11/2025
Status: Active
Attachments: No files
Logo Logo
Loading...