Display Line Name of Fibonacci Lines
Forums › ProRealTime English forum › ProBuilder support › Display Line Name of Fibonacci Lines
- This topic has 23 replies, 4 voices, and was last updated 4 years ago by Vonasi.
-
-
05/28/2020 at 6:47 AM #133541
Hello,
I have written the code for previous day Fibonacci levels however can you please let me know how to put the “name tag” (as PRT does for Pivot lines) on top of the lines, e.g. it should write “1.618” on top of the line left justified.
Many thanks.
05/28/2020 at 7:08 AM #133544Sorry for double post since in the first instance I got WordPress Error.
When I am adding the below code then 1.618 is coming across the entire line repeatedly as enclosed.
12voff=5*pipsizeDRAWTEXT("1.618", barindex,r11+voff, Dialog , Bold, 10) COLOURED(255,255,0)05/28/2020 at 7:56 AM #133549If you ask it to draw at the close of every bar then that is what it will do!
Try enclosing the DRAWTEXT in an IF THEN so that it only draws when the value changes:
1234if r11 <> r11[1] thenvoff=5*pipsizeDRAWTEXT(“1.618”, barindex,r11+voff, Dialog , Bold, 10) COLOURED(255,255,0)endifNote: Always use the ‘Insert PRT Code’ button when putting code in your posts – even if it is only a couple of lines of code as it makes it far easier for others to read. We like a tidy forum. I have edited your post.
05/29/2020 at 3:47 AM #133694Thank you Vonasi, however for some strange reason, the enclosed code is not printing the text.
Can you throw some light to it please?
Regards
Fibonacci Support/ Resistance123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125D=DayOfWeekif (D=2 or D=3 or D=4 or D=5) thenH1=DHigh(1)elsif (D=1) thenH1=DHigh(1)endifif (D=2 or D=3 or D=4 or D=5) thenL1=DLow(1)elsif (D=1) thenL1=DLow(1)endifif (D=2 or D=3 or D=4 or D=5) thenC1=DClose(1)elsif D=1 thenC1=DClose(2)endifif (D=2 or D=3 or D=4 or D=5) thenO=DOpen(0)elsif D=1 thenO=DOpen(1)endifr=h1-l1R236=L1+R*0.236R382=L1+R*0.382R50=L1+R*0.5r6=l1+r*0.618r7=l1+r*.786r1=l1+r*1.272r11=l1+r*1.618R22=L1+R*2R2618=L1+R*2.618R33=L1+R*3.33DH=H1-r*1DL=H1-r*0Lr1=H1-r*1.272L11=H1-r*1.618L22=H1-R*2L2618=H1-R*2.618L33=H1-R*3.33WPH=(H1+L1+C1)*2/3-H1WPL=(H1+L1+C1)*2/3-L1P=H1+L1+C1if O>C1 thenX=(P+H1)/2elsif O<C1 thenX=(P+L1)/2elsif O=C1 thenX=(P+C1)/2endifDPH=X-L1DPL=X-H1IF R11<>R11[1] THENvoff=5*pipsizeDRAWTEXT("1.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R236<>R236[1] THENvoff=5*pipsizeDRAWTEXT("0.236", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R382<>R382[1] THENvoff=5*pipsizeDRAWTEXT("0.382", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R50<>R50[1] THENvoff=5*pipsizeDRAWTEXT("0.5", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R6<>R6[1] THENvoff=5*pipsizeDRAWTEXT("0.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R7<>R7[1] THENvoff=5*pipsizeDRAWTEXT("0.786", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R1<>R1[1] THENvoff=5*pipsizeDRAWTEXT("1.272", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R22<>R22[1] THENvoff=5*pipsizeDRAWTEXT("2.0", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R2618<>R2618[1] THENvoff=5*pipsizeDRAWTEXT("2.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF R33<>R33[1] THENvoff=5*pipsizeDRAWTEXT("3.33", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF DH<>DH[1] THENvoff=5*pipsizeDRAWTEXT("DH", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ELSIF DL<>DL[1] THENvoff=5*pipsizeDRAWTEXT("DL", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF LR1<>LR1[1] THENvoff=5*pipsizeDRAWTEXT(" - 1.272", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L11<>L11[1] THENvoff=5*pipsizeDRAWTEXT(" - 1.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L22<>L22[1] THENvoff=5*pipsizeDRAWTEXT(" - 2.0", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L2618<>L2618[1] THENvoff=5*pipsizeDRAWTEXT(" - 2.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L33<>L33[1] THENvoff=5*pipsizeDRAWTEXT(" - 3.33", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF DPH<>DPH[1] THENvoff=5*pipsizeDRAWTEXT("DPRH", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF DPL<>DPL[1] THENvoff=5*pipsizeDRAWTEXT("DPRL", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF WPH<>WPH[1] THENvoff=5*pipsizeDRAWTEXT("WPRH", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF WPL<>WPL[1] THENvoff=5*pipsizeDRAWTEXT("WPRL", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFRETURN WPH AS "WPRH", DPH AS "DPRH", WPL AS "WPRL", DPL AS "DPRL", R236 AS "0.236", R382 AS "0.382", R50 AS "0.5", r6 as "0.618", r7 as "0.786", r1 as "1.272", r11 as "1.618", R22 AS "2", R2618 AS "2.618", R33 AS "3.33", LR1 AS "-1.272", L11 AS "-1.618", L22 AS "-2", L2618 AS "-2.618", L33 AS "-3.33", DH AS "DL", DL AS "DH"05/29/2020 at 5:50 AM #13369805/29/2020 at 5:54 AM #133700Display Line Code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136D=DayOfWeekif (D=2 or D=3 or D=4 or D=5) thenH1=DHigh(1)elsif (D=1) thenH1=DHigh(1)endifif (D=2 or D=3 or D=4 or D=5) thenL1=DLow(1)elsif (D=1) thenL1=DLow(1)endifif (D=2 or D=3 or D=4 or D=5) thenC1=DClose(1)elsif D=1 thenC1=DClose(2)endifif (D=2 or D=3 or D=4 or D=5) thenO=DOpen(0)elsif D=1 thenO=DOpen(1)endifr=h1-l1R236=L1+R*0.236R382=L1+R*0.382R50=L1+R*0.5r6=l1+r*0.618r7=l1+r*.786r1=l1+r*1.272r11=l1+r*1.618R22=L1+R*2R2618=L1+R*2.618R33=L1+R*3.33DH=H1-r*1DL=H1-r*0Lr1=H1-r*1.272L11=H1-r*1.618L22=H1-R*2L2618=H1-R*2.618L33=H1-R*3.33WPH=(H1+L1+C1)*2/3-H1WPL=(H1+L1+C1)*2/3-L1P=H1+L1+C1if O>C1 thenX=(P+H1)/2elsif O<C1 thenX=(P+L1)/2elsif O=C1 thenX=(P+C1)/2endifDPH=X-L1DPL=X-H1IF R11<>R11[1] THENvoff=5*pipsizeDRAWTEXT("1.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R236<>R236[1] THENvoff=5*pipsizeDRAWTEXT("0.236", barindex,r236+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R382<>R382[1] THENvoff=5*pipsizeDRAWTEXT("0.382", barindex,r382+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R50<>R50[1] THENvoff=5*pipsizeDRAWTEXT("0.5", barindex,r50+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R6<>R6[1] THENvoff=5*pipsizeDRAWTEXT("0.618", barindex,r6+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIF R7<>R7[1] THENvoff=5*pipsizeDRAWTEXT("0.786", barindex,r7+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R1<>R1[1] THENvoff=5*pipsizeDRAWTEXT("1.272", barindex,r1+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R22<>R22[1] THENvoff=5*pipsizeDRAWTEXT("2.0", barindex,r22+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R2618<>R2618[1] THENvoff=5*pipsizeDRAWTEXT("2.618", barindex,r2618+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf R33<>R33[1] THENvoff=5*pipsizeDRAWTEXT("3.33", barindex,r33+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf DH<>DH[1] THENvoff=5*pipsizeDRAWTEXT("DH", barindex,DH+voff, Dialog , Bold, 18) COLOURED(255,255,0)endifIf DL<>DL[1] THENvoff=5*pipsizeDRAWTEXT("DL", barindex,DL+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF LR1<>LR1[1] THENvoff=5*pipsizeDRAWTEXT(" - 1.272", barindex,LR1+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L11<>L11[1] THENvoff=5*pipsizeDRAWTEXT(" - 1.618", barindex,L11+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L22<>L22[1] THENvoff=5*pipsizeDRAWTEXT(" - 2.0", barindex,L22+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L2618<>L2618[1] THENvoff=5*pipsizeDRAWTEXT(" - 2.618", barindex,L2618+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF L33<>L33[1] THENvoff=5*pipsizeDRAWTEXT(" - 3.33", barindex,L33+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF DPH<>DPH[1] THENvoff=5*pipsizeDRAWTEXT("DPRH", barindex,DPH+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF DPL<>DPL[1] THENvoff=5*pipsizeDRAWTEXT("DPRL", barindex,DPL+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF WPH<>WPH[1] THENvoff=5*pipsizeDRAWTEXT("WPRH", barindex,WPH+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFIF WPL<>WPL[1] THENvoff=5*pipsizeDRAWTEXT("WPRL", barindex,WPL+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFRETURN WPH AS "WPRH", DPH AS "DPRH", WPL AS "WPRL", DPL AS "DPRL", R236 AS "0.236", R382 AS "0.382", R50 AS "0.5", r6 as "0.618", r7 as "0.786", r1 as "1.272", r11 as "1.618", R22 AS "2", R2618 AS "2.618", R33 AS "3.33", LR1 AS "-1.272", L11 AS "-1.618", L22 AS "-2", L2618 AS "-2.618", L33 AS "-3.33", DH AS "DL", DL AS "DH"05/29/2020 at 7:12 AM #133708Apart from the text drawing y value that Razz corrected and the ELSIFs that should have been ENDIFs there is an awful lot of code that is not needs that really slows down the calculation time. Plus you only need to do the calculations once when the day changes.
Here is the code tidied up:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172D=openDayOfWeekif d <> d[1] thenif (D=2 or D=3 or D=4 or D=5) thenH1=DHigh(1)L1=DLow(1)C1=DClose(1)O=DOpen(0)elsif (D=1) thenH1=DHigh(1)L1=DLow(1)C1=DClose(2)O=DOpen(1)endifr=h1-l1R236=L1+R*0.236R382=L1+R*0.382R50=L1+R*0.5r6=l1+r*0.618r7=l1+r*.786r1=l1+r*1.272r11=l1+r*1.618R22=L1+R*2R2618=L1+R*2.618R33=L1+R*3.33DH=H1-r*1DL=H1-r*0Lr1=H1-r*1.272L11=H1-r*1.618L22=H1-R*2L2618=H1-R*2.618L33=H1-R*3.33WPH=(H1+L1+C1)*2/3-H1WPL=(H1+L1+C1)*2/3-L1P=H1+L1+C1if O>C1 thenX=(P+H1)/2elsif O<C1 thenX=(P+L1)/2elsif O=C1 thenX=(P+C1)/2endifDPH=X-L1DPL=X-H1voff=5*pipsizeDRAWTEXT("1.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.236", barindex,r236+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.382", barindex,r382+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.5", barindex,r50+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.618", barindex,r6+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.786", barindex,r7+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("1.272", barindex,r1+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("2.0", barindex,r22+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("2.618", barindex,r2618+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("3.33", barindex,r33+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DH", barindex,DH+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DL", barindex,DL+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 1.272", barindex,LR1+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 1.618", barindex,L11+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 2.0", barindex,L22+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 2.618", barindex,L2618+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 3.33", barindex,L33+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DPRH", barindex,DPH+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DPRL", barindex,DPL+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("WPRH", barindex,WPH+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("WPRL", barindex,WPL+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFRETURN WPH AS "WPRH", DPH AS "DPRH", WPL AS "WPRL", DPL AS "DPRL", R236 AS "0.236", R382 AS "0.382", R50 AS "0.5", r6 as "0.618", r7 as "0.786", r1 as "1.272", r11 as "1.618", R22 AS "2", R2618 AS "2.618", R33 AS "3.33", LR1 AS "-1.272", L11 AS "-1.618", L22 AS "-2", L2618 AS "-2.618", L33 AS "-3.33", DH AS "DL", DL AS "DH"05/29/2020 at 7:26 AM #133711Also I’m not sure what you are trying to achieve with the first bit of code that sets the O H L C values. If it is to include Sunday data in with Monday data then you need to do it like this:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172D=openDayOfWeekif d <> d[1] thenif (D=2 or D=3 or D=4 or D=5) thenH1=DHigh(1)L1=DLow(1)C1=DClose(1)O=DOpen(1)elsif (D=1) thenH1=max(DHigh(1),dHigh(2))L1=min(DLow(1),dLow(2))C1=DClose(1)O=DOpen(2)endifr=h1-l1R236=L1+R*0.236R382=L1+R*0.382R50=L1+R*0.5r6=l1+r*0.618r7=l1+r*.786r1=l1+r*1.272r11=l1+r*1.618R22=L1+R*2R2618=L1+R*2.618R33=L1+R*3.33DH=H1-r*1DL=H1-r*0Lr1=H1-r*1.272L11=H1-r*1.618L22=H1-R*2L2618=H1-R*2.618L33=H1-R*3.33WPH=(H1+L1+C1)*2/3-H1WPL=(H1+L1+C1)*2/3-L1P=H1+L1+C1if O>C1 thenX=(P+H1)/2elsif O<C1 thenX=(P+L1)/2elsif O=C1 thenX=(P+C1)/2endifDPH=X-L1DPL=X-H1voff=5*pipsizeDRAWTEXT("1.618", barindex,r11+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.236", barindex,r236+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.382", barindex,r382+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.5", barindex,r50+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.618", barindex,r6+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("0.786", barindex,r7+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("1.272", barindex,r1+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("2.0", barindex,r22+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("2.618", barindex,r2618+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("3.33", barindex,r33+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DH", barindex,DH+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DL", barindex,DL+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 1.272", barindex,LR1+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 1.618", barindex,L11+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 2.0", barindex,L22+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 2.618", barindex,L2618+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT(" - 3.33", barindex,L33+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DPRH", barindex,DPH+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("DPRL", barindex,DPL+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("WPRH", barindex,WPH+voff, Dialog , Bold, 18) COLOURED(255,255,0)DRAWTEXT("WPRL", barindex,WPL+voff, Dialog , Bold, 18) COLOURED(255,255,0)ENDIFRETURN WPH AS "WPRH", DPH AS "DPRH", WPL AS "WPRL", DPL AS "DPRL", R236 AS "0.236", R382 AS "0.382", R50 AS "0.5", r6 as "0.618", r7 as "0.786", r1 as "1.272", r11 as "1.618", R22 AS "2", R2618 AS "2.618", R33 AS "3.33", LR1 AS "-1.272", L11 AS "-1.618", L22 AS "-2", L2618 AS "-2.618", L33 AS "-3.33", DH AS "DL", DL AS "DH"1 user thanked author for this post.
05/29/2020 at 7:28 AM #133712Many thanks to both of you dear.
Vonasi you are a Legend. Special thanks to you.
1 user thanked author for this post.
05/29/2020 at 8:52 AM #13373405/29/2020 at 9:27 AM #133743Yes – looking at it after another coffee even my code is not quite right!
Change the OHLC code to the following and on Sundays and Mondays it bases the calculations on Fridays data and on Tuesdays it bases the calculations on Sunday and Monday’s data:
123456789101112if d <> d[1] thenif (D=0 or D=3 or D=4 or D=5) thenH1=DHigh(1)L1=DLow(1)C1=DClose(1)O=DOpen(1)elsif (D=2) thenH1=max(DHigh(1),dHigh(2))L1=min(DLow(1),dLow(2))C1=DClose(1)O=DOpen(2)endif1 user thanked author for this post.
05/29/2020 at 9:39 AM #13374406/01/2020 at 7:48 AM #134010Many thanks again to the legends!!
It seems the previous code is returning better results and new code is returning wrong levels as captured in the enclosed doc.
What say?
06/01/2020 at 8:46 AM #134017please use image file formats (jpg, png) when attaching pics and PDF or TXT file formats when attaching text.
Thank you 🙂
06/02/2020 at 8:12 AM #134147What should be the format if it is a combination of text and image? I presume it would be pdf, correct?
-
AuthorPosts
Find exclusive trading pro-tools on