Camarilla++ - PineScript 5
Camarilla++ - PineScript 5
0 at
https://mozilla.org/MPL/2.0/
//@version=5
indicator('Camarilla++', overlay=true)
//Resources:
//GRaB Candles
//https://www.tradingview.com/script/W3CQILKS-GRaB-Candles/
//Inverse-Fisher-RSI-MTF2-
//https://www.tradingview.com/script/XDJWADe9-Inverse-Fisher-RSI-MTF2-alerts/
//https://www.tradingview.com/script/6mkMeGyw-strategy-MACD-and-RSI-alert/
//VWAP CANDLES
//https://www.tradingview.com/script/JNE22ckq-VWAP-Candles/
//RSI SWING
//https://www.tradingview.com/script/uHew29m1-RSI-Swing-Indicator-v2/
//Jurik-PPO-PercentileRank
//ttps://www.tradingview.com/script/EJUoaGdk-Jurik-PPO-PercentileRank-Mkt-Tops-
Bottoms/
//VPTbollfib
//https://www.tradingview.com/script/6cjUFQpc-VPTbollfib/
// Line Style
linestyle = lstyle == 'Solid' ? plot.style_line : lstyle == 'Circles' ? plot.style_circles :
plot.style_cross
Round_it(x) =>
n = math.round(x / syminfo.mintick) * syminfo.mintick
n
//
///// GOLDEN ROPE
show_gr = input(false, 'Show Golden Rope')
ema_200 = ta.ema(close, 200)
plot(show_gr ? ema_200 : na, title='Golden Rope', color=color.new(color.yellow, 0),
style=plot.style_line, linewidth=1)
///// EMA
show_ema26 = input(false, 'Show EMA')
ema_26 = ta.ema(close, 26)
plot(show_ema26 ? ema_26 : na, title='EMA 26', color=color.new(color.purple, 0),
style=plot.style_line, linewidth=1)
[dIsLast, dH6, dH5, dH4, dH3, dH2, dH1, dL1, dL2, dL3, dL4, dL5, dL6, dP, dPb, dPt] =
getData(ptf, false)
[tIsLast, tH6, tH5, tH4, tH3, tH2, tH1, tL1, tL2, tL3, tL4, tL5, tL6, tP, tPb, tPt] =
getData(ptf, true)
[wIsLast, wH6, wH5, wH4, wH3, wH2, wH1, wL1, wL2, wL3, wL4, wL5, wL6, wP,
wPb, wPt] = getData('W', false)
[mIsLast, mH6, mH5, mH4, mH3, mH2, mH1, mL1, mL2, mL3, mL4, mL5, mL6, mP,
mPb, mPt] = getData('M', false)
[yIsLast, yH6, yH5, yH4, yH3, yH2, yH1, yL1, yL2, yL3, yL4, yL5, yL6, yP, yPb, yPt] =
getData('12M', false)
/////
//W CPR
cpr_trans = color.new(color.white, transp=75)
if showWCPR
wcpr = line.new(time, wP, time + 60 * 60 * 24, wP, xloc=xloc.bar_time,
color=color.white, style=line.style_dashed, extend=extend.right)
line.delete(wcpr[1])
wcprb = line.new(time, wPb, time + 60 * 60 * 24, wPb, xloc=xloc.bar_time,
color=cpr_trans, style=line.style_dashed, extend=extend.right)
line.delete(wcprb[1])
wcprt = line.new(time, wPt, time + 60 * 60 * 24, wPt, xloc=xloc.bar_time,
color=cpr_trans, style=line.style_dashed, extend=extend.right)
line.delete(wcprt[1])
wcprl = label.new(time, wP, '
Weekly Pivot : ' + str.tostring(Round_it(wP)), xloc=xloc.bar_time, size=size.small,
textcolor=color.white, style=label.style_none, textalign=text.align_left)
label.delete(wcprl[1])
//D
plot(showDaily and dIsLast ? dP : na, title='Pivot', color=dP != dP[1] ? na : color.fuchsia,
linewidth=1, style=linestyle, transp=0)
plot(showDaily and dIsLast ? dPb : na, title='Pivot Botttom', color=dPb != dPb[1] ? na :
color.fuchsia, linewidth=1, style=linestyle, transp=0)
plot(showDaily and dIsLast ? dPt : na, title='Pivot Top', color=dPt != dPt[1] ? na :
color.fuchsia, linewidth=1, style=linestyle, transp=0)
if showTomorrow
tP_l = line.new(x1=time + 86400000 / 4, y1=tP, x2=time + 86400000, y2=tP,
xloc=xloc.bar_time, color=color.fuchsia, style=line.style_dashed)
line.delete(tP_l[1])
tPb_l = line.new(x1=time + 86400000 / 4, y1=tPb, x2=time + 86400000, y2=tPb,
xloc=xloc.bar_time, color=color.fuchsia, style=line.style_dashed)
line.delete(tPb_l[1])
tPt_l = line.new(x1=time + 86400000 / 4, y1=tPt, x2=time + 86400000, y2=tPt,
xloc=xloc.bar_time, color=color.fuchsia, style=line.style_dashed)
line.delete(tPt_l[1])
if showlabels
if showDaily
var label dPlabel = na
var label ds3label = na
var label ds4label = na
var label ds5label = na
var label ds6label = na
var label dr3label = na
var label dr4label = na
var label dr5label = na
var label dr6label = na
label.delete(dPlabel)
label.delete(ds3label)
label.delete(ds4label)
label.delete(ds5label)
label.delete(ds6label)
label.delete(dr3label)
label.delete(dr4label)
label.delete(dr5label)
label.delete(dr6label)
dPlabel := label.new(x=dist, y=dP, text=' P'+
str.tostring(Round_it(dP)), textalign=text.align_left, size=size.small,
textcolor=color.fuchsia, style=label.style_none, xloc=xloc.bar_time, yloc=yloc.price)
//GRaB Candles
emaPeriod = input(title='[GRaB] EMA Period', defval=34)
showWave = input(title='[GRaB] Show Wave', defval=false)
longCond = bool(na)
shortCond = bool(na)
longCond := xRSI > Overbought and signal < macd
shortCond := xRSI < Oversold and signal > macd
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1
// VWAP CANDLES
NormalVwap = ta.vwap(hlc3)
H = ta.vwap(high)
L = ta.vwap(low)
O = ta.vwap(open)
C = ta.vwap(close)
left = 30 //input(title="[VWAP Candles# bars to the left", type=integer, defval=30)
left_low = ta.lowest(left)
left_high = ta.highest(left)
newlow = low <= left_low
newhigh = high >= left_high
wc = color.new(color.black, transp=100)
q = ta.barssince(newlow)
w = ta.barssince(newhigh)
col2 = showVwap ? q < w ? #8B3A3A : #9CBA7F : wc
col2b = showVwap ? O > C ? color.red : color.lime : wc
col2c = showVwapLine ? O > C ? color.red : color.lime : wc
AVGHL = math.avg(H, L)
AVGOC = math.avg(O, C)
col = showVwap ? AVGHL > AVGOC ? color.lime : color.red : wc
col3 = showVwap ? open > AVGOC ? color.lime : color.red : wc
///TKE
//// TKE
tke_period = 14
tke_emaperiod = 5
momentum = close / close[tke_period] * 100
cci = ta.cci(hlc3, tke_period)
rsi = ta.rsi(close, tke_period)
willr = (ta.highest(high, tke_period) - close) / (ta.highest(high, tke_period) -
ta.lowest(low, tke_period)) * -100
stosk = ta.stoch(close, high, low, tke_period)
upper_s = math.sum(volume * (ta.change(hlc3) <= 0 ? 0 : hlc3), tke_period)
lower_s = math.sum(volume * (ta.change(hlc3) >= 0 ? 0 : hlc3), tke_period)
mfi = 100.0 - 100.0 / (1.0 + upper_s / lower_s)
spacing = 7
length7 = 7
length14 = 14
length28 = 28
average(bp, tr_, length) =>
math.sum(bp, length) / math.sum(tr_, length)
high_ = math.max(high, close[1])
low_ = math.min(low, close[1])
bp = close - low_
tr_ = high_ - low_
avg7 = average(bp, tr_, length7)
avg14 = average(bp, tr_, length14)
avg28 = average(bp, tr_, length28)
ult = 100 * (4 * avg7 + 2 * avg14 + avg28) / 7
TKEline = (ult + mfi + momentum + cci + rsi + willr + stosk) / 7
EMAline = ta.ema(TKEline, tke_emaperiod)
showTKEdots = input(title='Show TKE dots', defval=false)
obb = input(85, '[TKE] OB')
oss = input(-5, '[TKE] OS')
// Labels
var label labelll = na
var label labelhh = na
// Swing lines
var line line_up = na
var line line_down = na
// FUNCTIONS
obLabelText() =>
if last_actual_label_hh_price < high
'HH'
else
'LH'
//plot(last_actual_label_hh_price)
osLabelText() =>
if last_actual_label_ll_price < low
'HL'
else
'LL'
moveOverBoughtLabel() =>
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
label.set_text(labelhh, obLabelText())
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
// If we are overbought
if isOverbought
if high >= hh
hh := high
moveOverBoughtLabel()
laststate := 1
laststate
// If we are oversold
if isOversold
if low <= ll
ll := low
moveOversoldLabel()
laststate := 2
laststate
//If we are oversold and the last state was oversold, move the drawings to the lowest price
if laststate == 2 and isOversold
if low <= ll
ll := low
moveOversoldLabel()
// PPO
pctileB = pctile * -1
wrnpctileB = wrnpctile * -1
// HULL MA
//FUNCTIONS
//HMA
HMA(_src, _length) =>
ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length),
math.round(math.sqrt(_length)))
//EHMA
EHMA(_src, _length) =>
ta.ema(2 * ta.ema(_src, _length / 2) - ta.ema(_src, _length),
math.round(math.sqrt(_length)))
//THMA
THMA(_src, _length) =>
ta.wma(ta.wma(_src, _length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src,
_length), _length)
//SWITCH
Mode(modeSwitch, src, len) =>
modeSwitch == 'Hma' ? HMA(src, len) : modeSwitch == 'Ehma' ? EHMA(src, len) :
modeSwitch == 'Thma' ? THMA(src, len / 2) : na
//OUT
HULL = Mode(modeSwitch, src, length)
MHULL = HULL[0]
SHULL = HULL[2]
//COLOR
hullColor = switchColor ? HULL > HULL[2] ? #00ff00 : #ff0000 : #ff9800
//PLOT
///< Frame
Fi1 = plot(showHull ? MHULL : na, title='MHULL', color=hullColor,
linewidth=thicknesSwitch, transp=50)
Fi2 = plot(visualSwitch and showHull ? SHULL : na, title='SHULL', color=hullColor,
linewidth=thicknesSwitch, transp=50)
///< Ending Filler
fill(Fi1, Fi2, title='Band Filler', color=hullColor, transp=transpSwitch)
//vptBOlfib
source = close
hilow = (high - low) * 100
openclose = (close - open) * 100
vol = volume / hilow
spreadvol = openclose * vol
VPT = spreadvol + ta.cum(spreadvol)
window_len = input.int(28, minval=1, title='[vpt] Window Lenght')
v = spreadvol + ta.cum(spreadvol)
smooth = ta.sma(v, v_len)
v_spread = ta.stdev(v - smooth, window_len)
shadow = (v - smooth) / v_spread * price_spread
smooth1 = input(3)
m = ta.sma(out, smooth1)
plot(showvpt ? m : na, title='VPT', color=color.new(color.blue, 0), linewidth=3)
len = input.int(defval=20, minval=1)
p = close
sma = ta.sma(p, len)
avg = ta.atr(len)
fibratio1 = input(defval=1.618, title='Fibonacci Ratio 1')
fibratio2 = input(defval=2.618, title='Fibonacci Ratio 2')
fibratio3 = input(defval=4.236, title='Fibonacci Ratio 3')
r1 = avg * fibratio1
r2 = avg * fibratio2
r3 = avg * fibratio3
top3 = sma + r3
top2 = sma + r2
top1 = sma + r1
bott1 = sma - r1
bott2 = sma - r2
bott3 = sma - r3
typicalAtr = ta.atr(lookbackPeriod)
firstBar_body_size = math.abs(close[1] - open[1])
firstBar_range = high[1] - low[1]
firstBar_body_pct = firstBar_body_size / firstBar_range
otypicalAtr = ta.atr(olookbackPeriod)
ofirstBar_body_size = math.abs(close[1] - open[1])
ofirstBar_range = high[1] - low[1]