Fib by Raghav V 3.1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

// Disclaimer : I made this indicator based on Mr.

Nikhil concept who is a FTU Group


Member @nikhilbhoite (Telegram)
// Thanks to Nikhil for your concept of Fib Levels. The levels are working
fantastic.
//@version=4

study (title="Nikhil's Fib Levels'", shorttitle="Fib by Raghav ", overlay=true)


mytime = input(title="Select your 1st Candle Range : ", type=input.resolution,
defval="15")
showfib = input(true, title="Show Default Fib Levels")
show38 = input(false, title="Show 0.38 & 0.5 Fib Levels")
showextras = input(false, title="Show Extra Fib. Levels")
showmids = input(false, title="Show Fib Mid Points")
show48 = input(false, title="Show 48 Channel")
showvwap = input(false, title="Show VWAP")
showoc = input(false, title="Show Today Open & Prev. Day Close")
showst = input(false, title="Super Trend")

show15bb = input(false, title="20 Period Bollinger Bands")


show60bb = input(false, title="80 Period Bollinger Bands")
show100bb = input(false, title="100 Period Bollinger Bands")

adopt(r, s) => security(syminfo.tickerid, r, s)

colorvalue = security(syminfo.tickerid, "D", open[1], barmerge.gaps_off,


barmerge.lookahead_on)
todayopen = security(syminfo.tickerid, "D", open, barmerge.gaps_off,
barmerge.lookahead_on)
prevclose = security(syminfo.tickerid, "D", close[1], barmerge.gaps_off,
barmerge.lookahead_on)

pdh = security(syminfo.tickerid, "D", high[1], barmerge.gaps_off,


barmerge.lookahead_on)
pdl = security(syminfo.tickerid, "D", low[1], barmerge.gaps_off,
barmerge.lookahead_on)

tdh = security(syminfo.tickerid, "D", high, barmerge.gaps_off,


barmerge.lookahead_on)
tdl = security(syminfo.tickerid, "D", low, barmerge.gaps_off,
barmerge.lookahead_on)

tdrange = tdh - tdl


pdrange = pdh - pdl

float factor = 2
int pd = 10
float up = hl2 - (factor * atr(pd))
dn = hl2 + (factor * atr(pd))
float trendup = 0.0
trendup := close[1] > trendup[1] ? max(up, trendup[1]) : up
float trenddown = 0.0
trenddown := close[1] < trenddown[1] ? min(dn, trenddown[1]) : dn
float trend = 0.0
trend := close > trenddown[1] ? 1 : close < trendup[1] ? -1 : nz(trend[1], 1)
float tsl = trend == 1 ? trendup : trenddown
color linecolor = trend == 1 ? color.green : color.red

plot( showst and tsl ? tsl : na, color = linecolor, style = plot.style_line,
linewidth = 2, title = "SuperTrend")

redcolor = colorvalue != colorvalue[1] ? na : color.red


greencolor = colorvalue != colorvalue[1] ? na : color.green
blackcolor = colorvalue != colorvalue[1] ? na : #0000FF
pinkcolor = colorvalue != colorvalue[1] ? na : color.fuchsia
blue = colorvalue != colorvalue[1] ? na : color.blue
royalblue = colorvalue != colorvalue[1] ? na : #0000FF
blackblack = colorvalue != colorvalue[1] ? na : color.black
orangec = colorvalue != colorvalue[1] ? na : color.orange

myhigh_value = nz(valuewhen(change(time('D')) != 0, high, 0))


mylow_value = nz(valuewhen(change(time('D')) != 0, low, 0))

high_value = adopt (mytime, myhigh_value)


low_value = adopt (mytime, mylow_value)

range=high_value-low_value

mya= plot(showfib and high_value ? high_value : na, color = blackcolor,


linewidth=2, style=plot.style_line, title="15 min High")
myb= plot(showfib and low_value ? low_value : na, color = blackcolor, linewidth=2,
style=plot.style_line, title="15 min Low")

fill (mya, myb, color=blue, transp=90)

aa=plot( show38 and high_value - (range*0.382) ? high_value - (range*0.382) : na ,


color = blackblack, linewidth=2, style=plot.style_line, title=" 0.382")
ab=plot( show38 and high_value - (range*0.50) ? high_value - (range*0.50) : na ,
color = blackblack, linewidth=2, style=plot.style_line, title=" 0.50")
ac=plot( show38 and low_value + (range*0.382) ? low_value + (range*0.382) :
na , color = blackblack, linewidth=2, style=plot.style_line, title=" 0.382")

a=plot(showfib and high_value - (range*1.382) ? high_value - (range*1.382) : na,


color = greencolor, linewidth=2, style=plot.style_line, title=" 1.382")
b=plot(showfib and high_value - (range*1.618) ? high_value - (range*1.618) : na,
color = greencolor, linewidth=2, style=plot.style_line, title=" 1.618")

