Zigzag Fibonacci Indicator transcript from Tradingview needed
Forums › ProRealTime English forum › ProBuilder support › Zigzag Fibonacci Indicator transcript from Tradingview needed
- This topic has 2 replies, 2 voices, and was last updated 5 months ago by jowalz.
-
-
06/25/2024 at 11:18 AM #234331
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=2study(“Z01 Indi”)//calc_on_every_tick=falseuseAltTF = 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 = tickeridsz = 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)06/26/2024 at 12:06 PM #234366Hi! Here you have a code similar to that one you are sharing.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154prd=15showpastFib=1showDN=1ShowUP=1atr=averagetruerange[14](close)if high=highest[prd](high) thenph=highphx=barindexelseph=0endifif low=lowest[prd](low) thenpl=lowplx=barindexelsepl=0endifif ph and pl=0 thendir=1elsif pl and ph=0 thendir=-1elsedir=direndifdirchanged=dir<>dir[1]if ph or pl thenif dirchanged thenif dir=1 then$zigzag[t+1]=highest[prd](high)$zigzagidx[t+1]=barindex$dir[t+1]=1t=t+1else$zigzag[t+1]=lowest[prd](low)$zigzagidx[t+1]=barindex$dir[t+1]=-1t=t+1endifelseif dir=1 and highest[prd](high)> $zigzag[t] then$zigzag[t]=highest[prd](high)$zigzagidx[t]=barindexelsif dir=-1 and lowest[prd](low)< $zigzag[t] then$zigzag[t]=lowest[prd](low)$zigzagidx[t]=barindexendifendifendifif islastbarupdate thendrawsegment($zigzagidx[max(0,t-1)],$zigzag[max(0,t-1)],$zigzagidx[t],$zigzag[t])if $dir[t]=1 thenfib0=$zigzag[max(0,t-1)]fib100=$zigzag[t]diff=fib100-fib0fib0236=fib100-diff*0.236fib0382=fib100-diff*0.382fib0500=fib100-diff*0.500fib0618=fib100-diff*0.618fib0786=fib100-diff*0.786drawsegment($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 thenfib0=$zigzag[t]fib100=$zigzag[max(0,t-1)]diff=fib100-fib0fib0236=fib0+diff*0.236fib0382=fib0+diff*0.382fib0500=fib0+diff*0.500fib0618=fib0+diff*0.618fib0786=fib0+diff*0.786drawsegment($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)endifif showpastFib thenfor i=t-1 downto 1 dodrawsegment($zigzagidx[max(0,i-1)],$zigzag[max(0,i-1)],$zigzagidx[i],$zigzag[i])if $dir[i]=1 and showDN thenfib0=$zigzag[i-1]fib100=$zigzag[i]diff=fib100-fib0fib0236=fib100-diff*0.236fib0382=fib100-diff*0.382fib0500=fib100-diff*0.500fib0618=fib100-diff*0.618fib0786=fib100-diff*0.786drawsegment($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 thenfib0=$zigzag[i]fib100=$zigzag[i-1]diff=fib100-fib0fib0236=fib0+diff*0.236fib0382=fib0+diff*0.382fib0500=fib0+diff*0.500fib0618=fib0+diff*0.618fib0786=fib0+diff*0.786drawsegment($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)endifnextendifendifreturn06/27/2024 at 2:34 PM #234429thank’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
-
AuthorPosts
Find exclusive trading pro-tools on