wightsparky

MA_FibBand_MTF

Moving average of High, Low & Close with Fibonacci bands calculated from the average high and low. Four upper levels are to the power of 1.618, 2.618, 3.618 & 4.618. Four lower levels are to the power of 0.618, 1.618, 2.618 & 3.618. Included are a choice of time frames either current, semi-custom or fully custom allowing freedom to set any period you like which makes it great for historical averages. Adapted and expanded from Clarke Moody's MA_MTF i have tidied the script and included all CM's formulas although should be used in SMA or EMA i kept the other MA formulas for curiosity.
My preferred usage is to stick with 20ma and adjust the legnth of the period. Shown here is 20ema of 10day period.
More information can be learnt from 'endlessmountain' on youtube but only the very top and bottom levels are used with the High, Low & Close. Also i am not aware if this originates from any other source.
Thankyou to Clarke Moody and endlessmountain. Hope you like this tool.
Remove from Favorite Scripts Add to Favorite Scripts
//Fibonacci Band feature by WightSparky. Bitcoin Donations welcome: 1JsxW1SpJVtmZr6DFpHxnyvUjZmYuGZKWv
//Thanks to Clarke Moody for MA_MTF which i used the MA Formulas. 
//Moving average of High, Low & Close from which the High & Low is used to calculate log fibonacci bands.
//Designed for SMA or EMA use. Other MA's are included but for purpose of curiosity only.
//
study(title="MA_FibBand_MTF", shorttitle="MAFB_MTF", overlay=true)
//inputs
srch = high
srcc = close
srcl = low
len = input(defval=20, title="Moving Average Length")
atype = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3")
//periodT3 = input(defval=7, title="Tilson T3 Period", minval=1) 
factorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0)
CRes = input(minval=1, maxval=3, defval=1, title="Timeframe  (1=Current, 2=Semi-Custom, 3=Fully-Custom)")
SemiCustRes = input(title="Semi-Custom Timeframe", type=resolution, defval="W")
FullyCustRes = input(title="Fully Custom Timeframe (example: 3M, 3W, 3D, 720 =(12hrs) etc.)", defval="10D")
sb = input(true, title="High,Close,Low Band")
se1 =input(true, title="Extentions Level 1")
se2 =input(true, title="Extentions Level 2")
se3 =input(true, title="Extentions Level 3")
se4 =input(true, title="Extentions Level 4")

res = CRes == 1 ? period : CRes == 2 ? SemiCustRes : FullyCustRes

//HLC Band Colour
h_col = green
c_col = yellow
l_col = red

//Extension Colour
ext_col = blue

//hull ma definition
hullma_h = wma(2*wma(srch, len/2)-wma(srch, len), round(sqrt(len)))
hullma_c = wma(2*wma(srcc, len/2)-wma(srcc, len), round(sqrt(len)))
hullma_l = wma(2*wma(srcl, len/2)-wma(srcl, len), round(sqrt(len)))
//TEMA definition
ema1_h = ema(srch, len)
ema1_c = ema(srcc, len)
ema1_l = ema(srcl, len)
ema2_h = ema(ema1_h, len)
ema2_c = ema(ema1_c, len)
ema2_l = ema(ema1_l, len)
ema3_h = ema(ema2_h, len)
ema3_c = ema(ema2_c, len)
ema3_l = ema(ema2_l, len)
tema_h = 3 * (ema1_h - ema2_h) + ema3_h
tema_c = 3 * (ema1_c - ema2_c) + ema3_c
tema_l = 3 * (ema1_l - ema2_l) + ema3_l
//Tilson T3
factor = factorT3 *.10
gd_h(srch, len, factor) => ema(srch, len) * (1 + factor) - ema(ema(srch, len), len) * factor 
gd_c(srcc, len, factor) => ema(srcc, len) * (1 + factor) - ema(ema(srcc, len), len) * factor
gd_l(srcl, len, factor) => ema(srcl, len) * (1 + factor) - ema(ema(srcl, len), len) * factor
t3_h(srch, len, factor) => gd_h(gd_h(gd_h(srch, len, factor), len, factor), len, factor)
t3_c(srcc, len, factor) => gd_c(gd_c(gd_c(srcc, len, factor), len, factor), len, factor) 
t3_l(srcl, len, factor) => gd_l(gd_l(gd_l(srcl, len, factor), len, factor), len, factor) 
tilT3_h = t3_h(srch, len, factor)
tilT3_c = t3_c(srcc, len, factor)
tilT3_l = t3_l(srcl, len, factor)
 
