Zigzag Fibonacci Indicator transcript from Tradingview needed

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #234331 quote
    jowalz
    Participant
    New

    Hi everybody,

    I am familiar with coding (python, pinescript) and would like to start with prorealcode too.
    Nevertheless I struggle a bit with the specifics of prorealcode:-(

    So to kickstart, please could someone transcript the tradingview indicator to prorealcode?
    It shows very good the expected direction (see attached picture, green is the target direction) based on the fibonacci levels which are calculated with a different timeframe of 8 or 10 minutes on a 1 minute chart.

    Thanks in advance:-)

    …. pinescript code is as follows …

    // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    //@version=2
    study(“Z01 Indi”)
    //calc_on_every_tick=false
    useAltTF = input(true, title=’Use Alt Timeframe’)
    tf = input(‘8′, title=’Alt Timeframe’)
    zigzag() =>
    _isUp=close>=open
    _isDown=close<=open
    _direction=_isUp[1]and_isDown?-1:_isDown[1]and_isUp?1:nz(_direction[1])
    _zigzag=_isUp[1]and_isDownand_direction[1]!=-1?highest(2):_isDown[1]and_isUpand_direction[1]!=1?lowest(2):na
    _ticker = tickerid
    sz = useAltTF ? (change(time(tf)) != 0 ? security(_ticker, tf, zigzag()) : na) : zigzag()
    plot(sz, title=’zigzag’, color=lime, linewidth=2)
    x=valuewhen(sz,sz,4)
    a=valuewhen(sz,sz,3)
    b=valuewhen(sz,sz,2)
    c=valuewhen(sz,sz,1)
    d = valuewhen(sz, sz, 0)
    //————————————————————————————————————————————————————-
    fib_range = abs(d-c)
    fib_0000 = d > c ? d-(fib_range*0.000):d+(fib_range*0.000)
    fib_0236 = d > c ? d-(fib_range*0.236):d+(fib_range*0.236)
    fib_0382 = d > c ? d-(fib_range*0.382):d+(fib_range*0.382)
    fib_0500 = d > c ? d-(fib_range*0.500):d+(fib_range*0.500)
    fib_0618 = d > c ? d-(fib_range*0.618):d+(fib_range*0.618)
    fib_0764 = d > c ? d-(fib_range*0.764):d+(fib_range*0.764)
    fib_1000 = d > c ? d-(fib_range*1.000):d+(fib_range*1.000)
    plot(title=’Fib 0.000′, series=fib_0000, color=fib_0000 != fib_0000[1] ? na : black)
    plot(title=’Fib 0.236′, series=fib_0236, color=fib_0236 != fib_0236[1] ? na : red)
    plot(title=’Fib 0.382′, series=fib_0382, color=fib_0382 != fib_0382[1] ? na : olive)
    plot(title=’Fib 0.500′, series=fib_0500, color=fib_0500 != fib_0500[1] ? na : lime)
    plot(title=’Fib 0.618′, series=fib_0618, color=fib_0618 != fib_0618[1] ? na : teal)
    plot(title=’Fib 0.764′, series=fib_0764, color=fib_0764 != fib_0764[1] ? na : blue)
    plot(title=’Fib 1.000′, series=fib_1000, color=fib_1000 != fib_1000[1] ? na : black)
    #234366 quote
    Iván González
    Moderator
    Master

    Hi! Here you have a code similar to that one you are sharing.

    prd=15
    showpastFib=1
    showDN=1
    ShowUP=1
    
    atr=averagetruerange[14](close)
    
    if high=highest[prd](high) then
    ph=high
    phx=barindex
    else
    ph=0
    endif
    
    if low=lowest[prd](low) then
    pl=low
    plx=barindex
    else
    pl=0
    endif
    
    if ph and pl=0 then
    dir=1
    elsif pl and ph=0 then
    dir=-1
    else
    dir=dir
    endif
    
    dirchanged=dir<>dir[1]
    
    if ph or pl then
    if dirchanged then
    if dir=1 then
    $zigzag[t+1]=highest[prd](high)
    $zigzagidx[t+1]=barindex
    $dir[t+1]=1
    t=t+1
    else
    $zigzag[t+1]=lowest[prd](low)
    $zigzagidx[t+1]=barindex
    $dir[t+1]=-1
    t=t+1
    endif
    else
    if dir=1 and highest[prd](high)> $zigzag[t] then
    $zigzag[t]=highest[prd](high)
    $zigzagidx[t]=barindex
    elsif dir=-1 and lowest[prd](low)< $zigzag[t] then
    $zigzag[t]=lowest[prd](low)
    $zigzagidx[t]=barindex
    endif
    endif
    endif
    
    if islastbarupdate then
    
    drawsegment($zigzagidx[max(0,t-1)],$zigzag[max(0,t-1)],$zigzagidx[t],$zigzag[t])
    
    if $dir[t]=1 then
    
    fib0=$zigzag[max(0,t-1)]
    fib100=$zigzag[t]
    diff=fib100-fib0
    fib0236=fib100-diff*0.236
    fib0382=fib100-diff*0.382
    fib0500=fib100-diff*0.500
    fib0618=fib100-diff*0.618
    fib0786=fib100-diff*0.786
    drawsegment($zigzagidx[max(0,t-1)],fib0,barindex+10,fib0)style(line,2)coloured("grey")
    drawtext("Fib 0%",$zigzagidx[t],fib0+0.05*atr)
    drawsegment($zigzagidx[max(0,t-1)],fib0236,barindex+10,fib0236)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[max(0,t-1)],fib0382,barindex+10,fib0382)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[max(0,t-1)],fib0500,barindex+10,fib0500)style(dottedline,2)coloured("blue")
    drawtext("Fib 50%",$zigzagidx[t],fib0500+0.05*atr)
    drawsegment($zigzagidx[max(0,t-1)],fib0618,barindex+10,fib0618)style(dottedline,2)coloured("red")
    drawsegment($zigzagidx[max(0,t-1)],fib0786,barindex+10,fib0786)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[max(0,t-1)],fib100,barindex+10,fib100)style(line,2)coloured("grey")
    drawtext("Fib 100%",$zigzagidx[t],fib100+0.05*atr)
    
    elsif $dir[t]=-1 then
    
    fib0=$zigzag[t]
    fib100=$zigzag[max(0,t-1)]
    diff=fib100-fib0
    fib0236=fib0+diff*0.236
    fib0382=fib0+diff*0.382
    fib0500=fib0+diff*0.500
    fib0618=fib0+diff*0.618
    fib0786=fib0+diff*0.786
    drawsegment($zigzagidx[max(0,t-1)],fib0,barindex+10,fib0)style(line,2)coloured("grey")
    drawtext("Fib 0%",$zigzagidx[t],fib0+0.05*atr)
    drawsegment($zigzagidx[max(0,t-1)],fib0236,barindex+10,fib0236)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[max(0,t-1)],fib0382,barindex+10,fib0382)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[max(0,t-1)],fib0500,barindex+10,fib0500)style(dottedline,2)coloured("blue")
    drawtext("Fib 50%",$zigzagidx[max(0,t-1)],fib0500+0.05*atr)
    drawsegment($zigzagidx[max(0,t-1)],fib0618,barindex+10,fib0618)style(dottedline,2)coloured("red")
    drawsegment($zigzagidx[max(0,t-1)],fib0786,barindex+10,fib0786)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[max(0,t-1)],fib100,barindex+10,fib100)style(line,2)coloured("grey")
    drawtext("Fib 100%",$zigzagidx[t],fib100+0.05*atr)
    endif
    
    if showpastFib then
    for i=t-1 downto 1 do
    drawsegment($zigzagidx[max(0,i-1)],$zigzag[max(0,i-1)],$zigzagidx[i],$zigzag[i])
    
    if $dir[i]=1  and showDN then
    
    fib0=$zigzag[i-1]
    fib100=$zigzag[i]
    diff=fib100-fib0
    fib0236=fib100-diff*0.236
    fib0382=fib100-diff*0.382
    fib0500=fib100-diff*0.500
    fib0618=fib100-diff*0.618
    fib0786=fib100-diff*0.786
    drawsegment($zigzagidx[i-1],fib0,$zigzagidx[i+1],fib0)style(line,2)coloured("grey")
    drawtext("Fib 0%",$zigzagidx[i],fib0+0.05*atr)
    drawsegment($zigzagidx[i-1],fib0236,$zigzagidx[i+1],fib0236)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[i-1],fib0382,$zigzagidx[i+1],fib0382)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[i-1],fib0500,$zigzagidx[i+1],fib0500)style(dottedline,2)coloured("blue")
    drawtext("Fib 50%",$zigzagidx[i],fib0500+0.05*atr)
    drawsegment($zigzagidx[i-1],fib0618,$zigzagidx[i+1],fib0618)style(dottedline,2)coloured("red")
    drawsegment($zigzagidx[i-1],fib0786,$zigzagidx[i+1],fib0786)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[i-1],fib100,$zigzagidx[i+1],fib100)style(line,2)coloured("grey")
    drawtext("Fib 100%",$zigzagidx[i],fib100+0.05*atr)
    
    elsif $dir[i]=-1 and ShowUP then
    
    fib0=$zigzag[i]
    fib100=$zigzag[i-1]
    diff=fib100-fib0
    fib0236=fib0+diff*0.236
    fib0382=fib0+diff*0.382
    fib0500=fib0+diff*0.500
    fib0618=fib0+diff*0.618
    fib0786=fib0+diff*0.786
    drawsegment($zigzagidx[i-1],fib0,$zigzagidx[i+1],fib0)style(line,2)coloured("grey")
    drawtext("Fib 0%",$zigzagidx[i],fib0+0.05*atr)
    drawsegment($zigzagidx[i-1],fib0236,$zigzagidx[i+1],fib0236)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[i-1],fib0382,$zigzagidx[i+1],fib0382)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[i-1],fib0500,$zigzagidx[i+1],fib0500)style(dottedline,2)coloured("blue")
    drawtext("Fib 50%",$zigzagidx[i-1],fib0500+0.05*atr)
    drawsegment($zigzagidx[i-1],fib0618,$zigzagidx[i+1],fib0618)style(dottedline,2)coloured("red")
    drawsegment($zigzagidx[i-1],fib0786,$zigzagidx[i+1],fib0786)style(dottedline,1)coloured("grey")
    drawsegment($zigzagidx[i-1],fib100,$zigzagidx[i+1],fib100)style(line,2)coloured("grey")
    drawtext("Fib 100%",$zigzagidx[i],fib100+0.05*atr)
    
    endif
    
    next
    endif
    endif
    return
    
    #234429 quote
    jowalz
    Participant
    New

    thank’s Ivan … that helps much.

    I can work further on and adapt my specifics wishes or what I do have in trading view already setup.
    As you can see in the attached picture zigzag and fibonacci is a good combination to identify support and resistance levels and trading targets accordingly.

    After my summer holiday I will post my final result here and share with the community.

    Cheers Jo

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

Zigzag Fibonacci Indicator transcript from Tradingview needed


ProBuilder support

New Reply
Author
author-avatar
jowalz @jowalz Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by jowalz
1 year, 7 months ago.

Topic Details
Forum: ProBuilder support
Language: English
Started: 06/25/2024
Status: Active
Attachments: 2 files
Logo Logo
Loading...