plot(showextras and high_value - (range*2.618) ? high_value - (range*2.618) : na,


color = greencolor, linewidth=2, style=plot.style_line, title=" 2.618")
plot(showextras and high_value - (range*3.618) ? high_value - (range*3.618) : na,
color = greencolor, linewidth=2, style=plot.style_line, title=" 3.618")

plot(showmids and high_value - (range*2.118) ? high_value - (range*2.118) : na,


color = blackcolor, linewidth=1, style=plot.style_circles, title=" Mid Point")
plot(showmids and high_value - (range*3.118) ? high_value - (range*3.118) : na,
color = blackcolor, linewidth=1, style=plot.style_circles, title=" Mid Point")

e=plot(showfib and low_value + (range*1.382) ? low_value + (range*1.382) : na,


color = redcolor, linewidth=2, style=plot.style_line, title=" 1.382")
f=plot(showfib and low_value + (range*1.618) ? low_value + (range*1.618) : na,
color = redcolor, linewidth=2, style=plot.style_line, title=" 1.618")

plot(showextras and low_value + (range*2.618) ? low_value + (range*2.618) : na,


color = redcolor, linewidth=2, style=plot.style_line, title=" 2.618")
plot(showextras and low_value + (range*3.618) ? low_value + (range*3.618) : na,
color = redcolor, linewidth=2, style=plot.style_line, title=" 3.618")

plot(showmids and low_value + (range*2.118) ? low_value + (range*2.118) : na, color


= blackcolor, linewidth=1, style=plot.style_circles, title=" Mid Point")
plot(showmids and low_value + (range*3.118) ? low_value + (range*3.118) : na, color
= blackcolor, linewidth=1, style=plot.style_circles, title=" Mid Point")

fill (a,b, color=greencolor, transp=70)


fill (e,f, color=redcolor, transp=70)

myvwap = vwap(hlc3)

plot(showvwap and myvwap ? myvwap : na, color = blackcolor, linewidth=2,


style=plot.style_stepline, title = "VWAP")
plot(showoc and todayopen ? todayopen : na, color = pinkcolor, linewidth=3,
style=plot.style_line, title="Open")
plot(showoc and prevclose ? prevclose : na , color = orangec, linewidth=2,
style=plot.style_line, title = "Prev.Close")

plot(showvwap and myvwap ? myvwap : na, color = color.black, linewidth=2,


style=plot.style_line, title = "VWAP")

ema48high = ema (high, 48)


ema48low = ema (low, 48)
h=plot(show48 and ema48high ? ema48high : na, color = royalblue, linewidth=2,
style=plot.style_line, title = "48EMA_High")
l=plot(show48 and ema48low ? ema48low : na, color = royalblue, linewidth=2,
style=plot.style_line, title = "48EMA_Low")

fill (h, l, color=color.yellow, transp=60)

/////////////////////////////// Bollinger Band


Codes ///////////////////////////////////////

length = 20
src = close
mult = 2
basis = sma(src, 20)
dev = mult * stdev(close, 20)
upper = basis + dev
lower = basis - dev

length1 = 80
src1 = close
mult1 = 2
basis1 = sma(src1, 80)
dev1 = mult1 * stdev(close, 80)
upper1 = basis1 + dev1
lower1 = basis1 - dev1

p1 = plot(show15bb and upper ? upper : na, "15 Upper", color=color.red,


linewidth=2)
p2 = plot(show15bb and lower ? lower : na, "15 Lower", color=color.green,
linewidth=2)
plot(show15bb and basis ? basis : na, "20 SMA", color=color.gray,
style=plot.style_stepline, linewidth=2)
fill(p1, p2, title = "Background", color=color.blue, transp=85)

p3 = plot(show60bb and upper1 ? upper1 : na, "60 Upper", color=color.red,


linewidth=3)
p4 = plot(show60bb and lower1 ? lower1 : na, "60 Lower", color=color.green,
linewidth=3)
plot(show60bb and basis1 ? basis1 : na, "80 SMA", color=color.black,
style=plot.style_stepline, linewidth=3)

length2 = 100
src2 = close
mult2 = 2
basis2 = sma(src2, 100)
dev2 = mult2 * stdev(close, 100)
upper2 = basis2 + dev2
lower2 = basis2 - dev2

p5 = plot(show100bb and upper2 ? upper2 : na, "100 Upper", color=color.red,


linewidth=6)
p6 = plot(show100bb and lower2 ? lower2 : na, "100 Lower", color=color.green,
linewidth=6)
plot(show100bb and basis2 ? basis2 : na, "100 SMA", color=color.black,
style=plot.style_stepline, linewidth=6)

You might also like