Donchian Channel – Pivot High-Low

Forums ProRealTime English forum ProBuilder support Donchian Channel – Pivot High-Low

Viewing 3 posts - 1 through 3 (of 3 total)
  • #168898

    //@version=4
    study(“Donchian Channel – Pivot High-Low”, overlay=true)
    pvtLenR = input(4)
    pvtLenL = input(2)
    waitforclose = input(true)
    ShowHHLL = input(true)
    DCBase = input(title=”Channel Base”, defval=”Combined”, options=[“Price”, “Pivots”, “Combined”])
    DCLength = input(20)
    showChannel = input(true)
    donchian(highSource, lowSource, rangeLength)=>
    top = highest(highSource, rangeLength)
    bottom = lowest(lowSource, rangeLength)
    middle = (top+bottom)/2
    [middle, top, bottom]

    f_calculatePivots(Shunt)=>
    pvthi_ = pivothigh(high, pvtLenL, pvtLenR)
    pvtlo_ = pivotlow(low, pvtLenL, pvtLenR)

    pvthi = pvthi_[Shunt]
    pvtlo = pvtlo_[Shunt]

    pvthighline = pvthi
    pvthighline := na(pvthighline)? nz(pvthighline[1]): pvthighline

    pvtlowline = pvtlo
    pvtlowline := na(pvtlowline)? nz(pvtlowline[1]): pvtlowline

    higherhigh = na(pvthi) ? na : ( valuewhen(pvthi, high[pvtLenR+Shunt], 1) < valuewhen(pvthi, high[pvtLenR+Shunt], 0) ) ? pvthi : na
    lowerhigh = na(pvthi) ? na : ( valuewhen(pvthi, high[pvtLenR+Shunt], 1) > valuewhen(pvthi, high[pvtLenR+Shunt], 0) ) ? pvthi : na
    higherlow = na(pvtlo) ? na : ( valuewhen(pvtlo, low[pvtLenR+Shunt], 1) < valuewhen(pvtlo, low[pvtLenR+Shunt], 0) ) ? pvtlo : na
    lowerlow = na(pvtlo) ? na : ( valuewhen(pvtlo, low[pvtLenR+Shunt], 1) > valuewhen(pvtlo, low[pvtLenR+Shunt], 0) ) ? pvtlo : na

    [pvthighline, pvtlowline, higherhigh, lowerhigh, higherlow, lowerlow]

    Shunt = waitforclose? 1 : 0
    [pvthighline, pvtlowline, higherhigh, lowerhigh, higherlow, lowerlow] = f_calculatePivots(Shunt)

    [middleP, topP, bottomP] = donchian(pvthighline, pvtlowline, DCLength)
    [middleC, topC, bottomC] = donchian(high, low, DCLength)

    top = DCBase == “Combined”? max(topP,topC) : DCBase == “Pivots” ? topP : topC
    bottom = DCBase == “Combined”? min(bottomP,bottomC) : DCBase == “Pivots” ? bottomP : bottomC
    middle = DCBase == “Combined”? (middleP+middleC)/2 : DCBase == “Pivots” ? middleP : middleC

    //plotshape(ShowHHLL ? higherhigh : na, title=’HH’, style=shape.triangleup, location=location.abovebar, color=color.green, text=”HH”, offset=-pvtLenR-Shunt, transp=50)
    //plotshape(ShowHHLL ? higherlow : na, title=’HL’, style=shape.triangleup, location=location.belowbar, color=color.green, text=”HL”, offset=-pvtLenR-Shunt, transp=0)
    //plotshape(ShowHHLL ? lowerhigh : na, title=’LH’, style=shape.triangledown, location=location.abovebar, color=color.maroon, text=”LH”, offset=-pvtLenR-Shunt, transp=0)
    //plotshape(ShowHHLL ? lowerlow : na, title=’LL’, style=shape.triangledown, location=location.belowbar, color=color.maroon, text=”LL”, offset=-pvtLenR-Shunt, transp=50)

    BBup = plot(showChannel ? top: na, title=”Top”, color=color.red, linewidth=1, transp=50, style=plot.style_linebr)
    BBdown = plot(showChannel ? bottom: na, title=”Bottom”, color=color.green, linewidth=1, transp=50, style=plot.style_linebr)
    BBmid = plot(showChannel ? middle: na, title=”Middle”, color=color.blue, linewidth=1, transp=50, style=plot.style_linebr)
    fill(BBup, BBmid, title=”High Zone”, color=color.green, transp=90)
    fill(BBdown, BBmid, title=”Low Zone”, color=color.red, transp=90)

    #168905

    Bonjour, on va supposer, en l’absence de texte, que ce n’était pas un simple partage de code dans un autre langage mais que tu as besoin d’une conversion de code vers PRT? Si tel est le cas, il faut respecter la checklist du formulaire de conversion et fournir tout ce qui manque (description en texte de ce que fait l’indicateur, captures écrans pour le rendu visuel de l’indicateur, etc…), voir lien de demande de conversion: https://www.prorealcode.com/free-code-conversion/

    #168943

    Un petit effort de politesse et on pourra t’aider 😉

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

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