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