Convention script tradingview

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #239893 quote
    ahmdupuit
    Participant
    New

    Bonjour, j’espère être au bon endroit , voilà j’aimerais convertir un script tradingview pour prorealtiem, mais je n’y connais rien en code , quelqu’un pourrait m’aider, je vous mets le script en de

     

    //@version=5
    indicator(‘Ehlers Leading Indicator [CC] Ribbon’, overlay=false)
    inp = input(title=’Source’, defval=hl2)
    res = input.timeframe(title=’Resolution’, defval=”)
    rep = input(title=’Allow Repainting?’, defval=true)
    bar = input(title=’Allow Bar Color Change?’, defval=true)
    colormode = input(title=’Color Mode? [on = CheatCountry, off=BurgerCrisis]’, defval=true)
    src = request.security(syminfo.tickerid, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]
    alpha01 = input.float(title=’Alpha1 1′, defval=0.03, minval=0.01, step=0.01)
    alpha02 = input.float(title=’Alpha1 2′, defval=0.06, minval=0.01, step=0.01)
    trend = input(title=’Show Ribbon? [off = show master]’, defval=true)
    //fun(x, y) =>
    //    a = x+y
    //    b = x-y
    //    [a, b]
    //Special syntax is required for calling such functions:
    //[res0, res1] = fun(open, close)
    //plot(res0)
    //plot(res1)
    ema = 0.0
    ema := 0.5 * src + 0.5 * nz(ema[1])
    f_ehi(_alpha1, _alpha2) =>
        lead = 0.0
        lead := 2 * src + (_alpha1 – 2) * nz(src[1]) + (1 – _alpha1) * nz(lead[1])
        netLead = 0.0
        netLead := _alpha2 * lead + (1 – _alpha2) * nz(netLead[1])
        sig = netLead > ema ? 1 : netLead < ema ? -1 : 0
        liColor = sig > 0 ? color.green : sig < 0 ? color.red : color.black
        [netLead, ema, sig, liColor]
    dd = (math.pow(0.05, 1.4) + math.pow(0.05, 1.3) + math.pow(0.05, 1.2)) / 3
    [netLead0, ema0, sig0, liColor0] = f_ehi(alpha01 * 1, alpha02 * 10)
    [netLead1, ema1, sig1, liColor1] = f_ehi(alpha01 * 2, alpha02 * 9)
    [netLead2, ema2, sig2, liColor2] = f_ehi(alpha01 * 3, alpha02 * 8)
    [netLead3, ema3, sig3, liColor3] = f_ehi(alpha01 * 4, alpha02 * 7)
    [netLead4, ema4, sig4, liColor4] = f_ehi(alpha01 * 5, alpha02 * 6)
    [netLead5, ema5, sig5, liColor5] = f_ehi(alpha01 * 6, alpha02 * 5)
    [netLead6, ema6, sig6, liColor6] = f_ehi(alpha01 * 7, alpha02 * 4)
    [netLead7, ema7, sig7, liColor7] = f_ehi(alpha01 * 8, alpha02 * 3)
    [netLead8, ema8, sig8, liColor8] = f_ehi(alpha01 * 9, alpha02 * 2)
    [netLead9, ema9, sig9, liColor9] = f_ehi(alpha01 * 10, alpha02 * 1)
    alertcondition(ta.crossover(sig0, 0), ‘0 Buy Signal’, ‘0 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig0, 0), ‘0 Sell Signal’, ‘0 Bearish Change Detected’)
    plot(trend ? netLead0 : na, title=’Lead 0′, color=liColor0, linewidth=2)
    plot(trend ? ema : na, title=’Ema’, color=color.new(color.black, 0), linewidth=1)
    alertcondition(ta.crossover(sig1, 0), ‘1 Buy Signal’, ‘1 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig1, 0), ‘1 Sell Signal’, ‘1 Bearish Change Detected’)
    plot(trend ? netLead1 : na, title=’Lead 1′, color=liColor1, linewidth=2)
    alertcondition(ta.crossover(sig2, 0), ‘2 Buy Signal’, ‘2 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig2, 0), ‘2 Sell Signal’, ‘2 Bearish Change Detected’)
    plot(trend ? netLead2 : na, title=’Lead 2′, color=liColor2, linewidth=2)
    alertcondition(ta.crossover(sig3, 0), ‘3 Buy Signal’, ‘3 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig3, 0), ‘3 Sell Signal’, ‘3 Bearish Change Detected’)
    plot(trend ? netLead3 : na, title=’Lead 3′, color=liColor3, linewidth=2)
    alertcondition(ta.crossover(sig4, 0), ‘4 Buy Signal’, ‘4 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig4, 0), ‘4 Sell Signal’, ‘4 Bearish Change Detected’)
    plot(trend ? netLead4 : na, title=’Lead 4′, color=liColor4, linewidth=2)
    alertcondition(ta.crossover(sig5, 0), ‘5 Buy Signal’, ‘5 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig5, 0), ‘5 Sell Signal’, ‘5 Bearish Change Detected’)
    plot(trend ? netLead5 : na, title=’Lead 5′, color=liColor5, linewidth=2)
    alertcondition(ta.crossover(sig6, 0), ‘6 Buy Signal’, ‘6 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig6, 0), ‘6 Sell Signal’, ‘6 Bearish Change Detected’)
    plot(trend ? netLead6 : na, title=’Lead 6′, color=liColor6, linewidth=2)
    alertcondition(ta.crossover(sig7, 0), ‘7 Buy Signal’, ‘7 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig7, 0), ‘7 Sell Signal’, ‘7 Bearish Change Detected’)
    plot(trend ? netLead7 : na, title=’Lead 7′, color=liColor7, linewidth=2)
    alertcondition(ta.crossover(sig8, 0), ‘8 Buy Signal’, ‘8 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig8, 0), ‘8 Sell Signal’, ‘8 Bearish Change Detected’)
    plot(trend ? netLead8 : na, title=’Lead 8′, color=liColor8, linewidth=2)
    alertcondition(ta.crossover(sig9, 0), ‘9 Buy Signal’, ‘9 Bullish Change Detected’)
    alertcondition(ta.crossunder(sig9, 0), ‘9 Sell Signal’, ‘9 Bearish Change Detected’)
    plot(trend ? netLead9 : na, title=’Lead 9′, color=liColor9, linewidth=2)
    elirating = sig0 + sig1 + sig2 + sig3 + sig4 + sig5 + sig6 + sig7 + sig8 + sig9
    sig = elirating > 0 ? elirating > nz(elirating[1]) ? 2 : 1 : elirating < 0 ? elirating < nz(elirating[1]) ? -2 : -1 : 0
    liColor = sig > 1 ? #a9ff77 : sig > 0 ? color.green : sig < -1 ? color.orange : sig < 0 ? color.red : color.gray
    trendcolor = (elirating > 5 ? #a9ff77 : elirating > 0 ? color.green : elirating < -5 ? color.orange : elirating < 0 ? color.red  : color.gray)
    colorxx = colormode ? liColor : trendcolor
    barcolor(bar ? colorxx : na)
    plot(trend ? na : elirating, title=’ELI Master Rating’, color=colorxx, linewidth=1)
    hline(trend ? na : 0, ‘dank1’)
    hline(trend ? na : 5, ‘dank2’, color.lime)
    hline(trend ? na : -5, ‘dank3’, color.orange)
    #239931 quote
    Iván González
    Moderator
    Master

    ici vous avez

    //-------------------------------------------//
    //PRC_Ehlers Leading Indicator
    //version = 0
    //04.11.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-------------------------------------------//
    //        Inputs
    //-------------------------------------------//
    src=customclose
    alpha01=0.03
    alpha02=0.06
    trend=1 
    //-------------------------------------------//
    //        Ema calculation
    //-------------------------------------------//
    if barindex<1 then
    ema=src
    else
    ema=0.5*src+0.5*ema[1]
    endif
    
    dd=(pow(1.4,0.05)+pow(1.3,0.05)+pow(1.2,0.05))/3
    //-------------------------------------------//
    //        NetLead0
    //-------------------------------------------//
    if barindex<1 then
    lead0=0
    netlead0=0
    else
    lead0=2*src+(alpha01*1-2)*src[1]+(1-alpha01*1)*lead0[1]
    netlead0=alpha02*10*lead0+(1-alpha02*10)*netlead0[1]
    endif
    
    if netlead0>ema then
    sig0=1
    r00=0
    g00=255
    else
    if netlead0<ema then
    sig0=-1
    r00=255
    g00=0
    else
    sig0=0
    r00=0
    g00=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead1
    //-------------------------------------------//
    if barindex<1 then
    lead1=0
    netlead1=0
    else
    lead1=2*src+(alpha01*2-2)*src[1]+(1-alpha01*2)*lead1[1]
    netlead1=alpha02*9*lead1+(1-alpha02*9)*netlead1[1]
    endif
    
    if netlead1>ema then
    sig1=1
    r01=0
    g01=255
    else
    if netlead1<ema then
    sig1=-1
    r01=255
    g01=0
    else
    sig1=0
    r01=0
    g01=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead2
    //-------------------------------------------//
    if barindex<1 then
    lead2=0
    netlead2=0
    else
    lead2=2*src+(alpha01*3-2)*src[1]+(1-alpha01*3)*lead2[1]
    netlead2=alpha02*8*lead2+(1-alpha02*8)*netlead2[1]
    endif
    
    if netlead2>ema then
    sig2=1
    r02=0
    g02=255
    else
    if netlead2<ema then
    sig2=-1
    r02=255
    g02=0
    else
    sig2=0
    r02=0
    g02=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead3
    //-------------------------------------------//
    if barindex<1 then
    lead3=0
    netlead3=0
    else
    lead3=2*src+(alpha01*4-2)*src[1]+(1-alpha01*4)*lead3[1]
    netlead3=alpha02*7*lead3+(1-alpha02*7)*netlead3[1]
    endif
    
    if netlead3>ema then
    sig3=1
    r03=0
    g03=255
    else
    if netlead3<ema then
    sig3=-1
    r03=255
    g03=0
    else
    sig3=0
    r03=0
    g03=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead4
    //-------------------------------------------//
    if barindex<1 then
    lead4=0
    netlead4=0
    else
    lead4=2*src+(alpha01*5-2)*src[1]+(1-alpha01*5)*lead4[1]
    netlead4=alpha02*6*lead4+(1-alpha02*6)*netlead4[1]
    endif
    
    if netlead4>ema then
    sig4=1
    r04=0
    g04=255
    else
    if netlead4<ema then
    sig4=-1
    r04=255
    g04=0
    else
    sig4=0
    r04=0
    g04=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead5
    //-------------------------------------------//
    if barindex<1 then
    lead5=0
    netlead5=0
    else
    lead5=2*src+(alpha01*6-2)*src[1]+(1-alpha01*6)*lead5[1]
    netlead5=alpha02*5*lead5+(1-alpha02*5)*netlead5[1]
    endif
    
    if netlead5>ema then
    sig5=1
    r05=0
    g05=255
    else
    if netlead5<ema then
    sig5=-1
    r05=255
    g05=0
    else
    sig5=0
    r05=0
    g05=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead6
    //-------------------------------------------//
    if barindex<1 then
    lead6=0
    netlead6=0
    else
    lead6=2*src+(alpha01*7-2)*src[1]+(1-alpha01*7)*lead6[1]
    netlead6=alpha02*4*lead6+(1-alpha02*4)*netlead6[1]
    endif
    
    if netlead6>ema then
    sig6=1
    r06=0
    g06=255
    else
    if netlead6<ema then
    sig6=-1
    r06=255
    g06=0
    else
    sig6=0
    r06=0
    g06=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead7
    //-------------------------------------------//
    if barindex<1 then
    lead7=0
    netlead7=0
    else
    lead7=2*src+(alpha01*8-2)*src[1]+(1-alpha01*8)*lead7[1]
    netlead7=alpha02*3*lead7+(1-alpha02*3)*netlead7[1]
    endif
    
    if netlead7>ema then
    sig7=1
    r07=0
    g07=255
    else
    if netlead7<ema then
    sig7=-1
    r07=255
    g07=0
    else
    sig7=0
    r07=0
    g07=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead8
    //-------------------------------------------//
    if barindex<1 then
    lead8=0
    netlead8=0
    else
    lead8=2*src+(alpha01*9-2)*src[1]+(1-alpha01*9)*lead8[1]
    netlead8=alpha02*2*lead8+(1-alpha02*2)*netlead8[1]
    endif
    
    if netlead8>ema then
    sig8=1
    r08=0
    g08=255
    else
    if netlead8<ema then
    sig8=-1
    r08=255
    g08=0
    else
    sig8=0
    r08=0
    g08=0
    endif
    endif
    //-------------------------------------------//
    //        NetLead9
    //-------------------------------------------//
    if barindex<1 then
    lead9=0
    netlead9=0
    else
    lead9=2*src+(alpha01*10-2)*src[1]+(1-alpha01*10)*lead9[1]
    netlead9=alpha02*1*lead9+(1-alpha02*1)*netlead9[1]
    endif
    
    if netlead9>ema then
    sig9=1
    r09=0
    g09=255
    else
    if netlead9<ema then
    sig9=-1
    r09=255
    g09=0
    else
    sig9=0
    r09=0
    g09=0
    endif
    endif
    //-------------------------------------------//
    //        ELI Master Rating
    //-------------------------------------------//
    elirating=sig0+sig1+sig2+sig3+sig4+sig5+sig6+sig7+sig8+sig9
    if elirating>0 then
    if elirating>elirating[1] then
    sig=2
    r=169
    g=255
    b=119
    else
    sig=1
    r=76
    g=175
    b=80
    endif
    else
    if elirating<0 then
    if elirating<elirating[1] then
    sig=-2
    r=255
    g=152
    b=0
    else
    sig=-1
    r=255
    g=82
    b=82
    endif
    else
    sig=0
    r=120
    g=123
    b=134
    endif
    endif
    //-------------------------------------------//
    //        Plot conditions
    //-------------------------------------------//
    if trend then
    mysig=undefined
    mylead0=netlead0
    mylead1=netlead1
    mylead2=netlead2
    mylead3=netlead3
    mylead4=netlead4
    mylead5=netlead5
    mylead6=netlead6
    mylead7=netlead7
    mylead8=netlead8
    mylead9=netlead9
    myema=ema
    else
    mysig=sig
    mylead0=undefined
    mylead1=undefined
    mylead2=undefined
    mylead3=undefined
    mylead4=undefined
    mylead5=undefined
    mylead6=undefined
    mylead7=undefined
    mylead8=undefined
    mylead9=undefined
    myema=undefined
    endif
    
    //-------------------------------------------//
    return mysig coloured(r,g,b),myema as "ema"coloured("black")style(line,1),mylead0 as "Lead0"coloured(r00,g00,0)style(line,2),mylead1 as "Lead1"coloured(r01,g01,0)style(line,2),mylead2 as "Lead2"coloured(r02,g02,0)style(line,2),mylead3 as "Lead3"coloured(r03,g03,0)style(line,2),mylead4 as "Lead4"coloured(r04,g04,0)style(line,2),mylead5 as "Lead5"coloured(r05,g05,0)style(line,2),mylead6 as "Lead6"coloured(r06,g06,0)style(line,2),mylead7 as "Lead7"coloured(r07,g07,0)style(line,2),mylead8 as "Lead8"coloured(r08,g08,0)style(line,2),mylead9 as "Lead9"coloured(r09,g09,0)style(line,2)
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Convention script tradingview


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
ahmdupuit @ahmdupuit Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
1 year, 3 months ago.

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