PDHL levels with INTRADAY Auto FIB
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vatsanuj
//INTRADAY day AUTO Fib also includes PDHL levels + EMA20/50/200 + VWAP -- Enjoy--Dr.Vats
//@version=5

indicator(title='INTRADAY Auto FIB with PDHL levels', shorttitle='Intraday FIB', overlay=true)

plot(ta.vwap(close), color=color.fuchsia, linewidth = 2, title = "VWAP")

[EMA20, EMA50, EMA200] =request.security(syminfo.tickerid, 'D', [math.round_to_mintick(ta.ema(close,20)),math.round_to_mintick(ta.ema(close,50)), math.round_to_mintick(ta.ema(close,200))])
plot(EMA20, title = "20 DEMA", color = color.yellow, linewidth = 2, style = plot.style_circles)
plot(EMA50,title = "50 DEMA", color = color.rgb(247, 9, 9), linewidth = 2,style = plot.style_circles)
plot(EMA200,title = "200 DEMA", color = color.green, linewidth = 3,style = plot.style_cross)

[Fhigh,Fhigh1,Fhigh2,Flow,Flow1,Flow2]  = request.security(syminfo.tickerid, 'D', [high[0], high[1], high[2], low[0], low[1], low[2]])

F0 = Flow
F236 = (Fhigh - Flow) * 0.236 + Flow
F382 = (Fhigh - Flow) * 0.382 + Flow
F500 = (Fhigh - Flow) * 0.500 + Flow
F618 = (Fhigh - Flow) * 0.618 + Flow
F786 = (Fhigh - Flow) * 0.786 + Flow
F1000 = (Fhigh - Flow) * 1.000 + Flow

Fcolor_PDH_Broke = Fhigh>Fhigh1 ? color.aqua : color.gray // color of the present day high line if present day price has broken Previous day high
Fcolor_PDL_Broke = Flow <Flow1  ? color.fuchsia : color.gray // color of the present day low line if present day price has broken Previous day low

bgcolor(Fhigh>Fhigh1 ? color.new(color.white,90) :na, show_last = 1, title = "PDH broken") //highlights the background of the present candle to white if PDH is already broken anytime in present day
bgcolor(Flow<Flow1 ? color.new(color.red,85) :na, show_last = 1, title= "PDL broken") //highlights the background of the present candle to red if PDL is already broken anytime in present day

plot(Fhigh1, color= color.yellow, linewidth = 2,trackprice=true, show_last=1, title='PDH')
plot(Fhigh2, color= color.yellow, linewidth = 1,trackprice=true, show_last=1, title='PDH2')
plot(Flow1, color= color.orange, linewidth = 2,trackprice=true, show_last=1, title='PDL')
plot(Flow2, color= color.orange, linewidth = 1,trackprice=true, show_last=1, title='PDL2')
plotshape(Fhigh1, style=shape.labeldown, location=location.absolute, color=color.new(color.yellow, 10), textcolor=color.new(color.fuchsia, 10), show_last=1, text='PDH', offset=-2)
plotshape(Fhigh2, style=shape.arrowup, location=location.absolute, color=color.new(color.yellow, 10), textcolor=color.new(color.yellow, 10), show_last=1, text='PDH2', offset=-4)
plotshape(Flow1, style=shape.labeldown, location=location.absolute, color=color.new(color.orange, 30), textcolor=color.new(color.white, 10), show_last=1, text='PDL', offset=-2)
plotshape(Flow2, style=shape.arrowdown, location=location.absolute, color=color.new(color.orange, 30), textcolor=color.new(color.orange, 10), show_last=1, text='PDL2', offset=-4)


plot(F0, color=Fcolor_PDL_Broke, linewidth=2, trackprice=true, show_last=1, title='0')
plot(F236, color=color.new(color.green, 0), linewidth=1, trackprice=true, show_last=1, title='0.236')
plot(F382, color=color.rgb(169, 221, 157, 16), linewidth=2, trackprice=true, show_last=1, title='61.8 RT')

plot(F500, color=color.new(color.white, 0), linewidth=2, trackprice=true, show_last=1, title='0.5')

plot(F618, color=color.rgb(250, 92, 234, 16), linewidth=2, trackprice=true, show_last=1, title='38.2 RT')
plot(F786, color=color.new(color.maroon, 0), linewidth=1, trackprice=true, show_last=1, title='0.786')
plot(F1000, color=Fcolor_PDH_Broke, linewidth=2, trackprice=true, show_last=1, title='1')

plotshape(F0, style=shape.labeldown, location=location.absolute, color=color.new(color.white, 0), textcolor=color.new(color.black, 0), show_last=1, text='%0', offset=5)
plotshape(F236, style=shape.labeldown, location=location.absolute, color=color.new(color.white, 0), textcolor=color.new(color.black, 0), show_last=1, text='%78.6', offset=6)
plotshape(F382, style=shape.labeldown, location=location.absolute, color=color.rgb(6, 167, 24), textcolor=color.new(color.black, 0), show_last=1, text='%61.8', offset=4)

plotshape(F500, style=shape.labeldown, location=location.absolute, color=color.new(color.white, 0), textcolor=color.new(color.black, 0), show_last=1, text='%50', offset=5)

plotshape(F618, style=shape.labeldown, location=location.absolute, color=color.rgb(248, 28, 28), textcolor=color.new(color.white, 0), show_last=1, text='%38.2', offset=4)
plotshape(F786, style=shape.labeldown, location=location.absolute, color=color.new(color.white, 0), textcolor=color.new(color.black, 0), show_last=1, text='%23.6', offset=6)
plotshape(F1000, style=shape.labeldown, location=location.absolute, color=color.new(color.white, 0), textcolor=color.new(color.black, 0), show_last=1, text='%100', offset=5)



