Simrido + Adx

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #53094 quote
    bolsatrilera
    Participant
    Master

    Estoy intentando adaptar este código de la plataforma Tradingview de un indicador llamado Simrido + Adx : https://es.tradingview.com/script/h2SKGE0d/

    Tengo desarrollado esto:

    REM SIMRIDO+ADX
    //@version=3
    
    lensimrido= 14
    
    rise = 0
    for i=0 to lensimrido-1 do
    if typicalprice[i] > typicalprice[i+1] then
    rise=rise+1
    endif
    next
    
    srd = rise/lensimrido*100
    
    len = 14
    th  = 20
    
    TrueRange = max(max(high-low, abs(high-(close[1]))), abs(low-(close[1])))
    
    if DirectionalMovementPlus then
    DirectionalMovementPlus= high-(high[1])>(low[1])-low
    elsif DirectionalMovementPlus=max(high-(high[1]),0) then
    DirectionalMovementPlus=0
    endif
    
    if DirectionalMovementMinus then
    DirectionalMovementMinus = (low[1])-low > high-(high[1])
    elsif DirectionalMovementMinus= max((low[1])-low, 0) then
    DirectionalMovementMinus=0
    endif
    
    SmoothedTrueRange=close*0
    SmoothedTrueRange= (SmoothedTrueRange[1]) - ((SmoothedTrueRange[1])/len) + TrueRange
    SmoothedDirectionalMovementPlus=close*0
    SmoothedDirectionalMovementPlus =(SmoothedDirectionalMovementPlus[1])-((SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
    SmoothedDirectionalMovementMinus=close*0
    SmoothedDirectionalMovementMinus=(SmoothedDirectionalMovementMinus[1])-((SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
    
    DPlus = (SmoothedDirectionalMovementPlus / SmoothedTrueRange) * 100
    DMinus = (SmoothedDirectionalMovementMinus / SmoothedTrueRange)* 100
    DX = abs((DPlus-DMinus / DPlus+DMinus))*100
    AD =average[len](DX)
    
    
    
    
    return srd coloured(0,0,255)as "simrido",AD coloured(255,0,0)as "adx", th style(dottedline)as "20",50 as "50"
    
    ibex.png ibex.png
    #53096 quote
    bolsatrilera
    Participant
    Master

    Como veís, la linea roja ( adx) no me sale y es lo que falta

    #191589 quote
    Fr7
    Participant
    Master

    Hola, he intentado arreglarlo pero sigue si funcionar…¿Alguien sabe qué está mal?

    lensimrido= 14
    rise = 0
    for i=0 to lensimrido-1 do
    if typicalprice[i] > typicalprice[i+1] then
    rise=rise+1
    endif
    next
     
    srd = rise/lensimrido*100
     
    len = 14
    th  = 20
     
    TrueRange = max(max(high-low, abs(high-(close[1]))), abs(low-(close[1])))
    
    if high-(high[1])>(low[1])-low then
    DirectionalMovementPlus=max(high-(high[1]),0)
    else
    DirectionalMovementPlus=0
    endif
    
    if  (low[1])-low > high-(high[1]) then
    DirectionalMovementMinus=max((low[1])-low, 0)
    else
    DirectionalMovementMinus=0
    endif
     
     
    SmoothedTrueRange=close*0
    SmoothedTrueRange= (SmoothedTrueRange[1]) - ((SmoothedTrueRange[1])/len) + TrueRange
    SmoothedDirectionalMovementPlus=close*0
    SmoothedDirectionalMovementPlus =(SmoothedDirectionalMovementPlus[1])-((SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
    SmoothedDirectionalMovementMinus=close*0
    SmoothedDirectionalMovementMinus=(SmoothedDirectionalMovementMinus[1])-((SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
     
    DPlus = (SmoothedDirectionalMovementPlus / SmoothedTrueRange) * 100
    DMinus = (SmoothedDirectionalMovementMinus / SmoothedTrueRange)* 100
    DX = abs((DPlus-DMinus / DPlus+DMinus))*100
    AD =average[len](DX)
    return srd coloured(0,0,255)as "simrido",AD coloured(255,0,0)as "adx", th style(dottedline)as "20",50 as "50"
     
    
    #191594 quote
    Fr7
    Participant
    Master

    Este es el código original:

    //@version=3
    study("simrido")
    len_simrido = input(14)
    
    rise = 0
    for i=0 to len_simrido-1
        if hlc3[i] > hlc3[i+1]
            rise:=rise+1
    srd = rise/len_simrido*100
    
    len = input(title="Length", type=integer, defval=14)
    th = input(title="threshold", type=integer, defval=20)
    
    TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
    DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
    DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
    
    SmoothedTrueRange=close*0
    SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
    SmoothedDirectionalMovementPlus=close*0
    SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
    SmoothedDirectionalMovementMinus=close*0
    SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
    
    DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
    DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
    DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
    ADX = sma(DX, len)
    
    dis = srd-ADX
    
    plot(srd, "simrido", color=blue, style=area, histbase=50, transp=50)
    plot(ADX, "ADX", color=red)
    hline(th, "th", color=black, linestyle=dashed)
    //plot(dis, "dis", color=#80008030, style=area, histbase=th)//, transp=10)
    //plot((dis+th)/2, "dis", color=black, linewidth=4, transp=20)
    //hline(50, color=black, linestyle=dashed)
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Simrido + Adx


ProBuilder: Indicadores y Herramientas

New Reply
Author
Summary

This topic contains 3 replies,
has 1 voice, and was last updated by Fr7
3 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 11/17/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...