Version 5
Version 5
//Indicator for Daily CPR, Monthly Pivots, Weekly Pivots, Highs and Lows, Moving
averages and Camarilla pivots.
//Number of days pivots need to be shown can be set
study(title="CPR Camarilla & MA", shorttitle="CPR & MA", overlay=true)
//Inputs
daily_cpr = input (title="Number of Daily CPR to show", type= input.integer ,
defval=1, minval=0)
weekly_pivot_back = input (title="Number of Weekly pivot to show ", type =
input.integer , defval=1, minval=0)
monthly_pivot_back = input (title="Number of Monthly pivot to show ", type =
input.integer , defval=1, minval=0)
// Pivot calculation
pivot = (high + low + close) / 3.0
bc = (high + low) / 2.0
tc = (pivot - bc) + pivot
R1 = (2*pivot) - low
S1 = (2*pivot) - high
R2 = pivot + ( high - low)
S2 = pivot - ( high - low)
R3 = high + (2*(pivot - low))
S3 = low - (2*(high - pivot ))
R4 = R3 + (R2 - R1)
S4 = S3 + (S2 - S1)
PH = high
PL= low
one_day = 1000 * 60 * 60 * 24
plot( (timeframe.isintraday and showCPR) ? (dtc_ >= dbc_ ? dtc_ : dbc_) : na,
title="Daily TC", style= plot.style_circles , color=#2196f3, linewidth=2)
plot( (timeframe.isintraday and showCPR) ? dpp_ : na, title="Daily PP", style=
plot.style_circles, color=#9C27B0, linewidth=2)
plot( (timeframe.isintraday and showCPR) ? (dtc_ >= dbc_ ? dbc_ : dtc_) : na,
title="Daily BC", style= plot.style_circles, color=#2196f3, linewidth=2)
//Monthly pvts
//Tomorrow CPR
//EMA
//EMA 1
lenE1 = input(9, minval=1, title="EMA 1 Length")
srcE1 = input(close, title="Source")
outE1 = ema(srcE1, lenE1)
plot(showEMA ? outE1 : na, color=#fb41ff, title="EMA 1", linewidth=2)
//EMA 2
lenE2 = input(20, minval=1, title="EMA 2 Length")
srcE2 = input(close, title="Source")
outE2 = ema(srcE2, lenE2)
plot(showEMA ? outE2 : na, color=#fb41ff, title="EMA 2", linewidth=2)
//EMA 3
lenE3 = input(50, minval=1, title="EMA 3 Length")
srcE3 = input(close, title="Source")
outE3 = ema(srcE3, lenE3)
plot(showEMA ? outE3 : na, color=#fb41ff, title="EMA 3", linewidth=2)
//EMA 4
lenE4 = input(100, minval=1, title="EMA 4 Length")
srcE4 = input(close, title="Source")
outE4 = ema(srcE4, lenE4)
plot(showEMA ? outE4 : na, color=#fb41ff, title="EMA 4", linewidth=2)
//EMA 5
lenE5 = input(200, minval=1, title="EMA 5 Length")
srcE5 = input(close, title="Source")
outE5 = ema(srcE5, lenE5)
plot(showEMA ? outE5 : na, color=#fb41ff, title="EMA 5", linewidth=2)
//SMA
//SMA 1
lenS1 = input(9, minval=1, title="SMA 1 Length")
srcS1 = input(close, title="Source")
outS1 = sma(srcS1, lenS1)
plot(showSMA ? outS1 : na, color=#ffeb3b, title="SMA 1", linewidth=2)
//SMA 2
lenS2 = input(20, minval=1, title="SMA 2 Length")
srcS2 = input(close, title="Source")
outS2 = sma(srcS2, lenS2)
plot(showSMA ? outS2 : na, color=#008000, title="SMA 2", linewidth=2)
//SMA 3
lenS3 = input(50, minval=1, title="SMA 3 Length")
srcS3 = input(close, title="Source")
outS3 = sma(srcS3, lenS3)
plot(showSMA ? outS3 : na, color=#ff0000, title="SMA 3", linewidth=2)
//SMA 4
lenS4 = input(100, minval=1, title="SMA 4 Length")
srcS4 = input(close, title="Source")
outS4 = sma(srcS4, lenS4)
plot(showSMA ? outS4 : na, color=#00bcd4, title="SMA 4", linewidth=2)
//SMA 5
lenS5 = input(200, minval=1, title="SMA 5 Length")
srcS5 = input(close, title="Source")
outS5 = sma(srcS5, lenS5)
plot(showSMA ? outS5 : na, color=#ffffff, title="SMA 5", linewidth=2)
//Get previous day/week bar and avoiding realtime calculation by taking the
previous to current bar
// //Calculate pivots
//center=(sclose)
h1=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
l1=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)
//Plotting
// //Camarilla levels
plot(showCamarilla ? h4_ : na, title="H4",color = (sopen != sopen[1] ? na :
#bcae2d), style=plot.style_cross, linewidth=2)
plot(showCamarilla ? h3_ : na, title="H3",color = (sopen != sopen[1] ? na :
#f0da19), style=plot.style_cross, linewidth=2)
plot(showCamarilla ? l3_ : na, title="L3",color = (sopen != sopen[1] ? na :
#00ff0e), style=plot.style_cross, linewidth=2)
plot(showCamarilla ? l4_ : na, title="L4",color = (sopen != sopen[1] ? na :
#389d3d), style=plot.style_cross, linewidth=2)