avg_h = atype == 1 ? sma(srch,len) : atype == 2 ? ema(srch,len) : atype == 3 ? wma(srch,len) : atype == 4 ? hullma_h : atype == 5 ? vwma(srch, len) : atype == 6 ? rma(srch,len) : atype == 7 ? tema_h : tilT3_h
avg_c = atype == 1 ? sma(srcc,len) : atype == 2 ? ema(srcc,len) : atype == 3 ? wma(srcc,len) : atype == 4 ? hullma_c : atype == 5 ? vwma(srcc, len) : atype == 6 ? rma(srcc,len) : atype == 7 ? tema_c : tilT3_c
avg_l = atype == 1 ? sma(srcl,len) : atype == 2 ? ema(srcl,len) : atype == 3 ? wma(srcl,len) : atype == 4 ? hullma_l : atype == 5 ? vwma(srcl, len) : atype == 6 ? rma(srcl,len) : atype == 7 ? tema_l : tilT3_l

//HLC Band
out_b_h = security(tickerid, res, avg_h)
out_b_c = security(tickerid, res, avg_c)
out_b_l = security(tickerid, res, avg_l)

//Extentions
ext_up = out_b_h/out_b_l
ext_dwn = out_b_l/out_b_h

upper_ext = pow(ext_up, 1.618)*out_b_l
lower_ext = pow(ext_dwn, 0.618)*out_b_l
upper_ext2 = pow(ext_up, 2.618)*out_b_l
lower_ext2 = pow(ext_dwn, 1.618)*out_b_l
upper_ext3 = pow(ext_up, 3.618)*out_b_l
lower_ext3 = pow(ext_dwn, 2.618)*out_b_l
upper_ext4 = pow(ext_up, 4.618)*out_b_l
lower_ext4 = pow(ext_dwn, 3.618)*out_b_l

//HLC Band
bh = plot(sb and out_b_h ? out_b_h : na, title="MA High", style=line, linewidth=2, color = h_col, transp=20)
bl = plot(sb and out_b_l ? out_b_l : na, title="MA Low", style=line, linewidth=2, color = l_col, transp=20)
fill(bh, bl, color = ext_col, transp = 100)
plot(sb and out_b_c ? out_b_c : na, title="MA Close", style=line, linewidth=2, color = c_col, transp=20)

//Extension
bh_ex1 = plot(se1 and upper_ext ? upper_ext : na, title ="High Extension 1", color=ext_col, linewidth = 1, transp=20)
bl_ex1 = plot(se1 and lower_ext ? lower_ext : na, title ="Low Extension 1", color=ext_col, linewidth = 1, transp=20)
fill(bh, bh_ex1, color=ext_col, transp=100, title = "High Extension 1 Background")
fill(bh, bl_ex1, color=ext_col, transp=100, title = "Low Extension 1 Background")

bh_ex2 = plot(se2 and upper_ext2 ? upper_ext2 : na, title ="High Extension 2", color=ext_col, linewidth = 1, transp=20)
bl_ex2 = plot(se2 and lower_ext2 ? lower_ext2 : na, title ="Low Extension 2", color=ext_col, linewidth = 1, transp=20)
fill(bh_ex1, bh_ex2, color=ext_col, transp=80, title = "High Extension 2 Background")
fill(bl_ex1, bl_ex2, color=ext_col, transp=80, title = "Low Extension 2 Background")

bh_ex3 = plot(se3 and upper_ext3 ? upper_ext3 : na, title ="High Extension 3", color=ext_col, linewidth = 1, transp=20)
bl_ex3 = plot(se3 and lower_ext3 ? lower_ext3 : na, title ="Low Extension 3", color=ext_col, linewidth = 1, transp=20)
fill(bh_ex2, bh_ex3, color=ext_col, transp=100, title = "High Extension 3 Background")
fill(bl_ex2, bl_ex3, color=ext_col, transp=100, title = "Low Extension 3 Background")

bh_ex4 = plot(se4 and upper_ext4 ? upper_ext4 : na, title ="High Extension 4", color=ext_col, linewidth = 2, transp=20)
bl_ex4 = plot(se4 and lower_ext4 ? lower_ext4 : na, title ="Low Extension 4", color=ext_col, linewidth = 2, transp=20)
fill(bh_ex3, bh_ex4, color=ext_col, transp=80, title = "High Extension 4 Background")
fill(bl_ex3, bl_ex4, color=ext_col, transp=80, title = "Low Extension 4 Background")
wightsparky
a year ago
Weekly & Monthly
EMA
snapshot


SMA
snapshot
Reply
telepatico
6 months ago
It would be nice if you could add a squeeze to this.
Reply
squattter PRO
4 months ago
fucking lovely!
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener 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 Billing Sign Out