Zigzag Fibonacci – an addition required

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #115653 quote
    Angus Thomson
    Participant
    Junior

    Hello troops,

    https://www.prorealcode.com/prorealtime-indicators/zigzag-fibonacci-levels/

    I was wondering if anyone could help modify this to add on -23.6 -36.2% -50% and so on

    It is of course an excellent indicator, although it could be more excellent.

    Thanks

    #115655 quote
    GraHal
    Participant
    Master

    The Fib levels you ask for above are already built-in to the Indicator … see the red arrowheads on attached.

    Angus.jpg Angus.jpg
    #115657 quote
    Vonasi
    Moderator
    Master

    I think Angus means negative values. So the 0% fib is at the top and the 100% fib is at the bottom. So after an upwards zigzag line the fib would be 0% down to 100% and after a downwards zigzag line the fib would be 0% up to 100%.

    Unfortunately I’m a bit too busy at the moment to have a go at it.

    #115663 quote
    GraHal
    Participant
    Master

    Ah right yeah gotcha … yes that would be a useful improvement.

    Cheers

    #115668 quote
    Vonasi
    Moderator
    Master

    I found five minutes and came up with this modification that I think does what you want. (Not tested very much!)

    //PRC_ZigZag Fibonacci levels | indicator
    //Modified by Vonasi 31122019 to return negative Fibonacci Levels
    //17.10.2018
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    //defparam drawonlastbaronly=true
    
    // --- settings
    //percent = 0.5
    //color:
    //r=255
    //g=255
    //b=0
    //DaysBefore = 20
    // --- end of settings
    
    zz = zigzag[percent](close)
    
    top = zz<zz[1] and zz[1]>zz[2]
    bot = zz>zz[1] and zz[1]<zz[2]
    
    if top then
    highlvl = high[1]
    startbartop = barindex[1]
    idate = date[1]
    endif
    if bot then
    lowlvl = low[1]
    startbarbot = barindex[1]
    idate = date[1]
    endif
    
    newtop = top<>top[1]
    newbot = bot<>bot[1]
    
    if newbot then
    fullrange = abs(highlvl-lowlvl)
    
    fibo236 = lowlvl+(fullrange*0.236)
    fibo382 = lowlvl+(fullrange*0.382)
    fibo50 = lowlvl+fullrange/2
    fibo618 = lowlvl+(fullrange*0.618)
    startbar = min(startbartop,startbarbot)
    titlea = 100
    titleb = 0
    endif
    
    if newtop then
    fullrange = abs(highlvl-lowlvl)
    
    fibo236 = highlvl-(fullrange*0.236)
    fibo382 = highlvl-(fullrange*0.382)
    fibo50 = highlvl-fullrange/2
    fibo618 = highlvl-(fullrange*0.618)
    startbar = min(startbartop,startbarbot)
    titlea = 0
    titleb = 100
    endif
    //plot fibonacci levels
    if startbar<>lastplot and today-idate<DaysBefore then
    drawsegment(startbar,highlvl,barindex,highlvl) coloured(r,g,b)
    drawtext("          #titlea#%",barindex,highlvl,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,lowlvl,barindex,lowlvl) coloured(r,g,b)
    drawtext("          #titleb#%",barindex,lowlvl,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo236,barindex,fibo236) coloured(r,g,b)
    drawtext("          23.6%",barindex,fibo236,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo382,barindex,fibo382) coloured(r,g,b)
    drawtext("          38.2%",barindex,fibo382,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo50,barindex,fibo50) coloured(r,g,b)
    drawtext("          50%",barindex,fibo50,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo618,barindex,fibo618) coloured(r,g,b)
    drawtext("          61.8%",barindex,fibo618,Dialog,Standard,10) coloured(r,g,b)
    lastplot = startbar
    endif
    
    return
    
    ZigZag-Fibonacci-levels-v2.itf
    #115670 quote
    GraHal
    Participant
    Master

    Grand Job! Works a Treat!

    Thank You Vonasi
    Happy New Year

    #115671 quote
    Vonasi
    Moderator
    Master

    Happy New Year to you too GraHal!

    #115869 quote
    Angus Thomson
    Participant
    Junior

    I was hoping for something more like the attached

    Fibo.png Fibo.png
    #115893 quote
    Vonasi
    Moderator
    Master

    That was a wasted five minutes that I’ll never get back again then!

    #115894 quote
    Angus Thomson
    Participant
    Junior

    Not being funny but all you did was make the font smaller and the line less thick

    Have another go please

    #115899 quote
    Vonasi
    Moderator
    Master

    Not being funny but all I did was read your poor description of what you wanted which even GraHal didn’t understand and then code something that I thought you wanted. My code does what I described in my second post so it is far more than just a font size change. I changed the font size only because the large size was ugly.

    Perhaps a thanks instead of an insult would be more of an incentive to assist further.

    #115900 quote
    GraHal
    Participant
    Master

    Not being funny but all you did was make the font smaller and the line less thick

    Vonasi changed the Indicator so that …

    • from a Top we can see / read the % Fib retrace down from the Top.
    • from a Bottom we see / read the % Fib retrace up from the Bottom.
    #115930 quote
    Vonasi
    Moderator
    Master

    Here you go. This one not only inverts the fibs but draws your negative value fibs too. Another five minutes of life I won’t get back as they are pretty pointless because price never gets into the negative because if it does then the ZigZag redraws and so does our indicator as we no longer have a new bottom or a new top!

    I didn’t waste too much time on it so not really tested and you might find the odd bug.

    //PRC_ZigZag Fibonacci levels | indicator
    //Modified by Vonasi 05012019 to return negative Fibonacci Levels v2
    //17.10.2018
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    //defparam drawonlastbaronly=true
    
    // --- settings
    //percent = 0.5
    //color:
    //r=255
    //g=255
    //b=0
    //DaysBefore = 20
    // --- end of settings
    
    zz = zigzag[percent](close)
    
    top = zz<zz[1] and zz[1]>zz[2]
    bot = zz>zz[1] and zz[1]<zz[2]
    
    if top then
    highlvl = high[1]
    startbartop = barindex[1]
    idate = date[1]
    endif
    if bot then
    lowlvl = low[1]
    startbarbot = barindex[1]
    idate = date[1]
    endif
    
    newtop = top<>top[1]
    newbot = bot<>bot[1]
    
    if newbot then
    fullrange = abs(highlvl-lowlvl)
    
    fibo0 = lowlvl
    fibo236 = lowlvl+(fullrange*0.236)
    fibo382 = lowlvl+(fullrange*0.382)
    fibo50 = lowlvl+fullrange/2
    fibo618 = lowlvl+(fullrange*0.618)
    fibo100 = lowlvl+fullrange 
    
    fibo236n = lowlvl-(fullrange*0.236)
    fibo382n = lowlvl-(fullrange*0.382)
    fibo50n = lowlvl-fullrange/2
    fibo618n = lowlvl-(fullrange*0.618)
    fibo100n = lowlvl-fullrange
    
    startbar = min(startbartop,startbarbot)
    endif
    
    if newtop then
    fullrange = abs(highlvl-lowlvl)
    
    fibo0 = highlvl
    fibo236 = highlvl-(fullrange*0.236)
    fibo382 = highlvl-(fullrange*0.382)
    fibo50 = highlvl-fullrange/2
    fibo618 = highlvl-(fullrange*0.618)
    fibo100 = highlvl-fullrange
    
    fibo236n = highlvl+(fullrange*0.236)
    fibo382n = highlvl+(fullrange*0.382)
    fibo50n = highlvl+fullrange/2
    fibo618n = highlvl+(fullrange*0.618)
    fibo100n = highlvl+fullrange
    
    startbar = min(startbartop,startbarbot)
    endif
    //plot fibonacci levels
    if startbar<>lastplot and today-idate<DaysBefore then
    drawsegment(startbar,fibo0,barindex,fibo0) coloured(r,g,b)
    drawtext("               0%",barindex,fibo0,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo100,barindex,fibo100) coloured(r,g,b)
    drawtext("               +100%",barindex,fibo100,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo100n,barindex,fibo100n) coloured(r,g,b)
    drawtext("               -100%",barindex,fibo100n,Dialog,Standard,10) coloured(r,g,b)
    
    drawsegment(startbar,fibo236,barindex,fibo236) coloured(r,g,b)
    drawtext("               +23.6%",barindex,fibo236,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo382,barindex,fibo382) coloured(r,g,b)
    drawtext("               +38.2%",barindex,fibo382,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo50,barindex,fibo50) coloured(r,g,b)
    drawtext("               +50%",barindex,fibo50,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo618,barindex,fibo618) coloured(r,g,b)
    drawtext("               +61.8%",barindex,fibo618,Dialog,Standard,10) coloured(r,g,b)
    
    drawsegment(startbar,fibo236n,barindex,fibo236n) coloured(r,g,b)
    drawtext("               -23.6%",barindex,fibo236n,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo382n,barindex,fibo382n) coloured(r,g,b)
    drawtext("               -38.2%",barindex,fibo382n,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo50n,barindex,fibo50n) coloured(r,g,b)
    drawtext("               -50%",barindex,fibo50n,Dialog,Standard,10) coloured(r,g,b)
    drawsegment(startbar,fibo618n,barindex,fibo618n) coloured(r,g,b)
    drawtext("               -61.8%",barindex,fibo618n,Dialog,Standard,10) coloured(r,g,b)
    lastplot = startbar
    endif
    
    return
    Angus Thomson thanked this post
    PRC_ZigZag-Fibonacci-levels-v3.itf Screenshot_1-1.png Screenshot_1-1.png
    #116054 quote
    Angus Thomson
    Participant
    Junior

    Thank you Vonasi I appreciate your hard work and I apologise for the poor description, please don’t feel like what you did was pointless.

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

Zigzag Fibonacci – an addition required


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 13 replies,
has 3 voices, and was last updated by Angus Thomson
6 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/31/2019
Status: Active
Attachments: 5 files
Logo Logo
Loading...