Drawing fibonacci levels not based on a period
Forums › ProRealTime English forum › ProBuilder support › Drawing fibonacci levels not based on a period
- This topic has 6 replies, 4 voices, and was last updated 4 years ago by Copperwave.
-
-
08/30/2019 at 6:24 PM #105941
Hello,
The common way to code fibonacci level is to take the high/low over a past period, lets say 1000 units, or 10 days, or whatever. The issue with this approch is that
- You never know if the relevant high/low is within your period
- The fibo that you have drawn has maybe already play its role (a retracement has occured) and news levels should be used.
So I’m looking for a way to remove this fixed period, by using a rule. The rule is “if there has been a retracement greater than 50%, and then afterwards the market turns again and break the 50% level again, then a new fibo should be drawn”. I have attached an exemple on the Dax TF4H. Three fibos can be drawn successfully, first the blue, then the red, and finally the white. It means that the fibo which is now relevant is the white one, the two other can be deleted. This is in opposition with the common way to drawn it (11265-11990 vs 11572-11990).
I have reused a code of Nicolas, but I struggle to
- Add a loop which will takes first the highest high /lowest low, then move to the next high/low if there has been a retracement
- I need to add a way via zigzag or anything else to check if we break again the 50%.
Sorry I’m a bit in a rush, but looking forward your advice
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103defparam drawonlastbaronly=trueONCE startbar=0ONCE hh=0ONCE ll=1000000000ONCE shifthighest=0ONCE shiftlowest=0//shiftlowest=barindexfor i = 1000-startbar downto 1 doif high[i]>=hh thenhh=high[i]shifthighest=barindex[i]endifif low[i]<=ll thenll=low[i]shiftlowest=barindex[i]endifnext//isSwingDown = shiftHighest < shiftLowestif isSwingDown thenfullrange = abs(hh-ll)fibo100 = hhfibo0 = llfibo236 = ll+(fullrange*0.236)fibo382 = ll+(fullrange*0.382)fibo50 = ll+fullrange/2fibo618 = ll+(fullrange*0.618)startbar1 = min(shifthighest,shiftlowest)endbar=max(shifthighest,shiftlowest)r=255g=0b=0elsefullrange = abs(hh-ll)fibo100 = llfibo0 = hhfibo236 = hh-(fullrange*0.236)fibo382 = hh-(fullrange*0.382)fibo50 = hh-fullrange/2fibo618 = hh-(fullrange*0.618)startbar1 = min(shifthighest,shiftlowest)endbar=max(shifthighest,shiftlowest)r=0g=255b=0endifif not isSwingDown thenblockprice=hhstartbar=barindex-shifthighestfor i = startbar downto 1 doif low[i]<blockprice thenblockprice=low[i]//blockbar=barindex[i]endifnextif blockprice<fibo50 thenstartbar=shifthighestendifelseblockprice=llstartbar=barindex-shiftlowestfor i = startbar downto 1 doif high[i]>blockprice thenblockprice=high[i]endifnextif blockprice>fibo50 thenstartbar=shiftlowestendifendif//drawsegment(startbar1,fibo100,endbar,fibo100) coloured(r,g,b)drawtext(" 100%",endbar,fibo100,Dialog,Standard,20) coloured(r,g,b)drawsegment(startbar1,fibo0,endbar,fibo0) coloured(r,g,b)drawtext(" 0%",endbar,fibo0,Dialog,Standard,20) coloured(r,g,b)drawsegment(startbar1,fibo236,endbar,fibo236) coloured(r,g,b)drawtext(" 23.6%",endbar,fibo236,Dialog,Standard,20) coloured(r,g,b)drawsegment(startbar1,fibo382,endbar,fibo382) coloured(r,g,b)drawtext(" 38.2%",endbar,fibo382,Dialog,Standard,20) coloured(r,g,b)drawsegment(startbar1,fibo50,endbar,fibo50) coloured(r,g,b)drawtext(" 50%",endbar,fibo50,Dialog,Standard,20) coloured(r,g,b)drawsegment(startbar1,fibo618,endbar,fibo618) coloured(r,g,b)drawtext(" 61.8%",endbar,fibo618,Dialog,Standard,20) coloured(r,g,b)return1 user thanked author for this post.
08/30/2019 at 7:31 PM #105950stefou102 – Perhaps it is better to only post topics when you are not in such a rush!
Surely pressing the return button and using shift to get a capital letter or two wouldn’t have taken too much extra time and would have made your post actually readable. I’ve edited it and inserted your numbered points in a more readable way. 🙂
08/30/2019 at 8:07 PM #10595209/02/2019 at 10:07 AM #10619910/01/2020 at 5:55 PM #146120Hi Guys – I see this has been quietly gathering dust till I stumbled upon it. The code above only does one pass. The graphic is hand drawn. I do this manually (it is my go-to trading strategy) but having the platform identify the 50/61.8% fib levels in this manner, (i.e not bar based but price action based) would be very useful.
Best regards
//Copperwave
10/02/2020 at 8:16 AM #14614210/02/2020 at 11:58 PM #146257Hmmm, good question…I think the problem is we are using lagging logic to try and identify leading levels. Is there a hybrid approach that could work?
Lets say the largest (initial) high/low is found somewhere in the last 50~100 bars and we are looking for a retracement for a long. If price retraces under then over the 50% of the initial range, (but doesn’t exceed the 61.8% or 76.4% levels) the swing low/high created by this price action becomes the next fib range…all subsequent fib ranges are indexed off this initial fib range. If the 76.4% levels do get broken, then this starts a new fib high/low in the opposite direction.
I hope this makes sense. In the graphic above, the first fib range (in blue) could be anywhere (n) bars back but if the retracement was valid there would be other ones following it (well I suppose at least 1)…It is almost like using your 61.8% retracement indicator but nesting or looping additional ones off of it…(if only I could code…!!).
BR
//Copperwave
-
AuthorPosts
Find exclusive trading pro-tools on