Cam Day

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

/////////////////////////////////

/// camarilla day


/////////////////////////////////
t = input.string(title='Pivot Resolution', defval='D', options=['D', 'W', 'M'])

//Get previous day/week bar and avoiding realtime calculation by taking the
previous to current bar
[sopen,shigh,slow,sclose] = request.security(syminfo.tickerid, t,
[open[1],high[1],low[1],close[1]], barmerge.gaps_off, barmerge.lookahead_on)
//shigh = request.security(syminfo.tickerid, t, high[1], barmerge.gaps_off,
barmerge.lookahead_on)
//slow = request.security(syminfo.tickerid, t, low[1], barmerge.gaps_off,
barmerge.lookahead_on)
//sclose = request.security(syminfo.tickerid, t, close[1], barmerge.gaps_off,
barmerge.lookahead_on)
r = shigh - slow

//Calculate pivots
center = sclose
h1c = sclose + r * (1.1 / 12)
h2 = sclose + r * (1.1 / 6)
h3 = sclose + r * (1.1 / 4)
h4 = sclose + r * (1.1 / 2)
h5 = shigh / slow * sclose
l1c = sclose - r * (1.1 / 12)
l2 = sclose - r * (1.1 / 6)
l3 = sclose - r * (1.1 / 4)
l4 = sclose - r * (1.1 / 2)
l5 = sclose - (h5 - sclose)

//Colors (<ternary conditional operator> expression prevents continuous lines on


history)
c5c = sopen != sopen[1] ? na : color.yellow
c4c = sopen != sopen[1] ? na : color.yellow
c3c = sopen != sopen[1] ? na : color.orange
c2c = sopen != sopen[1] ? na : #00FF00
c1c = sopen != sopen[1] ? na : #FF0000
ccc = sopen != sopen[1] ? na : color.white

//Plotting
//plot(center, title='Central', color=cc, linewidth=3, transp=0)
//plot(h5, title='H5', color=c5c, linewidth=1, style=plot.style_line, transp=0)
//plot(h4, title='H4', color=c4c, linewidth=1,style=plot.style_line, transp=0)
//plot(h3, title='H3', color=c3c, linewidth=1,style=plot.style_line, transp=0)
//plot(h2, title='H2', color=c2c, linewidth=1,style=plot.style_line, transp=0)
//plot(h1c, title='H1', color=c1c, linewidth=1,style=plot.style_line, transp=0)
//plot(l1c, title='L1', color=c1c, linewidth=1,style=plot.style_line, transp=0)
//plot(l2, title='L2', color=c2c, linewidth=1,style=plot.style_line, transp=0)
//plot(l3, title='L3', color=c3c, linewidth=1,style=plot.style_line, transp=0)
//plot(l4, title='L4', color=c4c, linewidth=1,style=plot.style_line, transp=0)
//plot(l5, title='L5', color=c5c, linewidth=1,style=plot.style_line, transp=0)

ll_offset = bar_index
l_size = size.small

cams1_label = label.new(x=ll_offset, y=l1c, text='cam S1 ║ ' + str.tostring(l1c),


style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.red, size=l_size)
label.delete(cams1_label[1])
cams2_label = label.new(x=ll_offset, y=l2, text='cam S2 ║ ' + str.tostring(l2),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.lime, size=l_size)
label.delete(cams2_label[1])
cams3_label = label.new(x=ll_offset, y=l3, text='cam S3 ║ ' + str.tostring(l3),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.orange, size=l_size)
label.delete(cams3_label[1])
cams4_label = label.new(x=ll_offset, y=l4, text='cam S4 ║ ' + str.tostring(l4),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.yellow, size=l_size)
label.delete(cams4_label[1])
cams5_label = label.new(x=ll_offset, y=l5, text='cam S5 ║ ' + str.tostring(l5),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.yellow, size=l_size)
label.delete(cams5_label[1])

camr1_label = label.new(x=ll_offset, y=h1c, text='cam R1 ║ ' + str.tostring(h1c),


style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.red, size=l_size)
label.delete(camr1_label[1])
camr2_label = label.new(x=ll_offset, y=h2, text='cam R2 ║ ' + str.tostring(h2),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.lime, size=l_size)
label.delete(camr2_label[1])
camr3_label = label.new(x=ll_offset, y=h3, text='cam R3 ║ ' + str.tostring(h3),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.orange, size=l_size)
label.delete(camr3_label[1])
camr4_label = label.new(x=ll_offset, y=h4, text='cam R4 ║ ' + str.tostring(h4),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.yellow, size=l_size)
label.delete(camr4_label[1])
camr5_label = label.new(x=ll_offset, y=h5, text='cam R5 ║ ' + str.tostring(h5),
style=label.style_label_left,color=color.new(color.green, 100),
textcolor=color.yellow, size=l_size)
label.delete(camr5_label[1])

You might also like