3c Indicator
3c Indicator
3c Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © chartcommandos
//@version=4
study("Chart Commando Combo", shorttitle="3C Indicator", overlay=true)
// User inputs
showTomorrowCPR = input(title="Show tomorrow's CPR", type=input.bool, defval=true)
showHistoricalCPR = input(title="Show historical CPR", type=input.bool,
defval=false)
showR3S3 = input(title="Show R3 & S3", type=input.bool, defval=false)
/////////////////////
// VWAP //
////////////////////
//////////////////
// BB //
//////////////////
length = input(20, minval=1)
src = input(close, title="BB_Source")
mult = input(2.0, minval=0.001, maxval=50, title="BB_StdDev")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
plot(showBB ? basis : na, "Basis", color=#872323, offset = offset)
p1 = plot(showBB ? upper : na, "Upper", color=color.teal, offset = offset)
p2 = plot(showBB ? lower: na, "Lower", color=color.teal, offset = offset)
fill(p1, p2, title = "Background", color=#198787, transp=95)
//////////////////
// EMA20 //
//////////////////
EMA20_Len = input(20, minval=1, title="EMA20_Length")
EMA20_src = input(close, title="EMA20_Source")
EMA20_offset = input(title="EMA20_Offset", type=input.integer, defval=0, minval=-
500, maxval=500)
EMA20_out = ema(EMA20_src, EMA20_Len)
plot(showEMA20 ? EMA20_out:na, title="EMA20", color=color.yellow,
offset=EMA20_offset)
//////////////////
// EMA9 //
//////////////////
EMA9_Len = input(9, minval=1, title="EMA9_Length")
EMA9_src = input(close, title="EMA9_Source")
EMA9_offset = input(title="EMA9_Offset", type=input.integer, defval=0, minval=-500,
maxval=500)
EMA9_out = ema(EMA9_src, EMA9_Len)
plot(showEMA9 ? EMA9_out:na, title="EMA9", color=color.blue, offset=EMA9_offset)
//////////////////
// EMA200 //
//////////////////
EMA200_Len = input(200, minval=1, title="EMA200_Length")
EMA200_src = input(close, title="EMA200_Source")
EMA200_offset = input(title="EMA200_Offset", type=input.integer, defval=0, minval=-
500, maxval=500)
EMA200_out = ema(EMA200_src, EMA200_Len)
plot(showEMA200 ? EMA200_out:na, title="EMA200", color=color.purple,
offset=EMA200_offset)
//////////////////
// PL && PH //
//////////////////
//previous day
prevDayHigh = security(syminfo.tickerid, 'D', high[1], lookahead=true)
prevDayLow = security(syminfo.tickerid, 'D', low[1], lookahead=true)
// Defaults
// CPR Colors
cprColor = color.yellow
rColor = color.fuchsia
sColor = color.aqua
// 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))))))))))))
// Skip Weekend
SkipWeekend(_date) =>
_d = dayofweek(_date)
_mul = _d == 6 ? 3 : _d == 7 ? 2 : 1
for i = 1 to noOfHolidays
if IsHoliday(_dt)
_dt := SkipWeekend(_dt)
continue
else
break
_dt
tom_start = start
tom_end = end
// Get series
getSeries(e, timeFrame) => security(syminfo.tickerid, "D", e,
lookahead=barmerge.lookahead_on)
// Pivot Range
P = (H + L + C) / 3
TC = (H + L)/2
BC = (P - TC) + P
// Resistance Levels
R3 = H + 2*(P - L)
R2 = P + (H - L)
R1 = (P * 2) - L
// Support Levels
S1 = (P * 2) - H
S2 = P - (H - L)
S3 = L - 2*(H - P)
// Pivot Range
tP = (tH + tL + tC) / 3
tTC = (tH + tL)/2
tBC = (tP - tTC) + tP
// Resistance Levels
tR3 = tH + 2*(tP - tL)
tR2 = tP + (tH - tL)
tR1 = (tP * 2) - tL
// Support Levels
tS1 = (tP * 2) - tH
tS2 = tP - (tH - tL)
tS3 = tL - 2*(tH - tP)