You are on page 1of 3

//@version=4

study(title='💥1💥', shorttitle='🔥',overlay=true)
//💥💥💥💥💥HIDE HISTORICAL LEVELS💥💥💥💥💥//
showlast = input(title='💥SHOW CURRENT LEVELS ONLY💥', defval=false,
group='Historical Levels')
islast = showlast ? security(syminfo.tickerid,'D', barstate.islast,
lookahead=barmerge.lookahead_on) : true

//💥💥💥💥💥💥💥💥💥💥💥💥💥💥//
//💥💥💥💥💥OPEN-CLOSE💥💥💥💥💥//
showprevclose = input(false, title="Show Previous Close")
showtodayopen = input(false, title="Show Today Open")

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)

yellowcolor = colorvalue != colorvalue[1] ? na : color.new(#ffe500, 0)


purplecolor = colorvalue != colorvalue[1] ? na : color.new(#e91e63, 0)

plot (islast and showtodayopen and todayopen? todayopen : na, color = purplecolor,
linewidth=1, style=plot.style_circles, title="Day Open")
plot (islast and showprevclose and prevclose ? prevclose : na , color =
yellowcolor, linewidth=1, style=plot.style_circles, title = "Previous Close")

//💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥//
//💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥//
//💥💥💥💥💥💥💥EXTENDED LINES💥💥💥💥💥💥💥💥//

// Colors
OPENColor = #ff2198
PDCColor = color.yellow

// Line style & Transparency


lStyle = plot.style_line
lTransp = 0

//Fill Transparency
fTransp = 95

// Global Variables & Flags


// TODO : Update the No of Holidays
noOfHolidays = 12

// Global Functions
// TODO : Update the list of Holiday here in format YYYY, MM, DD, 09, 15
// **09, 15 are session start hour & minutes
IsHoliday(_date) =>
iff(_date == timestamp(2020, 02, 21, 09, 15), true,
iff(_date == timestamp(2020, 03, 10, 09, 15), true,
iff(_date == timestamp(2020, 04, 02, 09, 15), true,
iff(_date == timestamp(2020, 04, 06, 09, 15), true,
iff(_date == timestamp(2020, 04, 10, 09, 15), true,
iff(_date == timestamp(2020, 04, 14, 09, 15), true,
iff(_date == timestamp(2020, 05, 01, 09, 15), true,
iff(_date == timestamp(2020, 05, 25, 09, 15), true,
iff(_date == timestamp(2020, 10, 02, 09, 15), true,
iff(_date == timestamp(2020, 11, 16, 09, 15), true,
iff(_date == timestamp(2020, 11, 30, 09, 15), true,
iff(_date == timestamp(2020, 12, 25, 09, 15), true,
false))))))))))))

// Note: Week of Sunday=1...Saturday=7


IsWeekend(_date) =>
dayofweek(_date) == 7 or dayofweek(_date) == 1

// Skip Weekend
SkipWeekend(_date) =>
_d = dayofweek(_date)
_mul = _d == 6 ? 3 : _d == 7 ? 2 : 1

_date + (_mul * 86400000)

// Get Next Working Day


GetNextWorkingDay(_date) =>
_dt = SkipWeekend(_date)

for i = 1 to noOfHolidays
if IsHoliday(_dt)
_dt := SkipWeekend(_dt)
continue
else
break

_dt

// Today's Session Start timestamp


y = year(timenow)
m = month(timenow)
d = dayofmonth(timenow)

// Start & End time for Today's CPR


start = timestamp(y, m, d, 09, 15)
end = start + 86400000

// Plot Today's CPR


shouldPlotToday = timenow > start

tom_start = start
tom_end = end

// Start & End time for Tomorrow's CPR


if shouldPlotToday
tom_start := GetNextWorkingDay(start)
tom_end := tom_start + 86400000

// Get series
getSeries(e, timeFrame) => security(syminfo.tickerid, "D", e,
lookahead=barmerge.lookahead_on)
// Calculate Today's CPR
//Get High, Low and Close
C = getSeries(close[1], 'D')
O = getSeries(open, 'D')

// Plot Today's CPR


if not(IsHoliday(start)) and not(IsWeekend(start)) and shouldPlotToday

_pclo = line.new(start, C, end, C,xloc.bar_time, color=color.new(PDCColor,


lTransp), width=3)
line.delete(_pclo[1])
_OP = line.new(start, O, end, O,xloc.bar_time, color=color.new(OPENColor,
lTransp), width=3)
line.delete(_OP[1])

// Plot Today's Labels


///if not(IsHoliday(start)) and not(IsWeekend(start)) and shouldPlotToday

////l_pclo = label.new(start, C, text="PDC",xloc=xloc.bar_time,


textcolor=PDCColor, style=label.style_none)
////label.delete(l_pclo[1])
////l_OP = label.new(start, O, text="OPEN",xloc=xloc.bar_time,
textcolor=OPENColor, style=label.style_none)
////label.delete(l_OP[1])

You might also like