JustUncleL

Automatic Daily Fibonacci v0.3 by JustUncleL

9776 lượt xem
2633
9776 9
This update is a correction on the way the Fib Zero line is calculated. Previously it was just based on the source of the previous day, which is Ok as long as the Fiblength was set to 2. The new version calculates the Fib Zero from the average of the specified source over the Fiblength, so if Fiblength is now something other than 2 the Fibonacci Zero and other support and resistant levels should calculate correctly.
Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
//@version=2
// Name: Automatic Daily Fibonacci v0.3
// By: JustUncleL
// Date: 14-Jul-2016
// Version: v0.3
//
// 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
//
// Modifications:
//   v0.3 (18-Sep-2016)
//   - Change the Fib zero to be the average of specified source over the "fiblength",
//     this caters better when fiblength is different from 2.
//   v0.2 (25-Jul-2016)
//   - Change Time frame type from "resolution" to "string", "resolution" was
//     restricting my time frame selections, I wanted to select 480(4H) and 720(8H)etc.
//     however, there is now no built-in resolution checking only valid ones can be
//     entered for axample: 60, 120, 240, 360, 480, 720, D, W, M, 2D, 2W, 3M...
//   - Change default zero from (hlc3) to (hl2), seems to give better results.
//   v0.1 (20-Jul-2016)
//   - Corrections and added optional source for centre line, it will
//     take the previous days position as centre line (hlc3), the original used
//     current days openning, but this could influenced by a spike.
//
study(title="Automatic Daily Fibonacci v0.3 by JustUncleL", shorttitle="AutoDailyFib v0.3 by JustUncleL", overlay=true, scale=scale.right)
//
// Get the time frame we are basing the Fibonacci retracements levels on.
// By default use Daily current day and previous day.
TimeFrame = input('1D',type=string,title="Timeframe For Fib Levels" )
fiblength=input(2,minval=1,title="Fibonacci Lookback Length")
zeroSrc = input(hl2,title="Fibonacci Centre Line Source")

//
// Find the highest and lowest 2 days(by default), including current.
// Start Fib retracement from average source over fiblength (default:hl2) 
Z_000 = security(tickerid, TimeFrame, sum(zeroSrc,fiblength)/fiblength)
H_100 = security(tickerid, TimeFrame, highest(high,fiblength))
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=30, 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=black, transp=70, 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=30, linewidth=2)

// Let's make it all look good fill in the gaps.
fill(h100,h764, color=maroon, transp=90)
fill(h764,h618, color=yellow, transp=90)
fill(h618,h500, color=blue, transp=90)
fill(h500,h382, color=lime, transp=90)
fill(h382,h236, color=green, transp=90)
fill(h236,zero, color=red, transp=90)
fill(zero,l236, color=red, transp=90)
fill(l382,l236, color=green, transp=90)
fill(l500,l382, color=lime, transp=90)
fill(l618,l500, color=blue, transp=90)
fill(l764,l618, color=yellow, transp=90)
fill(l764,l100, color=maroon, transp=90)
//
//EOF.
JustUncleL
Hi UncleL, any idea how i can make this to do another Fibonacci just for the day? in which it updates every hour upon receiving a closed hour of data?
Phản hồi
JustUncleL jianhua85
@jianhua85, It could possibly be performed, but it will not be related to the intention of this script though.
Phản hồi
is it possible to include premarket data ? currently its looking only for day high and low during trading hours.
Phản hồi
JustUncleL pratheepnz
@pratheepnz, Generally there is no access to pre-market data.
Phản hồi
Just started learning how to code. Hope you do not mind me using your code to practice with
Phản hồi
@break, All my scripts are open and free to use all or any part of the code, as long as your new script acknowledges where the original script came from, also any new scripts must be open, as per implied GPL copyright licence, if published into the library. In my newer or updated scripts I now include the GNU General Public Licence (GPL) copyright notice, rather than implying it.
Phản hồi
olivier77 JustUncleL
@JustUncleL : Just to thank you for your contribution to your site. It's very kind and very appreciated. Your coding skills are amazing!
Phản hồi
swp450 JustUncleL
@JustUncleL, thank you good sir!!
Phản hồi
im new so dont laugh this is my first time here this what im looking 4 also looking for practic buying and selling curency charts this perfect just need to learn an know more. any thing helps
+3 Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Cách thức hoạt động Tính năng Biểu đồ Giá Quy tắc Áp dụng Người điều hành Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Nhận trợ giúp Yêu cầu tính năng Blog & Tin tức Câu hỏi thường gặp Wiki Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Đồng TradingView Ticket Hỗ trợ của tôi Nhận trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất