JustUncleL

Automatic Daily Fibonacci v0

I was looking for a Indicator that would draw Fibonacci re-tracement levels
based on the previous days highest and lowest point automatically, then
update the levels if with current days high and low dynamically.
I was unable to find exactly what I was looking for so made this one.
The following code actually performs the task that I used to do
manually, this saves me set up time and avoids errors.
Remove from Favorite Scripts Add to Favorite Scripts
//@version2
// Name: Automatic Daily Fibonacci v0
// By: JustUncleL
// Date: 14-Jul-2016
// Version: v0
//
// Description:
//   I was looking for a Indicator that would draw Fibonacci retracement levels
//   based on the previous days highest and lowest point automatically, then
//   update the levels if with current days high and low dynamically.
//   I was unable to find exactly what I was looking for so made this one.
//   The following code actually performs the task that I used to do
//   manually, this saves me set up time and avoids errors.
//   I achieved this by combining some of the ideas from two other very
//   similar indicators (thank you for code hope you don't mind):
//   - Auto Fib by TheYangGuizi
//   - [RS]Monthly Dynamic Range Levels (Fibonaci) V0 by RicardoSantos
//
study(title="Automatic Daily Fibonacci v0", shorttitle="AutoDailyFib v0", overlay=true, scale=scale.none)
//
// Get the time frame we are basing the Fibonacci retracements levels on.
// By default use Daily current day and previous day.
TimeFrame = input('D',type=resolution,title="Time Frame For Fib Levels" )
fiblength=input(2,minval=1,title="Fibonacci Lookback Length")

//
// Find the highest and lowest 2 days(by default), including current.
// Start Fib retracement from todays openning price
H_100 = security(tickerid, TimeFrame, highest(high,fiblength))
Z_000 = security(tickerid, TimeFrame, open)
L_100 = security(tickerid, TimeFrame, lowest(low,fiblength))

// Now Range the Fib arround today's openning price.
H_RANGE = H_100-Z_000
L_RANGE = Z_000-L_100

// Calculate Fib Upper points from top down to zero
H_764 = H_100 - H_RANGE * 0.236
H_618 = H_100 - H_RANGE * 0.382
H_500 = H_100 - H_RANGE * 0.500
H_382 = H_100 - H_RANGE * 0.618
H_236 = H_100 - H_RANGE * 0.764

// Calculate Fib Lower points from bottom up to zero
L_764 = L_100 + L_RANGE * 0.236
L_618 = L_100 + L_RANGE * 0.382
L_500 = L_100 + L_RANGE * 0.500
L_382 = L_100 + L_RANGE * 0.618
L_236 = L_100 + L_RANGE * 0.764

// Plot all the upper and lower Fib lines dynamically 
h100=plot( H_100, title="+1.000", color=black, transp=20, linewidth=2)
h764=plot( H_764, title="+0.764", color=yellow, transp=0)
h618=plot( H_618, title="+0.618", color=blue, transp=0)
h500=plot( H_500, title="+0.500", color=lime, transp=0)
h382=plot( H_382, title="+0.382", color=green, transp=0)
h236=plot( H_236, title="+0.236", color=red, transp=0)
zero=plot( Z_000, title="0.000",  color=gray, transp=0, linewidth=2,style=cross,join=true)
l236=plot( L_236, title="-0.236", color=red, transp=0)
l382=plot( L_382, title="-0.382", color=green, transp=0)
l500=plot( L_500, title="-0.500", color=lime, transp=0)
l618=plot( L_618, title="-0.618", color=blue, transp=0)
l764=plot( L_764, title="-0.764", color=yellow, transp=0)
l100=plot( L_100, title="-1.000", color=black, transp=20, linewidth=2)

// Let's make it all look good fill in the gaps.
fill(h100,h764, color=maroon, transp=85)
fill(h764,h618, color=yellow, transp=85)
fill(h618,h500, color=blue, transp=85)
fill(h500,h382, color=lime, transp=85)
fill(h382,h236, color=green, transp=85)
fill(h236,zero, color=red, transp=85)
fill(zero,l236, color=red, transp=85)
fill(l382,l236, color=green, transp=85)
fill(l500,l382, color=lime, transp=85)
fill(l618,l500, color=blue, transp=85)
fill(l764,l618, color=yellow, transp=85)
fill(l764,l100, color=maroon, transp=85)
//
//EOF.
Hi everyone, small error on my behave the "scale=scale.none" specified in study should be "scale=scale.right"
+1 Reply
Could I change dates rather than having it set up as a daily fib calculator? For instance, I would like the fib from the high and low of a specific time period on a consistent basis. In effect, it would be nice to be able to fib 2013, 2014, etc...and other time frames. Could your code be customized for specific time ranges?
Reply
JustUncleL PRO smartscope
I believe it is possible, I will look into it for you and if you want I can create a customized version. By the way there is a newer version of this script available.
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out