Camrilla
Camrilla
0 at
https://mozilla.org/MPL/2.0/
//@version=4
//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
// Label for S/R
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper
Round_it(x) =>
n = round(x / syminfo.mintick) * syminfo.mintick
//
///// GOLDEN ROPE
show_gr= input(false, "Show Golden Rope")
ema_200 = ema(close, 200)
plot(show_gr ? ema_200 : na, title="Golden Rope", color = color.yellow,
style=plot.style_line,linewidth=1, transp=0)
///// EMA
show_ema26= input(false, "Show EMA")
ema_26 = ema(close, 26)
plot(show_ema26 ? ema_26 : na, title="EMA 26", color = color.purple,
style=plot.style_line,linewidth=1, transp=0)
[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 : "+ 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)
plot(showDaily and dIsLast ? dH5 : na, title = "H5", color = dH5 != dH5[1] ? na :
color.blue, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dH4 : na, title = "H4", color = dH4 != dH4[1] ?
na :color.red, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dH3 : na, title = "H3", color = dH3 != dH3[1] ?
na :color.red, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dH2 : na, title = "H2", color = dH2 != dH2[1] ?
na :color.red, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dL2 : na, title = "L2", color = dL2 != dL2[1] ?
na :color.green, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dL3 : na, title = "L3", color = dL3 != dL3[1] ?
na :color.green, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dL4 : na, title = "L4", color = dL4 != dL4[1] ?
na :color.green, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dL5 : na, title = "L5", color = dL5 != dL5[1] ?
na :color.blue, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dH6 : na, title = "H6", color = dH6 != dH6[1] ?
na :color.blue, linewidth = 1, style = linestyle, transp = 0)
plot(showDaily and dIsLast ? dL6 : na, title = "L6", color = dL6 != dL6[1] ?
na :color.blue, 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 " +
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", type=input.integer, defval=34)
showWave = input(title="[GRaB] Show Wave", type=input.bool, defval=false)
emaHigh = ema(high,emaPeriod)
emaLow = ema(low,emaPeriod)
emaClose = ema(close,emaPeriod)
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=vwap(hlc3)
H = vwap(high)
L = vwap(low)
O = vwap(open)
C = vwap(close)
left_low = lowest(left)
left_high = highest(left)
newlow = low <= left_low
newhigh = high >= left_high
wc = color.new(color.black , transp = 100)
q = barssince(newlow)
w = 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=avg(H,L)
AVGOC=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=cci(hlc3,tke_period)
rsi=rsi(close,tke_period)
willr=(highest(high,tke_period)-close)/(highest(high,tke_period)-
lowest(low,tke_period)) * -100
stosk=stoch(close,high,low,tke_period)
upper_s = sum(volume * (change(hlc3) <= 0 ? 0 : hlc3), tke_period)
lower_s = sum(volume * (change(hlc3) >= 0 ? 0 : hlc3), tke_period)
mfi= rsi(upper_s, lower_s)
spacing = 7
length7 = 7
length14 = 14
length28 = 28
average(bp, tr_, length) => sum(bp, length) / sum(tr_, length)
high_ = max(high, close[1])
low_ = 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= ema(TKEline,tke_emaperiod)
showTKEdots= input(title="Show TKE dots", defval=false)
obb = input( 85, "[TKE] OB", input.integer)
oss = input( -5, "[TKE] OS", input.integer)
// 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
// If we are oversold
if(isOversold)
if(low <= ll)
ll := low
moveOversoldLabel()
laststate := 2
//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
ppoT = (lmas-lmal)/lmal*100
ppoB = (lmal - lmas)/lmal*100
// HULL MA
//FUNCTIONS
//HMA
HMA(_src, _length) => wma(2 * wma(_src, _length / 2) - wma(_src, _length),
round(sqrt(_length)))
//EHMA
EHMA(_src, _length) => ema(2 * ema(_src, _length / 2) - ema(_src, _length),
round(sqrt(_length)))
//THMA
THMA(_src, _length) => wma(wma(_src,_length / 3) * 3 - wma(_src, _length / 2) -
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 + cum(spreadvol)
window_len = input(28, minval=1, title='[vpt] Window Lenght')
v = spreadvol + cum(spreadvol)
smooth = sma(v, v_len)
v_spread = stdev(v - smooth, window_len)
shadow = (v - smooth) / v_spread * price_spread
smooth1 = input(3)
m = sma(out, smooth1)
plot(showvpt ? m : na , title='VPT', color=color.blue,linewidth=3, transp=0)
len=input(defval=20,minval=1)
p=close
sma=sma(p,len)
avg=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
buy = crossover(m,bott2)
sell=crossunder(m,top2)
typicalAtr = atr(lookbackPeriod)
firstBar_body_size = abs(close[1] - open[1])
firstBar_range = high[1] - low[1]
firstBar_body_pct = firstBar_body_size / firstBar_range
otypicalAtr = atr(olookbackPeriod)
ofirstBar_body_size = abs(close[1] - open[1])
ofirstBar_range = high[1] - low[1]