RVC_DecisionPoints By Rishabh
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rvc8280

//@version=4
study("RVC_DecisionPoints",shorttitle="EMA PDH/PDL", overlay = true)

disp_dp = input(true, title="Display DP Lines?")
disp_brn = input(true, title="Display BRN Lines?")
firstbar(resolution) =>
    ch = 0
    if(resolution == 'Y')
        t  = year(time('D'))
        ch := change(t) != 0 ? 1 : 0
    else
        t = time(resolution)
        ch := change(t) != 0 ? 1 : 0
    ch

pp_res = 'D'
bars_sinse = 0
bars_sinse := firstbar(pp_res) ? 0 : bars_sinse[1] + 1

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

y_th = line.new(bar_index[min(bars_sinse, 300)], disp_dp?phigh_d :na, bar_index, disp_dp?phigh_d :na, color=color.navy,  style =  line.style_solid, width=1, extend = extend.none)

y_tl = line.new(bar_index[min(bars_sinse, 300)], disp_dp?plow_d :na, bar_index, disp_dp?plow_d :na, color=color.navy,  style =  line.style_solid,width=1, extend = extend.none)

line.delete(y_th[1])

line.delete(y_tl[1])

label_yh = label.new(bar_index, disp_dp?phigh_d : na, text="PDHigh",  style= label.style_none)

label_yl = label.new(bar_index, disp_dp?plow_d : na, text="PDLow",  style= label.style_none)

label.delete(label_yh[1])

label.delete(label_yl[1]) 



ema9 = ema(close, 8)
ema20 = ema(close, 20)
ema50 = ema(close, 50)
ema200 = ema(close, 200)

plot(ema9,title="EMA9", color = color.blue)
plot(ema20,title="EMA20", color = color.green)
plot(ema50,title="EMA50", color = color.red)
plot(ema200,title="EMA200", color = color.aqua)
