name
stringlengths 1
64
| url
stringlengths 44
135
| author
stringlengths 3
30
| author_url
stringlengths 34
61
| likes_count
int64 0
33.2k
| kind
stringclasses 3
values | pine_version
int64 1
5
| license
stringclasses 3
values | source
stringlengths 177
279k
|
---|---|---|---|---|---|---|---|---|
Erni Cute | https://www.tradingview.com/script/v0Q9r1kX-Erni-Cute/ | ungke | https://www.tradingview.com/u/ungke/ | 12 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4
study("Erni Cute", overlay = true)
//Resources:
//Camarilla Pivots Suite - Daily, Weekly, Monthly, Yearly S/R
//https://www.tradingview.com/v/VQaB8luz/
//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/
showDaily = input(title="Show Camarilla", defval=true)
ptf = input(title="Pivot Resolution", defval="D", options=["Current","D","W","M","12M"])
showlast = input(title = "Hide Historial", defval = false)
showlabels = input(title = "Show Labels", defval = true)
lstyle = input(title = "Line Style", options = ['Solid', 'Circles', 'Cross'], defval ='Solid')
showWCPR = input(title="Show Weekly Levels", defval=false)
showTomorrow= input(title="Show Future Pivot,H3,L3", defval=false)
showReg= input(title="Show Regression", defval=false)
showVwap= input(title="Show VWAP Candles", defval=false)
showVwapLine= input(title="Show VWAP Line", defval=false)
pbers = input(title="PivotBoss Extreme Reversal Setup", defval=false)
pbors = input(title="PivotBoss Outside Reversal Setup", defval=false)
changeColorPPO = input(title="Change Barcolor for PPO", type=input.bool, defval=false)
changeColor = input(title="Change Barcolor for GRaB", type=input.bool, defval=false)
// 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)
// Camarilla + CPR function
getData(t,tom) =>
highhtf = security(syminfo.tickerid, t, tom ? high : high[1], lookahead = barmerge.lookahead_on)
lowhtf = security(syminfo.tickerid, t, tom ? low : low[1], lookahead = barmerge.lookahead_on)
closehtf = security(syminfo.tickerid, t, tom ? close : close[1], lookahead = barmerge.lookahead_on)
range = highhtf - lowhtf
islast = showlast ? security(syminfo.tickerid, t, barstate.islast, lookahead = true) : true
H5 = (highhtf / lowhtf) * closehtf
H4 = closehtf + range * 1.1/2
H3 = closehtf + range * 1.1/4
H2 = closehtf + range * 1.1/6
H1 = closehtf + range * 1.1/12
H6 = H5 + 1.168 * (H5 - H4)
L1 = closehtf - range * 1.1/12
L2 = closehtf - range * 1.1/6
L3 = closehtf - range * 1.1/4
L4 = closehtf - range * 1.1/2
L5 = closehtf - (H5 - closehtf)
L6 = closehtf - (H6 - closehtf)
pivot = (highhtf + lowhtf + closehtf) / 3.0
bc = (highhtf + lowhtf) / 2.0
tc = pivot - bc + pivot
[islast,H6, H5, H4, H3, H2, H1, L1, L2, L3, L4, L5 ,L6 , pivot , bc , tc]
[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 : "+ 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])
wh3 = line.new(time, wH3 , time + 60 * 60 * 24, wH3, xloc=xloc.bar_time,color = color.red , style=line.style_dashed , extend=extend.right)
line.delete(wh3[1])
wh3l = label.new(time , wH3 , " Weekly H3 : "+ tostring(Round_it(wH3)) , xloc=xloc.bar_time, size=size.small,textcolor=color.red, style=label.style_none ,textalign = text.align_left )
label.delete(wh3l[1])
wh4 = line.new(time, wH4 , time + 60 * 60 * 24, wH4, xloc=xloc.bar_time,color = color.red , style=line.style_dashed , extend=extend.right)
line.delete(wh4[1])
wh4l = label.new(time , wH4 , " Weekly H4 : "+ tostring(Round_it(wH4)) , xloc=xloc.bar_time, size=size.small,textcolor=color.red, style=label.style_none ,textalign = text.align_left )
label.delete(wh4l[1])
wh5 = line.new(time, wH5 , time + 60 * 60 * 24, wH5, xloc=xloc.bar_time,color = color.red , style=line.style_dashed , extend=extend.right)
line.delete(wh5[1])
wh5l = label.new(time , wH5 , " Weekly H5 : "+ tostring(Round_it(wH5)) , xloc=xloc.bar_time, size=size.small,textcolor=color.red, style=label.style_none ,textalign = text.align_left )
label.delete(wh5l[1])
wl3 = line.new(time, wL3 , time + 60 * 60 * 24, wL3, xloc=xloc.bar_time,color = color.green , style=line.style_dashed , extend=extend.right)
line.delete(wl3[1])
wl3l = label.new(time , wL3 , " Weekly L3 : "+ tostring(Round_it(wL3)) , xloc=xloc.bar_time, size=size.small,textcolor=color.green, style=label.style_none ,textalign = text.align_left )
label.delete(wl3l[1])
wl4 = line.new(time, wL4 , time + 60 * 60 * 24, wL4, xloc=xloc.bar_time,color = color.green , style=line.style_dashed , extend=extend.right)
line.delete(wl4[1])
wl4l = label.new(time , wL4 , " Weekly L4 : "+ tostring(Round_it(wL4)) , xloc=xloc.bar_time, size=size.small,textcolor=color.green, style=label.style_none ,textalign = text.align_left )
label.delete(wl4l[1])
wl5 = line.new(time, wL5 , time + 60 * 60 * 24, wL5, xloc=xloc.bar_time,color = color.green , style=line.style_dashed , extend=extend.right)
line.delete(wl5[1])
wl5l = label.new(time , wL5 , " Weekly L5 : "+ tostring(Round_it(wL5)) , xloc=xloc.bar_time, size=size.small,textcolor=color.green, style=label.style_none ,textalign = text.align_left )
label.delete(wl5l[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])
tph3_l = line.new(x1=time + 86400000 / 4, y1=tH3,
x2=time + 86400000, y2=tH3 ,
xloc=xloc.bar_time , color = color.red , style=line.style_dashed)
line.delete(tph3_l[1])
tpl3_l = line.new(x1=time + 86400000 / 4, y1=tL3,
x2=time + 86400000, y2=tL3 ,
xloc=xloc.bar_time , color = color.green , style=line.style_dashed)
line.delete(tpl3_l[1])
var label tPlabel = na
var label tH3label = na
var label tL3label = na
tPlabel := label.new(x = time + 86400000 / 2, y = tP, text = " Next Pivot " + tostring(Round_it(tP)),size=size.small,textcolor=color.fuchsia, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
label.delete(tPlabel[1])
tH3label := label.new(x = time + 86400000 / 2, y = tH3, text = " Next H3 " + tostring(Round_it(tH3)),size=size.small,textcolor=color.red, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
label.delete(tH3label[1])
tL3label := label.new(x = time + 86400000 / 2, y = tL3, text = " Next L3 " + tostring(Round_it(tL3)),size=size.small,textcolor=color.green, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
label.delete(tL3label[1])
dist = time + chper *2
wdist = time + chper * 2
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)
ds3label := label.new( x = dist,y = dL3, text = " L3 " + tostring(Round_it(dL3)),textalign = text.align_left, size=size.small,textcolor=color.green, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
ds4label := label.new(x = dist, y = dL4, text = " L4 " + tostring(Round_it(dL4)),textalign = text.align_left, size=size.small,textcolor=color.green, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
ds5label := label.new(x = dist, y = dL5, text = " L5 " + tostring(Round_it(dL5)),textalign = text.align_left, size=size.small,textcolor=color.blue, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
ds6label := label.new(x = dist, y = dL6, text = " L6 " + tostring(Round_it(dL6)),textalign = text.align_left, size=size.small,textcolor=color.blue, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
dr3label := label.new(x = dist, y = dH3, text = " H3 " + tostring(Round_it(dH3)), textalign = text.align_left,size=size.small,textcolor=color.red, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
dr4label := label.new(x = dist, y = dH4, text = " H4 " + tostring(Round_it(dH4)), textalign = text.align_left, size=size.small,textcolor=color.red, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
dr5label := label.new(x = dist, y = dH5, text = " H5 " + tostring(Round_it(dH5)), textalign = text.align_left,size=size.small,textcolor=color.blue, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
dr6label := label.new(x = dist, y = dH6, text = " H6 " + tostring(Round_it(dH6)), textalign = text.align_left,size=size.small,textcolor=color.blue, 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)
waveHigh = showWave == true ? emaHigh : na
waveLow = showWave == true ? emaLow : na
waveClose = showWave == true ? emaClose : na
plot(waveHigh, title="EMA High",color=color.red )
plot(waveLow, title="EMA Low", color=color.blue)
plot(waveClose, title="EMA Close", color=color.silver)
barcolor(close < emaLow and changeColor ? close > open ? color.red : color.maroon : close > emaHigh and changeColor ? close > open ? color.blue : color.navy : close > open and changeColor ? color.silver : changeColor ? color.gray : na)
fastLength = 8 //input(8, minval=1)
slowLength = 16//input(16,minval=1)
signalLength= 11//input(11,minval=1)
fastMA = ema(close, fastLength)
slowMA = ema(close, slowLength)
macd = fastMA - slowMA
signal = sma(macd, signalLength)
Length = 10 //input(10, minval=1)
Oversold = 49//input(49, minval=1)
Overbought = 51//input(51, minval=1)
xRSI = rsi(close, Length)
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
plotshape(longCondition, title="RSI/MACD up", textcolor=color.white, style=shape.arrowup, size=size.tiny, location=location.belowbar, color=color.green, transp=0)
plotshape(shortCondition, title="RSI/MACD down", textcolor=color.white, style=shape.arrowdown, size=size.tiny, location=location.abovebar, color=color.red, transp=0)
period = input( 150, "[Regr] Period" , input.integer, minval=3)
deviations = input( 2.0, "[Regr] Deviation(s)" , input.float , minval=0.1, step=0.1)
extendType = input("Right", "[Regr] Extend Method", input.string , options=["Right","None"])=="Right" ? extend.right : extend.none
periodMinusOne = period-1
Ex = 0.0, Ey = 0.0, Ex2 = 0.0, Exy = 0.0, for i=0 to periodMinusOne
closeI = nz(close[i]), Ex := Ex + i, Ey := Ey + closeI, Ex2 := Ex2 + (i * i), Exy := Exy + (closeI * i)
ExEx = Ex * Ex, slope = Ex2==ExEx ? 0.0 : (period * Exy - Ex * Ey) / (period * Ex2 - ExEx)
linearRegression = (Ey - slope * Ex) / period
intercept = linearRegression + bar_index * slope
deviation = 0.0, for i=0 to periodMinusOne
deviation := deviation + pow(nz(close[i]) - (intercept - slope * (bar_index[i])), 2.0)
deviation := deviations * sqrt(deviation / periodMinusOne)
startingPointY = linearRegression + slope * periodMinusOne
if showReg
var line upperChannelLine = na , var line medianChannelLine = na , var line lowerChannelLine = na
line.delete(upperChannelLine[1]), line.delete(medianChannelLine[1]), line.delete(lowerChannelLine[1])
upperChannelLine := line.new(bar_index - period + 1, startingPointY + deviation, bar_index, linearRegression + deviation, xloc.bar_index, extendType, color.new(#FF0000, 0), line.style_solid , 2)
medianChannelLine := line.new(bar_index - period + 1, startingPointY , bar_index, linearRegression , xloc.bar_index, extendType, color.new(#C0C000, 0), line.style_solid , 1)
lowerChannelLine := line.new(bar_index - period + 1, startingPointY - deviation, bar_index, linearRegression - deviation, xloc.bar_index, extendType, color.new(#00FF00, 0), line.style_solid , 2)
// VWAP CANDLES
NormalVwap=vwap(hlc3)
H = vwap(high)
L = vwap(low)
O = vwap(open)
C = vwap(close)
left = 30 //input(title="[VWAP Candles# bars to the left", type=integer, defval=30)
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
plotcandle(O,H,L,C,color=col2b , wickcolor = wc , bordercolor = wc)
plot(showVwapLine ? NormalVwap : na, color=col2c)
///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)
//plotshape(TKEline >= obb and showTKEdots, color=color.orange, transp=50, style=shape.circle, size=size.tiny, location=location.abovebar, title="TKE OS")
//plotshape(TKEline >= 80 and showTKEdots, color=color.yellow, transp=50, style=shape.circle, size=size.tiny, location=location.abovebar, title="TKE OS 2")
plotshape(crossunder(TKEline ,obb) and showTKEdots, color=color.red, transp=20, style=shape.circle, size=size.tiny, location=location.abovebar, title="TKE OB cross")
//plotshape(TKEline <= oss and showTKEdots, color=color.yellow, transp=50, style=shape.circle, size=size.tiny, location=location.belowbar, title="TKE OS")
plotshape(crossover(TKEline ,0) and showTKEdots, color=color.green, transp=20, style=shape.circle, size=size.tiny, location=location.belowbar, title="KE OS cross")
//// RSI SWING
// RSI Settings for user
rsiShow = input(title="[RSI Swing] Show Indicator", defval=false)
rsiSource = input(title="[RSI Swing] Source", type=input.source, defval=close)
rsiLength = input(title="[RSI Swing] Length", type=input.integer, defval=7)
rsiOverbought = input(title="[RSI Swing] OB", type=input.integer, defval=70, minval=51, maxval=100)
rsiOvesold = input(title="[RSI Swing] OS", type=input.integer, defval=30, minval=1, maxval=49)
// RSI value based on inbuilt RSI
rsiValue = rsi(rsiSource, rsiLength)
// Get the current state
isOverbought = rsiValue >= rsiOverbought
isOversold = rsiValue <= rsiOvesold
// State of the last extreme 0 for initialization, 1 = overbought, 2 = oversold
var laststate = 0
// Highest and Lowest prices since the last state change
var hh = low
var ll = high
// Labels
var label labelll = na
var label labelhh = na
// Swing lines
var line line_up = na
var line line_down = na
var last_actual_label_hh_price = 0.0
var last_actual_label_ll_price = 0.0
// 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"
// Create oversold or overbought label
createOverBoughtLabel(isIt) =>
if(isIt)
label.new(x=bar_index, y=na ,yloc=yloc.abovebar, style=label.style_label_down, color=color.red, size=size.tiny, text=obLabelText())
else
label.new(x=bar_index, y=na ,yloc=yloc.belowbar, style=label.style_label_up, color=color.green, size=size.tiny, text=osLabelText())
// Move the oversold swing and label
moveOversoldLabel() =>
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
label.set_text(labelll, osLabelText())
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
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)
// We go from oversold straight to overbought NEW DRAWINGS CREATED HERE
if(laststate == 2 and isOverbought and rsiShow)
hh := high
labelhh := createOverBoughtLabel(true)
last_actual_label_ll_price := label.get_y(labelll)
labelll_ts = label.get_x(labelll)
labelll_price = label.get_y(labelll)
line_up := line.new(x1=bar_index, y1=high, x2=labelll_ts, y2=labelll_price, width=1)
// We go from overbought straight to oversold NEW DRAWINGS CREATED HERE
if(laststate == 1 and isOversold and rsiShow)
ll := low
labelll := createOverBoughtLabel(false)
last_actual_label_hh_price := label.get_y(labelhh)
labelhh_ts = label.get_x(labelhh)
labelhh_price = label.get_y(labelhh)
line_down := line.new(x1=bar_index, y1=high, x2=labelhh_ts, y2=labelhh_price, width=1)
// 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 last state was overbought and we are overbought
if(laststate == 1 and isOverbought)
if(hh <= high)
hh := high
moveOverBoughtLabel()
//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()
// If last state was overbought
if(laststate == 1)
if(hh <= high)
hh := high
moveOverBoughtLabel()
// If last stare was oversold
if(laststate == 2)
if(ll >= low)
ll := low
moveOversoldLabel()
// PPO
pctile = 90//input(90, title="Percentile Threshold Extreme Value, Exceeding Creates Colored Histogram")
wrnpctile = 75//input(75, title="Percentile Threshold Warning Value, Exceeding Creates Colored Histogram")
ma_source = close//input(title="Source", type=source, defval=close)
short_length = 35//input(title="Length - Short", type=integer, defval=35)
short_phase = 2//input(title="Phase - Short", type=integer, defval=2)
short_power = 2//input(title="Power - Short", type=integer, defval=2)
long_length = 75//input(title="Length - Long", type=integer, defval=75)
long_phase = 2//input(title="Phase - Long", type=integer, defval=2)
long_power = 2//input(title="Power - Long", type=integer, defval=2)
lkb = input(200,title="[PPO] Look Back Period ")
// Jurik MA Calculation by everget
get_jurik(length, phase, power, src)=>
phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5
beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)
alpha = pow(beta, power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 = 0.0
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
lmas = get_jurik(short_length, short_phase, short_power, ma_source)
lmal = get_jurik(long_length, long_phase, long_power, ma_source)
pctileB = pctile * -1
wrnpctileB = wrnpctile * -1
ppoT = (lmas-lmal)/lmal*100
ppoB = (lmal - lmas)/lmal*100
pctRankT = percentrank(ppoT, lkb)
pctRankB = percentrank(ppoB, lkb) * -1
colT = pctRankT >= pctile ? color.red : pctRankT >= wrnpctile and pctRankT < pctile ? color.orange : color.gray
colB = pctRankB <= pctileB ? color.lime : pctRankB <= wrnpctileB and pctRankB > pctileB ? color.green : color.silver
colFinal = color.silver
if (pctRankT >= pctile or (pctRankT >= wrnpctile and pctRankT < pctile))
colFinal := colT
if(pctRankB <= pctileB or (pctRankB <= wrnpctileB and pctRankB > pctileB))
colFinal := colB
barcolor(changeColorPPO ? colFinal: na)
// HULL MA
src = close//input(close, title="Source")
showHull = input(title="[Hull] Show indicator",defval=false)
modeSwitch = input("Hma", title="[Hull] Variation", options=["Hma", "Thma", "Ehma"])
length = input(55, title="[Hull] Length(180-200 for floating S/R , 55 for swing entry)")
switchColor = input(true, "[Hull] Color according to trend?")
//candleCol = input(false,title="Color candles based on Hull's Trend?")
visualSwitch = input(true, title="[Hull] Show as a Band?")
thicknesSwitch = input(1, title="[Hull] Line Thickness")
transpSwitch = input(40, title="[Hull] Band Transparency",step=5)
//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
showvpt = input(title="[vpt] Show bands",defval=false)
showvptar = input(title="[vpt] Show arrows",defval=true)
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_len = input(14, defval=14, minval=1, title='[vpt] smooth Lenght')
price_spread = stdev(high-low, window_len)
v = spreadvol + cum(spreadvol)
smooth = sma(v, v_len)
v_spread = stdev(v - smooth, window_len)
shadow = (v - smooth) / v_spread * price_spread
out = shadow > 0 ? high + shadow : low + shadow
color = shadow > 0 ? color.green : color.red
// out = close > close[1] ? shadow : -shadow
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
t3=plot(showvpt ? top3 : na,transp=0,title="Upper 3",color=color.red)
t2=plot(showvpt ? top2 : na,transp=20,title="Upper 2",color=color.teal)
t1=plot(showvpt ? top1 : na,transp=40,title="Upper 1",color=color.teal)
b1=plot(showvpt ? bott1 : na,transp=40,title="Lower 1",color=color.teal)
b2=plot(showvpt ? bott2 : na,transp=20,title="Lower 2",color=color.teal)
b3=plot(showvpt ? bott3 : na,transp=0,title="Lower 3",color=color.red)
plot(showvpt ? sma : na,style=plot.style_line,title="SMA",color=color.black)
fill(t3,b3,color=color.yellow,transp=90)
fill(t2,b2,color=color.green,transp=90)
buy = crossover(m,bott2)
sell=crossunder(m,top2)
plotshape(showvptar ? sell : na, title="sell", style=shape.triangledown,location=location.abovebar, color=color.red, transp=0, size=size.small)
plotshape(showvptar ? buy : na, title="buy", style=shape.triangleup,location=location.belowbar, color=color.green, transp=0, size=size.small)
// Pivot Boss Reversal
lookbackPeriod = 20//input(title="Lookback Period", type=integer, defval=20, minval=0)
atrMultiplier = 2//input(title="Bar ATR Multiplier", type=float, defval=2.0, minval=0)
barBodyPercentMin = 0.65//input(title="Minimum Bar Body %", type=float, defval=0.65, minval=0.0, maxval=1.0)
barBodyPercentMax = 0.85//input(title="Maximum Bar Body %", type=float, defval=0.85, minval=0.0, maxval=1.0)
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
firstBar_signal = (firstBar_range > (atrMultiplier * typicalAtr)) and (firstBar_body_pct >= barBodyPercentMin) and (firstBar_body_pct <= barBodyPercentMax)
bull_signal = firstBar_signal and (close[1] < open[1]) and (close > open)
bear_signal = firstBar_signal and (close[1] > open[1]) and (close < open)
plotshape(pbers and bull_signal , "Bullish Reversal", shape.labelup, location.belowbar, color.green,
text="XR", textcolor=color.black, size=size.tiny)
plotshape(pbers and bear_signal, "Bearish Reversal", shape.labeldown, location.abovebar, color.red,
text="XR", textcolor=color.black, size=size.tiny)
olookbackPeriod = 20//input(title="Lookback Period", type=integer, defval=20, minval=0)
oatrMultiplier = 1.05//input(title="Bar ATR Multiplier", type=float, defval=1.05, minval=0)
otypicalAtr = atr(olookbackPeriod)
ofirstBar_body_size = abs(close[1] - open[1])
ofirstBar_range = high[1] - low[1]
ofirstBar_signal = (ofirstBar_range > (oatrMultiplier * otypicalAtr))
obull_signal = (low < low[1]) and (close > high[1]) and ofirstBar_signal
obear_signal = (high > high[1]) and (close < low[1]) and ofirstBar_signal
plotshape(pbors and obull_signal, "Bullish Reversal", shape.labelup, location.belowbar, color.green,
text="OR", textcolor=color.black, size=size.tiny)
plotshape(pbors and obear_signal, "Bearish Reversal", shape.labeldown, location.abovebar, color.red,
text="OR", textcolor=color.black, size=size.tiny)
|
Stoma Trading | https://www.tradingview.com/script/a7jsJxa9-Stoma-Trading/ | PlsName | https://www.tradingview.com/u/PlsName/ | 7 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © payachonpooh5102
//@version=5
//Author SKiNNiEH 3-15-2022
indicator(title='EMA Cross', shorttitle="StomaTrading", overlay=true)
fastLength = input.int(34, title="Fast EMA")
slowLength = input.int(89, title="Slow EMA")
fast = ta.ema(close, fastLength)
slow = ta.ema(close, slowLength)
plotFast = plot(fast, color = color.new(color.blue, 0), title="Fast EMA")
plotSlow = plot(slow, color = color.new(color.red, 0), title="Slow EMA")
plot(ta.cross(fast, slow) ? slow : na, style=plot.style_cross, linewidth=3, color=color.new(color.white, 0), title="EMA Cross")
fill(plotFast, plotSlow, color = fast > slow ? color.new(color.green, 85) : color.new(color.red,85), title = "Background")
|
Colorful Rainbow | https://www.tradingview.com/script/6HeaAxoI/ | TheSaltyAustin | https://www.tradingview.com/u/TheSaltyAustin/ | 45 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheSaltyAustin
//@version=5
indicator("Rainbowwwww", overlay=true)
// indicator("Rainbowwwww", overlay=false)
//1636502400000: $64854
//1618358400000: $69000
// plot(time)
plot(ta.ema(close, 2), color=#FF1E00)
plot(ta.ema(close, 4), color=#FF3C00)
plot(ta.ema(close, 6), color=#FF5A00)
plot(ta.ema(close, 8), color=#FF7800)
plot(ta.ema(close, 10), color=#FF9600)
plot(ta.ema(close, 12), color=#FFB400)
plot(ta.ema(close, 14), color=#FFD200)
plot(ta.ema(close, 16), color=#FFF000)
plot(ta.ema(close, 18), color=#F0FF00)
plot(ta.ema(close, 20), color=#D2FF00)
plot(ta.ema(close, 22), color=#B4FF00)
plot(ta.ema(close, 24), color=#96FF00)
plot(ta.ema(close, 26), color=#78FF00)
plot(ta.ema(close, 28), color=#5AFF00)
plot(ta.ema(close, 30), color=#3CFF00)
plot(ta.ema(close, 32), color=#1EFF00)
plot(ta.ema(close, 34), color=#00FF00)
plot(ta.ema(close, 36), color=#00FF1E)
plot(ta.ema(close, 38), color=#00FF3C)
plot(ta.ema(close, 40), color=#00FF5A)
plot(ta.ema(close, 42), color=#00FF78)
plot(ta.ema(close, 44), color=#00FF96)
plot(ta.ema(close, 46), color=#00FFB4)
plot(ta.ema(close, 48), color=#00FFD2)
plot(ta.ema(close, 50), color=#00FFF0)
plot(ta.ema(close, 52), color=#00F0FF)
plot(ta.ema(close, 54), color=#00D2FF)
plot(ta.ema(close, 56), color=#00B4FF)
plot(ta.ema(close, 58), color=#0096FF)
plot(ta.ema(close, 60), color=#0078FF)
plot(ta.ema(close, 62), color=#005AFF)
plot(ta.ema(close, 64), color=#003CFF)
plot(ta.ema(close, 66), color=#001EFF)
plot(ta.ema(close, 68), color=#0000FF)
|
Roof and Floors From Actieve Inversiones | https://www.tradingview.com/script/pLFry9GY/ | Jesus_Salvatierra | https://www.tradingview.com/u/Jesus_Salvatierra/ | 33 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Jjsch
//@version=4
study("Roof and Floors Actieve - Basic ", overlay=true, max_bars_back=1001)//max bars back sirve para que el indicador le diga el maximo de velas que usaremos
barras = input(220, title="Bars", minval= 10, maxval=1000)
//obtener el minimo y obtener el maximo de x numero de periodos
minimo_precio = lowest(barras) //este es el eje x
minimo_barra = abs(lowestbars(barras)) //este es el eje y
maximo_precio = highest(barras)
maximo_barra = abs(highestbars(barras))
line50 = minimo_precio+ (maximo_precio - minimo_precio) * 0.5
line61 = minimo_precio+ (maximo_precio - minimo_precio) * 0.618
line38 = minimo_precio+ (maximo_precio - minimo_precio) * 0.382
x2 = max(minimo_barra, maximo_barra)
if barstate.islast //ATENCION!!! TODA ESTA FORMULA ES PARA CREAR LAS LINEAS DE EXTREMOS DE LOS FIBO
precio_50 = minimo_precio + (maximo_precio - minimo_precio) * 0.5
precio_618 = 0.0 //hay que redefinir un numero, por eso usamos este signo
x = max(minimo_barra, maximo_barra)
if minimo_barra > maximo_barra
precio_618 := maximo_precio - (maximo_precio - minimo_precio) * 0.618
else //tambien
precio_618 := minimo_precio + (maximo_precio - minimo_precio) * 0.618
erase1=line.new(bar_index[x],minimo_precio, bar_index[0], minimo_precio, color=color.new(color.black,40), style=line.style_solid, extend=extend.both)
erase2=line.new(bar_index[x],maximo_precio, bar_index[0], maximo_precio, color=color.new(color.black,40), style=line.style_solid, extend=extend.both)
line.delete(erase1)
line.delete(erase2)
//{LINEAS Y ETIQUETAS
secmin =security(syminfo.tickerid, "D", minimo_precio)
secmax =security(syminfo.tickerid, "D", maximo_precio)
delmin=line.new(bar_index[x2], secmin, bar_index[0], secmin, width=7 ,color=color.new(color.black,40) , extend= extend.both)
delmax=line.new(bar_index[x2], secmax, bar_index[0], secmax, width=7 ,color=color.new(color.black,40) , extend= extend.both)
line.delete(delmin[1])
line.delete(delmax[1])
la100= label.new(bar_index[200], secmax, text= " Metal Roof ", color= color.new(color.black,40), textcolor= color.white )
label.delete(la100[1])
la0= label.new(bar_index[200], secmin, text= " Metal Floor ", color= color.new(color.black,40), textcolor= color.white )
label.delete(la0[1])
fhmin =security(syminfo.tickerid, "240", minimo_precio)
fhmax =security(syminfo.tickerid, "240", maximo_precio)
fhdelmin=line.new(bar_index[x2], fhmin, bar_index[0], fhmin, width=5,color=color.new(color.red,40) , extend= extend.both)
fhdelmax=line.new(bar_index[x2], fhmax, bar_index[0], fhmax, width=5,color=color.new(color.red,40) , extend= extend.both)
line.delete(fhdelmin[1])
line.delete(fhdelmax[1])
fhla100= label.new(bar_index[200], fhmax, text= " Wooden Roof ", color= color.new(color.red,40), textcolor= color.white )
label.delete(fhla100[1])
fhla0= label.new(bar_index[200], fhmin, text= " Wooden Floor ", color= color.new(color.red,40), textcolor= color.white )
label.delete(fhla0[1])
hourmin =security(syminfo.tickerid, "60", minimo_precio)
hourmax =security(syminfo.tickerid, "60", maximo_precio)
hourdelmin=line.new(bar_index[x2], hourmin, bar_index[0], hourmin, width=3 ,color=color.new(color.blue,40) , extend= extend.both)
hourdelmax=line.new(bar_index[x2], hourmax, bar_index[0], hourmax, width=3 ,color=color.new(color.blue,40) , extend= extend.both)
line.delete(hourdelmin[1])
line.delete(hourdelmax[1])
hourla100= label.new(bar_index[200], hourmax, text= " Plastic Roof ", color= color.new(color.blue, 40), textcolor= color.white )
label.delete(hourla100[1])
hourla0= label.new(bar_index[200], hourmin, text= " Plastic Floor ", color= color.new(color.blue, 40), textcolor= color.white )
label.delete(hourla0[1])
thirtymin =security(syminfo.tickerid, "30", minimo_precio)
thirtymax =security(syminfo.tickerid, "30", maximo_precio)
thirtydelmin=line.new(bar_index[x2], thirtymin, bar_index[0], thirtymin, width= 2,color=color.new(color.green,40) , extend= extend.both)
thirtydelmax=line.new(bar_index[x2], thirtymax, bar_index[0], thirtymax, width= 2,color=color.new(color.green,40) , extend= extend.both)
line.delete(thirtydelmin[1])
line.delete(thirtydelmax[1])
thirtyla100= label.new(bar_index[200], thirtymax, text= "Paper Roof", color= color.new(color.green,40), textcolor= color.white )
label.delete(thirtyla100[1])
thirtyla0= label.new(bar_index[200], thirtymin, text= "Paper Floor", color= color.new(color.green,40), textcolor= color.white )
label.delete(thirtyla0[1])
fivemin =security(syminfo.tickerid, "5", minimo_precio)
fivemax =security(syminfo.tickerid, "5", maximo_precio)
fivedelmin=line.new(bar_index[x2], fivemin, bar_index[0], fivemin, color=color.new(color.silver,10) , extend= extend.both)
fivedelmax=line.new(bar_index[x2], fivemax, bar_index[0], fivemax, color=color.new(color.silver,10) , extend= extend.both)
line.delete(fivedelmin[1])
line.delete(fivedelmax[1])
fivela100= label.new(bar_index[200], fivemax, text= "Cristal Roof", color= color.new(color.silver,10), textcolor= color.white )
label.delete(fivela100[1])
fivela0= label.new(bar_index[200], fivemin, text= "Cristal Floor", color= color.new(color.silver,10), textcolor= color.white )
label.delete(fivela0[1])
//}LINEAS Y ETIQUETAS
//{RUPTURAS
prevFive_min= close < fivemin[20]? line.new(bar_index[1], fivemin[20], bar_index, fivemin[20],
color=color.new(color.silver,40),
extend=extend.both):na
line.delete(prevFive_min[1])
delPrevFive_min=close < fivemin[20]? label.new(bar_index[10],fivemin[20],
text="Broken Floor",
color=color.new(color.silver,40),
textcolor= color.white):na
label.delete(delPrevFive_min[1])
prevFive_max = close > fivemax[20]? line.new(bar_index[1], fivemax[20], bar_index, fivemax[20],
color=color.new(color.silver,40),
extend=extend.both):na
line.delete(prevFive_max[1])
delPrevFive_max = close > fivemax[20]? label.new(bar_index[10],fivemax[20],
text="Broken Roof",
textcolor=color.white,
color=color.new(color.silver,40)):na
label.delete(delPrevFive_max[1])
prevthirty_min= close < thirtymin[20]? line.new(bar_index[1], thirtymin[20], bar_index, thirtymin[20],
style=line.style_dashed,
color=color.new(color.green,40),
extend=extend.both,
width=2):na
line.delete(prevthirty_min[1])
delPrevthirty_min=close < thirtymin[20]? label.new(bar_index[10],thirtymin[20],
text="Broken Floor",
color=color.new(color.green,40),
textcolor=color.white):na
label.delete(delPrevthirty_min[1])
prevthirty_max = close > thirtymax[20]? line.new(bar_index[1], thirtymax[20], bar_index, thirtymax[20],
style=line.style_dashed,
color=color.new(color.green,40),
extend=extend.both,
width=2):na
line.delete(prevthirty_max[1])
delPrevthirty_max = close > thirtymax[20]? label.new(bar_index[10],thirtymax[20],
text="Broken Roof",
textcolor=color.white,
color=color.new(color.green,40)):na
label.delete(delPrevthirty_max[1])
prevhour_min= close < hourmin[20]? line.new(bar_index[1], hourmin[20], bar_index, hourmin[20],
style=line.style_dashed,
color=color.new(color.blue,40),
extend=extend.both,
width=3):na
line.delete(prevhour_min[1])
delPrevhour_min=close < hourmin[20]? label.new(bar_index[10],hourmin[20],
text="Broken Floor",
color=color.new(color.blue,40),
textcolor=color.white):na
label.delete(delPrevhour_min[1])
prevhour_max = close > hourmax[20]? line.new(bar_index[1], hourmax[20], bar_index, hourmax[20],
style=line.style_dashed,
color=color.new(color.blue,40),
extend=extend.both,
width=3):na
line.delete(prevhour_max[1])
delPrevhour_max = close > hourmax[20]? label.new(bar_index[10],hourmax[20],
text=" Broken Roof ",
textcolor=color.white,
color=color.new(color.blue,40)):na
label.delete(delPrevhour_max[1])
prevfh_min= close < fhmin[20]? line.new(bar_index[1], fhmin[20], bar_index, fhmin[20],
style=line.style_dashed,
color=color.new(color.red,40),
extend=extend.both,
width=5):na
line.delete(prevfh_min[1])
delPrevfh_min=close < fhmin[20]? label.new(bar_index[10],fhmin[20],
text=" Broken Floor ",
color=color.new(color.red,40),
textcolor=color.white):na
label.delete(delPrevfh_min[1])
prevfh_max = close > fhmax[20]? line.new(bar_index[1], fhmax[20], bar_index, fhmax[20],
style=line.style_dashed,
color=color.new(color.red,40),
extend=extend.both,
width=5):na
line.delete(prevfh_max[1])
delPrevfh_max = close > fhmax[20]? label.new(bar_index[10],fhmax[20],
text=" Broken Roof ",
textcolor=color.white,
color=color.new(color.red,40)):na
label.delete(delPrevfh_max[1])
prevsecmin= close < secmin[20]? line.new(bar_index[1], secmin[20], bar_index, secmin[20],
style=line.style_dashed,
color=color.new(color.black,40),
extend=extend.both,
width=7):na
line.delete(prevsecmin[1])
delPrevsecmin=close < secmin[20]? label.new(bar_index[10],secmin[20],
text=" Broken Floor ",
color=color.new(color.black,40),
textcolor=color.white):na
label.delete(delPrevsecmin[1])
prevsecmax = close > secmax[20]? line.new(bar_index[1], secmax[20], bar_index, secmax[20],
style=line.style_dashed,
color=color.new(color.black,40),
extend=extend.both,
width=7):na
line.delete(prevsecmax[1])
delPrevsecmax = close > secmax[20]? label.new(bar_index[10],secmax[20],
text=" Broken Roof ",
textcolor=color.white,
color=color.new(color.black,40)):na
label.delete(delPrevsecmax[1])
//RUPTURAS}
|
3EMA + Boullinger + PIVOT | https://www.tradingview.com/script/Vtiv2WxG/ | JCMR76 | https://www.tradingview.com/u/JCMR76/ | 402 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © JCMR76
//@version=4
study("3EMA + Boullinger + PIVOT", overlay=true)
// TRES EMAS - THREE EMA´s
periodo1 = input(8, title="Periodo 1, Length 1=", step =1, minval=1, maxval=300)
periodo2 = input(20, title="Periodo 2, Length 2=", step =1, minval=1, maxval=300)
periodo3 = input(200, title="Periodo 3, Length 3=", step =1, minval=1, maxval=1000)
plot(ema(close,periodo1), color=color.gray, linewidth=1)
plot(ema(close,periodo2), color=color.green, linewidth=1)
plot(ema(close,periodo3), color=color.purple, linewidth=3)
//BANDA BOLLINGER - BANDS BOLLINGER
longitudbb = input(20,title = "longitudBB, LenghtBB=", type = input.integer, step = 1, minval=1, maxval=50)
multbb = input(2.0, title = "Multiplicadorbb, EstDesv = ", type= input.float, step = 0.2, minval=0.2, maxval=20)
fuente = input(close, title="fuente", type=input.source)
[mm,banda_sup, banda_inf] = bb(fuente, longitudbb,multbb)
ps=plot(banda_sup, color=color.new(color.gray, 90))
pi=plot(banda_inf, color=color.new(color.gray, 90))
fill(ps,pi,color=color.new(color.gray,80))
//PIVOT - PIVOTE
dist = input(6, title ="distancia para el pivote/ distance to pivot ", type = input.integer, step = 1)
pl = pivotlow(low, dist, dist)
if not na(pl)
label.new(bar_index[dist], pl, text="Buy", style=label.style_label_up, textcolor=color.yellow, size=size.small, color=color.green)
ph = pivothigh(high, dist, dist)
if not na(ph)
label.new(bar_index[dist], ph, text="Sell",style=label.style_label_down, textcolor=color.yellow, size=size.small, color=color.red)
//PIVOT - PIVOTE
|
TotalCap RSI and Pressure Candle | https://www.tradingview.com/script/0dl6mhR2/ | CuerpoTiempoEspacio | https://www.tradingview.com/u/CuerpoTiempoEspacio/ | 23 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CuerpoTiempoEspacio
study(title = "TotalCap RSI and Pressure Candle", overlay=false)
//@version=4
TotalCapHigh= security('CRYPTOCAP:TOTAL', resolution= timeframe.period, expression=high)
TotalCapLow= security('CRYPTOCAP:TOTAL', resolution= timeframe.period, expression=low)
TotalCapOpen= security('CRYPTOCAP:TOTAL', resolution= timeframe.period, expression=open)
TotalCapClose= security('CRYPTOCAP:TOTAL', resolution= timeframe.period, expression=close)
Bearich= TotalCapOpen>TotalCapClose?1:na
Bullish= TotalCapOpen<TotalCapClose?1:na
Pressure= Bullish? TotalCapHigh : Bearich? TotalCapLow : TotalCapClose
RSIperiod= input(title="RSI Period", type=input.integer, defval=7)
ShowCandle= input(title="Show Pressure Candles", type=input.bool, defval=true)
RSI=rsi(Pressure,RSIperiod)
plot(RSI, color= RSI>=65 or RSI<=35? color.black : color.silver, linewidth=2, editable=true)
fill(hline(70),hline(80), color=color.red, transp=80)
fill(hline(30),hline(20), color=color.green, transp=80)
//Liquidations Leves
fill(hline(80),hline(100), color=color.yellow, transp=80)
fill(hline(20),hline(0), color=color.yellow, transp=80)
plot(50, color=color.black, transp=90)
barcolor(ShowCandle and pivotlow(close,10,0) and low[1]>close and open>close and RSI<=30? color.red :na, editable=true)
barcolor(ShowCandle and pivothigh(close,10,0) and high[1]<close and close>open and RSI>=70? color.green :na, editable=true)
|
FIBI | https://www.tradingview.com/script/jRQoSvBB-FIBI/ | rareSnow99686 | https://www.tradingview.com/u/rareSnow99686/ | 55 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rareSnow99686
//@version=4
study(title="FIBI", overlay=true)
range_long = input(200, "Range Long", type=input.integer)
range_short = input(100, "Range Short", type=input.integer)
lowest_lr = lowest(open, range_long)
highest_lr = highest(close, range_long)
lowest_sr = lowest(open, range_short)
highest_sr = highest(close, range_short)
fib_lr_618 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 61.80)
fib_lr_114 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 11.40)
fib_lr_236 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 23.60)
fib_lr_786 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 78.60)
fib_lr_382 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 38.20)
fib_lr_50 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 50)
fib_lr_100 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 100)
fib_lr_0 = lowest_lr + (((highest_lr - lowest_lr) / 100) * 0)
fib_sr_618 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 61.80)
fib_sr_114 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 11.40)
fib_sr_236 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 23.60)
fib_sr_786 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 78.60)
fib_sr_382 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 38.20)
fib_sr_50 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 50)
fib_sr_100 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 100)
fib_sr_0 = lowest_sr + (((highest_sr - lowest_sr) / 100) * 0)
line_lr__100 = plot(fib_lr_100, 'LR: 100', color.new(color.gray, 100))
plot(fib_sr_100, 'SR: 100', color.gray, 2, plot.style_stepline,true)
line_lr__786 = plot(fib_lr_786, 'LR: 78.60', color.new(color.blue, 100))
plot(fib_sr_786, 'SR: 78.60', color.blue, 2, plot.style_stepline,true)
line_lr__618 = plot(fib_lr_618, 'LR: 61.8', color.new(color.green, 100))
plot(fib_sr_618, 'SR: 61.8', color.green, 2, plot.style_stepline, true)
line_lr__50 = plot(fib_lr_50, 'LR: 50', color.new(color.white, 100))
plot(fib_sr_50, 'SR: 50', color.white, 2, plot.style_stepline,true)
line_lr__382 = plot(fib_lr_382, 'LR: 38.20', color.new(color.yellow, 100))
plot(fib_sr_382, 'SR: 38.20', color.yellow, 2, plot.style_stepline, true)
line_lr__236 = plot(fib_lr_236, 'LR: 23.60', color.new(color.orange, 100))
plot(fib_sr_236, 'SR: 23.60', color.orange, 2, plot.style_stepline, true)
line_lr__114 = plot(fib_lr_114, 'LR: 11.40', color.new(color.red, 100))
plot(fib_sr_114, 'SR: 11.40', color.red, 2, plot.style_stepline, true)
line_lr__0 = plot(fib_lr_0, 'LR: 0', color.new(color.gray, 100), 2, plot.style_stepline)
plot(fib_sr_0, 'SR: 0', color.gray, 2, plot.style_stepline,true)
fill(line_lr__786, line_lr__100, color=color.new(color.gray, 90), title="LR Fill: 100")
fill(line_lr__618, line_lr__786, color=color.new(color.blue, 90), title="LR Fill: 78.6")
fill(line_lr__618, line_lr__50, color=color.new(color.green, 90), title="LR Fill: 61.8")
fill(line_lr__50, line_lr__382, color=color.new(color.white, 90), title="LR Fill: 50")
fill(line_lr__382, line_lr__236, color=color.new(color.yellow, 90), title="LR Fill: 38.2")
fill(line_lr__236,line_lr__114, color=color.new(color.orange, 90), title="LR Fill: 23.6")
fill(line_lr__0,line_lr__114, color=color.new(color.red, 90), title="LR Fill: 11.4")
|
CCI+AO TR | https://www.tradingview.com/script/BhCKIH5M-CCI-AO-TR/ | sivaramsrk007 | https://www.tradingview.com/u/sivaramsrk007/ | 22 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sivaramsrk007
//@version=5
indicator(title="Commodity Channel Index", shorttitle="CCI+ao", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(hlc3, title="Source")
ma = ta.sma(src, length)
cci = (src - ma) / (0.015 * ta.dev(src, length))
plot(cci, "CCI", color=#2962FF)
band1 = hline(150, "Upper Band", color=#787B86, linestyle=hline.style_dashed)
band0 = hline(-150, "Lower Band", color=#787B86, linestyle=hline.style_dashed)
fill(band1, band0, color=color.rgb(33, 150, 243, 90), title="Background")
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
ao = ta.sma(hl2,5) - ta.sma(hl2,34)
diff = ao - ao[1]
plot(ao, color = diff <= 0 ? #F44336 : #009688, style=plot.style_columns)
changeToGreen = ta.crossover(diff, 0)
changeToRed = ta.crossunder(diff, 0)
alertcondition(changeToGreen, title = "AO color changed to green", message = "Awesome Oscillator's color has changed to green")
alertcondition(changeToRed, title = "AO color changed to red", message = "Awesome Oscillator's color has changed to red")
|
FVG Screener (Nephew_Sam_) | https://www.tradingview.com/script/cbkH7nq4-FVG-Screener-Nephew-Sam/ | nephew_sam_ | https://www.tradingview.com/u/nephew_sam_/ | 1,187 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nephew_sam_
//@version=5
indicator('FVG Screener (Nephew_Sam_)', overlay=true)
// -------------------- INPUTS --------------------
var GRP1 = "Timeframes"
timeframe1 = input.timeframe('15', title='Timeframe 1', inline='1', group=GRP1)
timeframe1_l = input.string(title='', defval='15', inline='1', group=GRP1)
timeframe1_on = input.bool(true, '', inline='1', group=GRP1)
timeframe2 = input.timeframe('30', title='Timeframe 2', inline='2', group=GRP1)
timeframe2_l = input.string(title='', defval='30', inline='2', group=GRP1)
timeframe2_on = input.bool(true, '', inline='2', group=GRP1)
timeframe3 = input.timeframe('60', title='Timeframe 3', inline='3', group=GRP1)
timeframe3_l = input.string(title='', defval='H1', inline='3', group=GRP1)
timeframe3_on = input.bool(true, '', inline='3', group=GRP1)
timeframe4 = input.timeframe('240', title='Timeframe 4', inline='4', group=GRP1)
timeframe4_l = input.string(title='', defval='H4', inline='4', group=GRP1)
timeframe4_on = input.bool(true, '', inline='4', group=GRP1)
timeframe5 = input.timeframe('D', title='Timeframe 5', inline='5', group=GRP1)
timeframe5_l = input.string(title='', defval='D', inline='5', group=GRP1)
timeframe5_on = input.bool(false, '', inline='5', group=GRP1)
var GRP2 = "FVG settings"
fvgFill = input.string(title='Filled FVG Type', defval='Close', options=['Close', 'H/L'], group = GRP2)
maxBarsback = input.int(100, 'Max bars back to find FVGs ?', minval=10, maxval=500, group = GRP2, tooltip="This will look for FVG's x bars back. The higher the number, the slower the script will run.")
var GRP3 = "UI"
theme = input.string(title='Theme Mode', defval='Dark', options=['Dark', 'Light'], group = GRP3)
position = input.string(title='Table Position', defval='Top Right', options=['Top Right', 'Bottom Right', 'Top Left', 'Bottom Left'], group = GRP3)
// -------------------- INPUTS --------------------
// -------------------- functions and formulas --------------------
getMtfData(res, i=0) =>
request.security(
syminfo.tickerid,
res,
[
close[i+1] < low[i+2] and high[i] < low[i+2], // Bearish FVG
close[i+1] > high[i+2] and low[i] > high[i+2], // Bullish FVG
open[i], high[i], low[i], close[i], time[i], bar_index[i],
open[i+1], high[i+1], low[i+1], close[i+1], time[i+1], bar_index[i+1],
open[i+2], high[i+2], low[i+2], close[i+2], time[i+2], bar_index[i+2]
],
gaps=barmerge.gaps_off,
lookahead=barmerge.lookahead_on
)
addToArray(_array, _val) =>
array.push(_array, _val)
removeFromArray(_array, _index) => array.remove(_array, _index)
isFvgFilled(type, old_bi, old_h, old_l, bi, h, l, c) => // bull/bear, open, high, low, close, bar_index, fvg bar index
isOld = bi - old_bi > maxBarsback
type == 'bull' ?
isOld or (fvgFill == 'Close' ? c : l) <= old_h
:
isOld or (fvgFill == 'Close' ? c : h) >= old_l
isPriceInsideFvg(type, old_h, old_l, h, l, c) =>
type == 'bull' ?
l < old_l and (fvgFill == 'Close' ? c : l) > old_h
:
h > old_h and (fvgFill == 'Close' ? c : h) < old_l
// -------------------- functions and formulas --------------------
// Get All OHLC Data
[tf1_bearish_fvg, tf1_bullish_fvg, tf1_o, tf1_h, tf1_l, tf1_c, tf1_t, tf1_bi, tf1_o1, tf1_h1, tf1_l1, tf1_c1, tf1_t1, tf1_bi1, tf1_o2, tf1_h2, tf1_l2, tf1_c2, tf1_t2, tf1_bi2] = getMtfData(timeframe1)
[tf2_bearish_fvg, tf2_bullish_fvg, tf2_o, tf2_h, tf2_l, tf2_c, tf2_t, tf2_bi, tf2_o1, tf2_h1, tf2_l1, tf2_c1, tf2_t1, tf2_bi1, tf2_o2, tf2_h2, tf2_l2, tf2_c2, tf2_t2, tf2_bi2] = getMtfData(timeframe2)
[tf3_bearish_fvg, tf3_bullish_fvg, tf3_o, tf3_h, tf3_l, tf3_c, tf3_t, tf3_bi, tf3_o1, tf3_h1, tf3_l1, tf3_c1, tf3_t1, tf3_bi1, tf3_o2, tf3_h2, tf3_l2, tf3_c2, tf3_t2, tf3_bi2] = getMtfData(timeframe3)
[tf4_bearish_fvg, tf4_bullish_fvg, tf4_o, tf4_h, tf4_l, tf4_c, tf4_t, tf4_bi, tf4_o1, tf4_h1, tf4_l1, tf4_c1, tf4_t1, tf4_bi1, tf4_o2, tf4_h2, tf4_l2, tf4_c2, tf4_t2, tf4_bi2] = getMtfData(timeframe4)
[tf5_bearish_fvg, tf5_bullish_fvg, tf5_o, tf5_h, tf5_l, tf5_c, tf5_t, tf5_bi, tf5_o1, tf5_h1, tf5_l1, tf5_c1, tf5_t1, tf5_bi1, tf5_o2, tf5_h2, tf5_l2, tf5_c2, tf5_t2, tf5_bi2] = getMtfData(timeframe5)
// -------------------- Save data to arrays --------------------
var tf1_bull_indexes = array.new_int(0)
var tf1_bull_highs = array.new_float(0)
var tf1_bull_lows = array.new_float(0)
var tf1_bear_indexes = array.new_int(0)
var tf1_bear_highs = array.new_float(0)
var tf1_bear_lows = array.new_float(0)
var tf2_bull_indexes = array.new_int(0)
var tf2_bull_highs = array.new_float(0)
var tf2_bull_lows = array.new_float(0)
var tf2_bear_indexes = array.new_int(0)
var tf2_bear_highs = array.new_float(0)
var tf2_bear_lows = array.new_float(0)
var tf3_bull_indexes = array.new_int(0)
var tf3_bull_highs = array.new_float(0)
var tf3_bull_lows = array.new_float(0)
var tf3_bear_indexes = array.new_int(0)
var tf3_bear_highs = array.new_float(0)
var tf3_bear_lows = array.new_float(0)
var tf4_bull_indexes = array.new_int(0)
var tf4_bull_highs = array.new_float(0)
var tf4_bull_lows = array.new_float(0)
var tf4_bear_indexes = array.new_int(0)
var tf4_bear_highs = array.new_float(0)
var tf4_bear_lows = array.new_float(0)
var tf5_bull_indexes = array.new_int(0)
var tf5_bull_highs = array.new_float(0)
var tf5_bull_lows = array.new_float(0)
var tf5_bear_indexes = array.new_int(0)
var tf5_bear_highs = array.new_float(0)
var tf5_bear_lows = array.new_float(0)
if timeframe1_on
if tf1_bullish_fvg
addToArray(tf1_bull_indexes, tf1_bi)
addToArray(tf1_bull_highs, tf1_h2)
addToArray(tf1_bull_lows, tf1_l)
else if tf1_bearish_fvg
addToArray(tf1_bear_indexes, tf1_bi)
addToArray(tf1_bear_highs, tf1_h)
addToArray(tf1_bear_lows, tf1_l2)
if timeframe2_on
if tf2_bullish_fvg
addToArray(tf2_bull_indexes, tf2_bi)
addToArray(tf2_bull_highs, tf2_h2)
addToArray(tf2_bull_lows, tf2_l)
else if tf2_bearish_fvg
addToArray(tf2_bear_indexes, tf2_bi)
addToArray(tf2_bear_highs, tf2_h)
addToArray(tf2_bear_lows, tf2_l2)
if timeframe3_on
if tf3_bullish_fvg
addToArray(tf3_bull_indexes, tf3_bi)
addToArray(tf3_bull_highs, tf3_h2)
addToArray(tf3_bull_lows, tf3_l)
else if tf3_bearish_fvg
addToArray(tf3_bear_indexes, tf3_bi)
addToArray(tf3_bear_highs, tf3_h)
addToArray(tf3_bear_lows, tf3_l2)
if timeframe4_on
if tf4_bullish_fvg
addToArray(tf4_bull_indexes, tf4_bi)
addToArray(tf4_bull_highs, tf4_h2)
addToArray(tf4_bull_lows, tf4_l)
else if tf4_bearish_fvg
addToArray(tf4_bear_indexes, tf4_bi)
addToArray(tf4_bear_highs, tf4_h)
addToArray(tf4_bear_lows, tf4_l2)
if timeframe5_on
if tf5_bullish_fvg
addToArray(tf5_bull_indexes, tf5_bi)
addToArray(tf5_bull_highs, tf5_h2)
addToArray(tf5_bull_lows, tf5_l)
else if tf5_bearish_fvg
addToArray(tf5_bear_indexes, tf5_bi)
addToArray(tf5_bear_highs, tf5_h)
addToArray(tf5_bear_lows, tf5_l2)
// -------------------- Save data to arrays --------------------
// -------------------- Delete filled fvgs --------------------
// Timeframe 1
if timeframe1_on
if array.size(tf1_bull_indexes) > 0
for i = array.size(tf1_bull_indexes)-1 to 0
if isFvgFilled('bull', array.get(tf1_bull_indexes,i), array.get(tf1_bull_highs,i), array.get(tf1_bull_lows,i), tf1_bi, tf1_h, tf1_l, tf1_c)
removeFromArray(tf1_bull_indexes, i)
removeFromArray(tf1_bull_highs, i)
removeFromArray(tf1_bull_lows, i)
if array.size(tf1_bear_indexes) > 0
for i = array.size(tf1_bear_indexes)-1 to 0
if isFvgFilled('bear', array.get(tf1_bear_indexes,i), array.get(tf1_bear_highs,i), array.get(tf1_bear_lows,i), tf1_bi, tf1_h, tf1_l, tf1_c)
removeFromArray(tf1_bear_indexes, i)
removeFromArray(tf1_bear_highs, i)
removeFromArray(tf1_bear_lows, i)
// Timeframe 2
if timeframe2_on
if array.size(tf2_bull_indexes) > 0
for i = array.size(tf2_bull_indexes)-1 to 0
if isFvgFilled('bull', array.get(tf2_bull_indexes,i), array.get(tf2_bull_highs,i), array.get(tf2_bull_lows,i), tf2_bi, tf2_h, tf2_l, tf2_c)
removeFromArray(tf2_bull_indexes, i)
removeFromArray(tf2_bull_highs, i)
removeFromArray(tf2_bull_lows, i)
if array.size(tf2_bear_indexes) > 0
for i = array.size(tf2_bear_indexes)-1 to 0
if isFvgFilled('bear', array.get(tf2_bear_indexes,i), array.get(tf2_bear_highs,i), array.get(tf2_bear_lows,i), tf2_bi, tf2_h, tf2_l, tf2_c)
removeFromArray(tf2_bear_indexes, i)
removeFromArray(tf2_bear_highs, i)
removeFromArray(tf2_bear_lows, i)
// Timeframe 3
if timeframe3_on
if array.size(tf3_bull_indexes) > 0
for i = array.size(tf3_bull_indexes)-1 to 0
if isFvgFilled('bull', array.get(tf3_bull_indexes,i), array.get(tf3_bull_highs,i), array.get(tf3_bull_lows,i), tf3_bi, tf3_h, tf3_l, tf3_c)
removeFromArray(tf3_bull_indexes, i)
removeFromArray(tf3_bull_highs, i)
removeFromArray(tf3_bull_lows, i)
if array.size(tf3_bear_indexes) > 0
for i = array.size(tf3_bear_indexes)-1 to 0
if isFvgFilled('bear', array.get(tf3_bear_indexes,i), array.get(tf3_bear_highs,i), array.get(tf3_bear_lows,i), tf3_bi, tf3_h, tf3_l, tf3_c)
removeFromArray(tf3_bear_indexes, i)
removeFromArray(tf3_bear_highs, i)
removeFromArray(tf3_bear_lows, i)
// Timeframe 4
if timeframe4_on
if array.size(tf4_bull_indexes) > 0
for i = array.size(tf4_bull_indexes)-1 to 0
if isFvgFilled('bull', array.get(tf4_bull_indexes,i), array.get(tf4_bull_highs,i), array.get(tf4_bull_lows,i), tf4_bi, tf4_h, tf4_l, tf4_c)
removeFromArray(tf4_bull_indexes, i)
removeFromArray(tf4_bull_highs, i)
removeFromArray(tf4_bull_lows, i)
if array.size(tf4_bear_indexes) > 0
for i = array.size(tf4_bear_indexes)-1 to 0
if isFvgFilled('bear', array.get(tf4_bear_indexes,i), array.get(tf4_bear_highs,i), array.get(tf4_bear_lows,i), tf4_bi, tf4_h, tf4_l, tf4_c)
removeFromArray(tf4_bear_indexes, i)
removeFromArray(tf4_bear_highs, i)
removeFromArray(tf4_bear_lows, i)
// Timeframe 5
if timeframe5_on
if array.size(tf5_bull_indexes) > 0
for i = array.size(tf5_bull_indexes)-1 to 0
if isFvgFilled('bull', array.get(tf5_bull_indexes,i), array.get(tf5_bull_highs,i), array.get(tf5_bull_lows,i), tf5_bi, tf5_h, tf5_l, tf5_c)
removeFromArray(tf5_bull_indexes, i)
removeFromArray(tf5_bull_highs, i)
removeFromArray(tf5_bull_lows, i)
if array.size(tf5_bear_indexes) > 0
for i = array.size(tf5_bear_indexes)-1 to 0
if isFvgFilled('bear', array.get(tf5_bear_indexes,i), array.get(tf5_bear_highs,i), array.get(tf5_bear_lows,i), tf5_bi, tf5_h, tf5_l, tf5_c)
removeFromArray(tf5_bear_indexes, i)
removeFromArray(tf5_bear_highs, i)
removeFromArray(tf5_bear_lows, i)
// -------------------- Delete filled fvgs --------------------
// label.new(bar_index, high, str.tostring(array.size(tf1_bull_indexes)))
// -------------------- Check if inside fvg --------------------
tf1_inside_bull = false
tf1_inside_bear = false
tf2_inside_bull = false
tf2_inside_bear = false
tf3_inside_bull = false
tf3_inside_bear = false
tf4_inside_bull = false
tf4_inside_bear = false
tf5_inside_bull = false
tf5_inside_bear = false
// timeframe 1
if timeframe1_on
if array.size(tf1_bull_indexes) > 0
for i = array.size(tf1_bull_indexes)-1 to 0
if isPriceInsideFvg('bull', array.get(tf1_bull_highs,i), array.get(tf1_bull_lows,i), tf1_h, tf1_l, tf1_c)
tf1_inside_bull := true
if array.size(tf1_bear_indexes) > 0
for i = array.size(tf1_bear_indexes)-1 to 0
if isPriceInsideFvg('bear', array.get(tf1_bear_highs,i), array.get(tf1_bear_lows,i), tf1_h, tf1_l, tf1_c)
tf1_inside_bear := true
// timeframe 2
if timeframe2_on
if array.size(tf2_bull_indexes) > 0
for i = array.size(tf2_bull_indexes)-1 to 0
if isPriceInsideFvg('bull', array.get(tf2_bull_highs,i), array.get(tf2_bull_lows,i), tf2_h, tf2_l, tf2_c)
tf2_inside_bull := true
if array.size(tf2_bear_indexes) > 0
for i = array.size(tf2_bear_indexes)-1 to 0
if isPriceInsideFvg('bear', array.get(tf2_bear_highs,i), array.get(tf2_bear_lows,i), tf2_h, tf2_l, tf2_c)
tf2_inside_bear := true
// timeframe 3
if timeframe3_on
if array.size(tf3_bull_indexes) > 0
for i = array.size(tf3_bull_indexes)-1 to 0
if isPriceInsideFvg('bull', array.get(tf3_bull_highs,i), array.get(tf3_bull_lows,i), tf3_h, tf3_l, tf3_c)
tf3_inside_bull := true
if array.size(tf3_bear_indexes) > 0
for i = array.size(tf3_bear_indexes)-1 to 0
if isPriceInsideFvg('bear', array.get(tf3_bear_highs,i), array.get(tf3_bear_lows,i), tf3_h, tf3_l, tf3_c)
tf3_inside_bear := true
// timeframe 4
if timeframe4_on
if array.size(tf4_bull_indexes) > 0
for i = array.size(tf4_bull_indexes)-1 to 0
if isPriceInsideFvg('bull', array.get(tf4_bull_highs,i), array.get(tf4_bull_lows,i), tf4_h, tf4_l, tf4_c)
tf4_inside_bull := true
if array.size(tf4_bear_indexes) > 0
for i = array.size(tf4_bear_indexes)-1 to 0
if isPriceInsideFvg('bear', array.get(tf4_bear_highs,i), array.get(tf4_bear_lows,i), tf4_h, tf4_l, tf4_c)
tf4_inside_bear := true
// timeframe 5
if timeframe5_on
if array.size(tf5_bull_indexes) > 0
for i = array.size(tf5_bull_indexes)-1 to 0
if isPriceInsideFvg('bull', array.get(tf5_bull_highs,i), array.get(tf5_bull_lows,i), tf5_h, tf5_l, tf5_c)
tf5_inside_bull := true
if array.size(tf5_bear_indexes) > 0
for i = array.size(tf5_bear_indexes)-1 to 0
if isPriceInsideFvg('bear', array.get(tf5_bear_highs,i), array.get(tf5_bear_lows,i), tf5_h, tf5_l, tf5_c)
tf5_inside_bear := true
// -------------------- Check if inside fvg --------------------
// -------------------- Plot table --------------------
_label(_val) => _val ? " " : " "
_color(_val, _type) => _val ? _type == 'bull' ? color.lime : color.red : color.new(color.red, 100)
_color1 = theme == "Dark" ? color.white : color.black
_position = switch position
"Top Left" => position.top_left
"Top Right" => position.top_right
"Bottom Left" => position.bottom_left
=> position.bottom_right
var table _table = table.new(_position, 3, 6, frame_width = 2, frame_color = _color1, border_color = _color1, border_width = 1)
if barstate.islast
table.cell(_table, 0, 0, "Period", text_color=_color1)
table.cell(_table, 1, 0, "Bear", text_color=_color1)
table.cell(_table, 2, 0, "Bull", text_color=_color1)
// Timeframe 1
if timeframe1_on
table.cell(_table, 0, 1, timeframe1_l, text_color=_color1)
table.cell(_table, 1, 1, _label(tf1_inside_bear), bgcolor=_color(tf1_inside_bear, 'bear'))
table.cell(_table, 2, 1, _label(tf1_inside_bull), bgcolor=_color(tf1_inside_bull, 'bull'))
// Timeframe 2
if timeframe2_on
table.cell(_table, 0, 2, timeframe2_l, text_color=_color1)
table.cell(_table, 1, 2, _label(tf2_inside_bear), bgcolor=_color(tf2_inside_bear, 'bear'))
table.cell(_table, 2, 2, _label(tf2_inside_bull), bgcolor=_color(tf2_inside_bull, 'bull'))
// Timeframe 3
if timeframe3_on
table.cell(_table, 0, 3, timeframe3_l, text_color=_color1)
table.cell(_table, 1, 3, _label(tf3_inside_bear), bgcolor=_color(tf3_inside_bear, 'bear'))
table.cell(_table, 2, 3, _label(tf3_inside_bull), bgcolor=_color(tf3_inside_bull, 'bull'))
// Timeframe 4
if timeframe4_on
table.cell(_table, 0, 4, timeframe4_l, text_color=_color1)
table.cell(_table, 1, 4, _label(tf4_inside_bear), bgcolor=_color(tf4_inside_bear, 'bear'))
table.cell(_table, 2, 4, _label(tf4_inside_bull), bgcolor=_color(tf4_inside_bull, 'bull'))
// Timeframe 5
if timeframe5_on
table.cell(_table, 0, 5, timeframe5_l, text_color=_color1)
table.cell(_table, 1, 5, _label(tf5_inside_bear), bgcolor=_color(tf5_inside_bear, 'bear'))
table.cell(_table, 2, 5, _label(tf5_inside_bull), bgcolor=_color(tf5_inside_bull, 'bull'))
// -------------------- Plot table -------------------- |
Fibonacci Progression with Breaks [LuxAlgo] | https://www.tradingview.com/script/xyCba4gl-Fibonacci-Progression-with-Breaks-LuxAlgo/ | LuxAlgo | https://www.tradingview.com/u/LuxAlgo/ | 2,981 | study | 5 | CC-BY-NC-SA-4.0 | // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("Fibonacci Progression With Breaks [LuxAlgo]",overlay=1,max_labels_count=500,max_lines_count=500)
method = input.string('Atr',options=['Atr','Manual'],inline='inline1')
size = input(1.,'',inline='inline1')
max = input(3,'Sequence Length')
//----
var fib = array.from(1,1)
var dist = 0.,var avg = 0.,var fib_n = 1,var os = 0
src = close
n = bar_index
if barstate.isfirst
for i = 1 to max
array.push(fib,array.get(fib,i-1) + array.get(fib,i))
//----
if method == 'Atr'
dist := ta.atr(200)*size*array.get(fib,fib_n)
else
dist := size*array.get(fib,fib_n)
fib_n := math.abs(src-avg) > dist ? fib_n+1 : fib_n
avg := nz(fib_n > max+1 ? src : avg[1],src)
fib_n := fib_n > max+1 ? 1 : fib_n
buy = avg > avg[1]
sell = avg < avg[1]
os := buy ? 1 : sell ? 0 : os
tp = avg != avg[1] ? na : os == 1 ? avg + dist : avg - dist
sl = avg != avg[1] ? na : os == 0 ? avg + dist : avg - dist
//----
css = os == 1 ? #0cb51a : #ff1100
plot0 = plot(src,color=na)
plot1 = plot(avg,color=na)
fill(plot0,plot1,color.new(css,80))
//----
plotshape(buy ? low : na,"Buy Label",shape.labelup,location.absolute,#0cb51a,0,text="B",textcolor=color.white,size=size.tiny)
plotshape(sell ? high : na,"Sell Label",shape.labeldown,location.absolute,#ff1100,0,text="S",textcolor=color.white,size=size.tiny)
plot(tp,'Target',#0cb51a,1,plot.style_linebr)
plot(sl,'Stop',#ff1100,1,plot.style_linebr)
if fib_n > fib_n[1] and os == 1 and src > avg
label.new(n,src,str.tostring(array.get(fib,fib_n-1)) + ' ✅',yloc=yloc.abovebar
,color=na,style=label.style_label_down,textcolor=color.gray,size=size.small)
else if fib_n > fib_n[1] and os == 1 and src < avg
label.new(n,src,str.tostring(array.get(fib,fib_n-1)) + ' ❌',yloc=yloc.belowbar
,color=na,style=label.style_label_up,textcolor=color.gray,size=size.small)
if fib_n > fib_n[1] and os == 0 and src < avg
label.new(n,src,str.tostring(array.get(fib,fib_n-1)) + ' ✅',yloc=yloc.belowbar
,color=na,style=label.style_label_up,textcolor=color.gray,size=size.small)
else if fib_n > fib_n[1] and os == 0 and src > avg
label.new(n,src,str.tostring(array.get(fib,fib_n-1)) + ' ❌',yloc=yloc.abovebar
,color=na,style=label.style_label_down,textcolor=color.gray,size=size.small)
|
Average True Range - Improved | https://www.tradingview.com/script/TFxe4MuQ-Average-True-Range-Improved/ | OasisTrading | https://www.tradingview.com/u/OasisTrading/ | 102 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OasisTrading
//@version=4
study(title="Average True Range - Improved", shorttitle="ATR Improved", overlay=false, resolution="")
length = input(title="Length", defval=5, minval=1)
smoothing = input(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])
ma_function(source, length) =>
if smoothing == "RMA"
rma(source, length)
else
if smoothing == "SMA"
sma(source, length)
else
if smoothing == "EMA"
ema(source, length)
else
wma(source, length)
atrvalue = (ma_function(tr(true), length))
percent = (atrvalue / close) * 100
//percentvalue = input(0.33, title= "Percent Value")
percentinput = input(50, title="Persent SMA")
percentvalue = sma(percent,percentinput)
volatilityAverage = sma(atrvalue, percentinput)
plot(percent, title= "ATR: Percent", style=plot.style_line, linewidth=2, color=#000000, transp=0, display=display.none)
plot(percentvalue, title = "ATR Average: Percent", style=plot.style_circles, linewidth= 1, color=color.blue, transp=0, display=display.none)
plot(ma_function(tr(true), length), title = "ATR", style=plot.style_area, linewidth= 4, color=#991515, transp=50)
plot(volatilityAverage, title = "ATR Average", style=plot.style_circles, linewidth= 1, color=#2196F3, transp=0)
plotshape(percent < percentvalue, title="Volatility Low", style=shape.circle, location=location.top, size=size.tiny, color=color.green, transp=50)
plotshape(percent > percentvalue, title="Volatility High", style=shape.circle, location=location.top, size=size.tiny, color=color.red, transp=50) |
Fractal Dimension Index | https://www.tradingview.com/script/Grr7TmFj-Fractal-Dimension-Index/ | bjr117 | https://www.tradingview.com/u/bjr117/ | 84 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bjr117
//@version=5
indicator(title = "Fractal Dimension Index", shorttitle = "FDI", overlay = false)
//==============================================================================
// Input Parameters
//==============================================================================
fdi_length = input.int(30, title = "FDI Length", minval = 2)
fdi_src = input.source(close, title = "FDI Source")
fdi_hline = input.float(1.5, title = "FDI Horizontal Line Level", minval = 0.0, maxval = 2.0, step = 0.005)
//==============================================================================
//==============================================================================
// Calculating FDI
//==============================================================================
calculate_FDI(fdi_src, fdi_length) =>
highest_high = ta.highest(fdi_src, fdi_length)
lowest_low = ta.lowest(fdi_src, fdi_length)
length = float(0.0)
for i = 1 to fdi_length - 1
diff = (fdi_src[i] - lowest_low) / (highest_high - lowest_low)
length := length + math.sqrt(math.pow(diff[i] - diff[i+1], 2) + (1 / math.pow(fdi_length, 2)))
fdi = 1 + (math.log(length) + math.log(2)) / math.log(2*fdi_length)
fdi
//==============================================================================
//==============================================================================
// Plotting FDI and FDI Horizontal Line
//==============================================================================
fdi = float(0.0)
fdi := calculate_FDI(fdi_src, fdi_length)
fdi_color = fdi > fdi_hline ? color.blue : color.red
fdi_plot = plot(fdi, title = "FDI Line", color = fdi_color)
hline_plot = plot(fdi_hline, title = "FDI Horizontal Line", color = color.new(#000000, 70))
fill(fdi_plot, hline_plot, title = "FDI Fill", color = color.new(fdi_color, 70))
//============================================================================== |
Paradigmi | https://www.tradingview.com/script/s0oUhSpc/ | FraSW99 | https://www.tradingview.com/u/FraSW99/ | 2 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © greenmask9
//@version=4
study(title = "Paradigmi", shorttitle = "Paradigmi", overlay=true)
///////////
i_position = input(type = input.string, title = "Table Placement", defval = "Top Center",
options = ["Top Right", "Top Center", "Bottom Right"], group = "Table Characteristics")
position = i_position == "Top Right" ? position.top_right : i_position == "Top Center" ? position.top_center : position.bottom_right
i_w = input(type = input.integer, title = "Width", defval = 12, group = "Table Characteristics")
i_h = input(type = input.integer, title = "Height", defval = 3, group = "Table Characteristics")
i_w_1 = input(type = input.integer, title = "Width", defval = 5, group = "Table Characteristics_1")
i_h_1 = input(type = input.integer, title = "Height", defval = 4, group = "Table Characteristics_1")
i_text_size = input(type = input.string, title = "Text Size", defval = "Normal", options = ["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], group = "Table Characteristics")
i_text_size_1 = input(type = input.string, title = "Text Size", defval = "Normal", options = ["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], group = "Table Characteristics_1")
text_size = i_text_size == "Normal" ? size.normal : i_text_size == "Auto" ? size.auto : i_text_size == "Auto" ? size.auto : i_text_size == "Tiny" ? size.tiny : i_text_size == "Small" ? size.small : i_text_size == "Large" ? size.large : i_text_size == "Huge" ? size.huge : size.normal
text_size_1 = i_text_size_1 == "Normal" ? size.normal : i_text_size == "Auto" ? size.auto : i_text_size == "Auto" ? size.auto : i_text_size == "Tiny" ? size.tiny : i_text_size == "Small" ? size.small : i_text_size == "Large" ? size.large : i_text_size == "Huge" ? size.huge : size.normal
row_1 = input(type = input.string, title = "Row 1 Text", defval = "RISPETTO SEMPRE IL MIO TRADING PLAN", group = "Texts")
row_2 = input(type = input.string, title = "Row 2 Text", defval = "TRADO QUELLO CHE VEDO, NON QUELLO CHE SENTO", group = "Texts")
row_3 = input(type = input.string, title = "Row 3 Text", defval = "SONO EMOTIVAMENTE DISTTACCATO DAI GRAFICI", group = "Texts")
row_4 = input(type = input.string, title = "Row 4 Text", defval = "RISPETTO LA MIA AZIENDA DI TRADING", group = "Texts")
row_5 = input(type = input.string, title = "Row 5 Text", defval = "WHERE IS THE $$$?", group = "Texts")
i_1 = input(type = input.bool, title = "Row 1", defval = true, group = "Enablers")
i_2 = input(type = input.bool, title = "Row 2", defval = true, group = "Enablers")
i_3 = input(type = input.bool, title = "Row 3", defval = true, group = "Enablers")
i_4 = input(type = input.bool, title = "Row 4", defval = true, group = "Enablers")
i_5 = input(type = input.bool, title = "Row 5", defval = true, group = "Enablers")
var table perfTable = table.new(position, 1, 5, border_width = 1)
var table perfTable_1 = table.new(position.top_right, 1, 5, border_width = 1)
if i_1
table.cell(perfTable, 0, 0, row_1, text_color = color.new(color.black, 0), width = i_w, height = i_h, text_size = text_size)
if i_2
table.cell(perfTable, 0, 1, row_2, text_color = color.new(color.black, 0), width = i_w, height = i_h, text_size = text_size)
if i_3
table.cell(perfTable, 0, 2, row_3, text_color = color.new(color.black, 0), width = i_w, height = i_h, text_size = text_size)
if i_4
table.cell(perfTable, 0, 3, row_4, text_color = color.new(color.black, 0), width = i_w, height = i_h, text_size = text_size)
if i_5
table.cell(perfTable_1, 0, 4, row_5, text_color = color.new(color.black, 0), width = i_w_1, height = i_h_1, text_size = text_size_1) |
Portfolio Laboratory [Kioseff Trading] | https://www.tradingview.com/script/GxQp712Z-Portfolio-Laboratory-Kioseff-Trading/ | KioseffTrading | https://www.tradingview.com/u/KioseffTrading/ | 631 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © KioseffTrading
//@version=5
// ________________________________________________
// | |
// | --------------------------------- |
// | | K̲ i̲ o̲ s̲ e̲ f̲ f̲ T̲ r̲ a̲ d̲ i̲ n̲ g | |
// | | | |
// | | ƃ u ᴉ p ɐ ɹ ꓕ ⅎ ⅎ ǝ s o ᴉ ꓘ | |
// | -------------------------------- |
// | |
// |_______________________________________________|
indicator(title = "Portfolio Laboratory [Kioseff Trading]", overlay = true, precision = 2, max_labels_count = 500, max_lines_count = 500)
import TradingView/ta/1 as ta
lin = input.string(defval = "Yes", title = "Show Percentage Line Performance? ", options = ["Yes", "No"])
tab = input.string(defval = "Yes", title = "Show Table? ", options = ["Yes", "No"])
col = input.string(defval = "No", title = "Color Table Cells on Better Performer?", options = ["Yes", "No"])
dex = input.string(defval = "SPX", title = "Index Measured Against", options = ["SPX", "NASDAQ", "RUT", "NIFTY", "FTSE", "NIKKEI", "HSI", "DAX", "TSX", "IBOV"])
plo = input.string(defval = "Yes", title = "Plot Index Return?", options = ["Yes", "No"])
// _______________________________________________________
//
// Portoflio Asset Selection
// _______________________________________________________
asset1 = input.symbol(title="", group = "Asset 1", defval="AAPL", inline="1")
wX1 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="1")
ls1 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="1")
asset2 = input.symbol(title="", group = "Asset 2", defval="MSFT", inline="2")
wX2 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="2")
ls2 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="2")
asset3 = input.symbol(title="", group = "Asset 3", defval="GOOG", inline="3")
wX3 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="3")
ls3 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="3")
asset4 = input.symbol(title="", group = "Asset 4", defval="AMZN", inline="4")
wX4 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="4")
ls4 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="4")
asset5 = input.symbol(title="", group = "Asset 5", defval="FB", inline="5")
wX5 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="5")
ls5 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="5")
asset6 = input.symbol(title="", group = "Asset 6", defval="T", inline="6")
wX6 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="6")
ls6 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="6")
asset7 = input.symbol(title="", group = "Asset 7", defval="V", inline="7")
wX7 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="7")
ls7 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="7")
asset8 = input.symbol(title="", group = "Asset 8", defval="MA", inline="8")
wX8 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="8")
ls8 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="8")
asset9 = input.symbol(title="", group = "Asset 9", defval="TSLA", inline="9")
wX9 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="9")
ls9 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="9")
asset10 = input.symbol(title="", group = "Asset 10", defval="X", inline="10")
wX10 = input.float(title="Return Weight", defval = 10, minval = 0.0, step = 0.1, maxval = 100.0, inline="10")
ls10 = input.string(title = "Direction (Long/Short)", defval = "Long", options = ["Long", "Short"], inline="10")
// _______________________________________________________
//
// Identifiers
// _______________________________________________________
var float [] d = array.new_float()
var float [] x = array.new_float(10)
var float [] x1 = array.new_float()
var float [] test = array.new_float(1)
var float [] currentR = array.new_float()
var float [] min = array.new_float(250)
var float [] es = array.new_float()
var float [] benMin = array.new_float(250)
var float [] benEs = array.new_float()
var float [] weight = array.new_float(10)
var float [] sH = array.new_float()
var float [] avg = array.new_float()
var float [] sHigh = array.new_float()
var float [] SsH = array.new_float()
var float [] Savg = array.new_float()
var float [] SsHigh = array.new_float()
var float [] dd = array.new_float()
var float [] sDD = array.new_float()
var float [] w_Eight = array.new_float(10)
var float [] w_Eight1 = array.new_float(10)
var label [] port = array.new_label(1)
var label [] asset = array.new_label(1)
var label [] assetDiff = array.new_label(1)
var label [] mon = array.new_label()
var label [] mon1 = array.new_label()
var label [] mon2 = array.new_label()
var label [] startDate = array.new_label()
var label [] inL = array.new_label(1)
var line [] pX = array.new_line(1)
var line [] pX1 = array.new_line(1)
var line [] pX2 = array.new_line(1)
var line [] pX3 = array.new_line(1)
var line [] pX4 = array.new_line(1)
var line [] inLI = array.new_line(1)
var linefill [] pXL = array.new_linefill()
var linefill [] pXL1 = array.new_linefill()
var string [] strin = array.new_string(10)
var float w1 = wX1
var float w2 = wX2
var float w3 = wX3
var float w4 = wX4
var float w5 = wX5
var float w6 = wX6
var float w7 = wX7
var float w8 = wX8
var float w9 = wX9
var float w10 = wX10
var float xY = 0.0
var bool cond2 = false
matS = ""
matX = ""
// _______________________________________________________
//
// Percentage Gain/Loss Calculation
// _______________________________________________________
PnLz(x, y) =>
((x / y) - 1)
PnL(x, y) =>
((x / y[1]) - 1)
// _______________________________________________________
//
// Time Window()
// _______________________________________________________
sYear = input.int(defval = 2018, title = "Calculation Start Year")
sMonth = input.int(defval = 01, title = "Calculation Start Month", maxval = 12, minval = 1)
sDay = input.int(defval = 02, title = "Calculation Start Day", maxval = 31, minval = 1)
eYear = input.int(defval = 2023, title = "Calculation End Year")
eMonth = input.int(defval = 01, title = "Calculation End Month", maxval = 12, minval = 1)
eDay = input.int(defval = 02, title = "Calculation End Day", maxval = 31, minval = 1)
start() => time >= timestamp(sYear, sMonth, sDay, 00, 00) and time <= timestamp(eYear, eMonth, eDay, 23, 59)
z = ta.valuewhen(start()[1] == false and start() == true, close, 0)
zZ = ta.valuewhen(year(time) == sYear and month(time) == sMonth and dayofmonth(time) == sDay, close, 0)
// _______________________________________________________
//
// Tuples
// _______________________________________________________
tuple(x, y) =>
First = x == "Long" ? nz(PnLz(close, z), -100) : nz(PnLz(close, z), -100) * -1
Second = x == "Long" ? PnL(close, close) * y : PnL(close, close) * y * -1,
Third = x == "Long" ? ((close / close[252]) - 1) * y : ((close / close[252]) - 1) * y * -1
Fourth = close
Fifth = syminfo.type
Sixth = ta.cagr(timestamp(sYear, sMonth, sDay), zZ, time <= timestamp(eYear, eMonth, eDay) ? time : timestamp(eYear, eMonth, eDay), close) * (y / 100)
var int [] count = array.new_int()
if year(time) >= sYear and ta.change(month(time))
array.push(count, 1)
Seventh = (math.pow((close / zZ), 1 / (array.sum(count) - 1)) - 1)
[First, Second, Third, Fourth, Fifth, Sixth, Seventh]
request() => tuple(ls1, wX1)
request1() => tuple(ls2, wX2)
request2() => tuple(ls3, wX3)
request3() => tuple(ls4, wX4)
request4() => tuple(ls5, wX5)
request5() => tuple(ls6, wX6)
request6() => tuple(ls7, wX7)
request7() => tuple(ls8, wX8)
request8() => tuple(ls9, wX9)
request9() => tuple(ls10, wX10)
// _______________________________________________________
//
// Data Requests()
// _______________________________________________________
[symcalc01x, f , annual , c, type, cagr, cmgr ] = request.security(asset1, timeframe.period, request() )
[symcalc02x, f1, annual1, c1, type1, cagr1, cmgr1] = request.security(asset2, timeframe.period, request1())
[symcalc03x, f2, annual2, c2, type2, cagr2, cmgr2] = request.security(asset3, timeframe.period, request2())
[symcalc04x, f3, annual3, c3, type3, cagr3, cmgr3] = request.security(asset4, timeframe.period, request3())
[symcalc05x, f4, annual4, c4, type4, cagr4, cmgr4] = request.security(asset5, timeframe.period, request4())
[symcalc06x, f5, annual5, c5, type5, cagr5, cmgr5] = request.security(asset6, timeframe.period, request5())
[symcalc07x, f6, annual6, c6, type6, cagr6, cmgr6] = request.security(asset7, timeframe.period, request6())
[symcalc08x, f7, annual7, c7, type7, cagr7, cmgr7] = request.security(asset8, timeframe.period, request7())
[symcalc09x, f8, annual8, c8, type8, cagr8, cmgr8] = request.security(asset9, timeframe.period, request8())
[symcalc10x, f9, annual9, c9, type9, cagr9, cmgr9] = request.security(asset10,timeframe.period, request9())
// _______________________________________________________
//
// Switch
// _______________________________________________________
mult1 = switch ls1
"Long" => 1
"Short" => 0
mult2 = switch ls2
"Long" => 1
"Short" => 0
mult3 = switch ls3
"Long" => 1
"Short" => 0
mult4 = switch ls4
"Long" => 1
"Short" => 0
mult5 = switch ls5
"Long" => 1
"Short" => 0
mult6 = switch ls6
"Long" => 1
"Short" => 0
mult7 = switch ls7
"Long" => 1
"Short" => 0
mult8 = switch ls8
"Long" => 1
"Short" => 0
mult9 = switch ls9
"Long" => 1
"Short" => 0
mult10 = switch ls10
"Long" => 1
"Short" => 0
// _______________________________________________________
//
// Dividends
// _______________________________________________________
div1 = (request.financial(asset1 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX1 * mult1
div2 = (request.financial(asset2 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX2 * mult2
div3 = (request.financial(asset3 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX3 * mult3
div4 = (request.financial(asset4 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX4 * mult4
div5 = (request.financial(asset5 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX5 * mult5
div6 = (request.financial(asset6 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX6 * mult6
div7 = (request.financial(asset7 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX7 * mult7
div8 = (request.financial(asset8 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX8 * mult8
div9 = (request.financial(asset9 ,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX9 * mult9
div10 = (request.financial(asset10,"DIVIDENDS_YIELD" ,"FQ", ignore_invalid_symbol = true) / 100) * wX10 * mult10
// _______________________________________________________
//
// Indices
// _______________________________________________________
requestIndex() => [(PnL(close, close) * 100), nz(PnLz(close, z) * 100, 0), close]
[SPX1,SPXx , spClose] = request.security("SPX", timeframe.period, requestIndex())
[ND1, NASDAQx, ndClose] = request.security("NDX", timeframe.period, requestIndex())
[RT1, RUTx , rtClose] = request.security("RUT", timeframe.period, requestIndex())
[NY1, NIFTYx , nyClose] = request.security("NIFTY", timeframe.period, requestIndex())
[FT1, FTSEx , ftClose] = request.security("FTSE100", timeframe.period, requestIndex())
[HA1, HANGx , haClose] = request.security("HSI", timeframe.period, requestIndex())
[NI1, NIKKEIx, niClose] = request.security("NI225", timeframe.period, requestIndex())
[DE1, DEx , deClose] = request.security("DAX", timeframe.period, requestIndex())
[CA1, TSXx , caClose] = request.security("TSX", timeframe.period, requestIndex())
[IN1, IBOVx , ibClose] = request.security("IBOV", timeframe.period, requestIndex())
symcalc01 = symcalc01x > -100 ? symcalc01x : -100, SPX = SPXx > -100 ? SPXx : -100
symcalc02 = symcalc02x > -100 ? symcalc02x : -100, NASDAQ = NASDAQx > -100 ? NASDAQx : -100
symcalc03 = symcalc03x > -100 ? symcalc03x : -100, RUT = RUTx > -100 ? RUTx : -100
symcalc04 = symcalc04x > -100 ? symcalc04x : -100, NIFTY = NIFTYx > -100 ? NIFTYx : -100
symcalc05 = symcalc05x > -100 ? symcalc05x : -100, FTSE = FTSEx > -100 ? FTSEx : -100
symcalc06 = symcalc06x > -100 ? symcalc06x : -100, HANG = HANGx > -100 ? HANGx : -100
symcalc07 = symcalc07x > -100 ? symcalc07x : -100, NIKKEI = NIKKEIx > -100 ? NIKKEIx : -100
symcalc08 = symcalc08x > -100 ? symcalc08x : -100, DE = DEx > -100 ? DEx : -100
symcalc09 = symcalc09x > -100 ? symcalc09x : -100, TSX = TSXx > -100 ? TSXx : -100
symcalc10 = symcalc10x > -100 ? symcalc10x : -100, IBOV = IBOVx > -100 ? IBOVx : -100
// _______________________________________________________
//
// User-Defined Identifiers
// _______________________________________________________
comb() =>
symcalc01x * wX1 +
symcalc02x * wX2 +
symcalc03x * wX3 +
symcalc04x * wX4 +
symcalc05x * wX5 +
symcalc06x * wX6 +
symcalc07x * wX7 +
symcalc08x * wX8 +
symcalc09x * wX9 +
symcalc10x * wX10
World() =>
"SPX " +
"\nNDX " +
"\nRUT " +
"\nNIFTY " +
"\nFTSE " +
"\nHSI " +
"\nNIKKEI " +
"\nDAX " +
"\nTSX " +
"\nIBOV "
WorldP() =>
str.tostring (SPX, format.percent) + "\n" +
str.tostring(NASDAQ, format.percent) + "\n" +
str.tostring(RUT, format.percent) + "\n" +
str.tostring(NIFTY, format.percent) + "\n" +
str.tostring(FTSE, format.percent) + "\n" +
str.tostring(HANG, format.percent) + "\n" +
str.tostring(NIKKEI, format.percent) + "\n" +
str.tostring(DE, format.percent) + "\n" +
str.tostring(TSX, format.percent) + "\n" +
str.tostring(IBOV, format.percent)
cond() =>
symcalc01 == -100 or symcalc02 == -100
or symcalc03 == -100 or symcalc04 == -100
or symcalc05 == -100 or symcalc06 == -100
or symcalc07 == -100 or symcalc08 == -100
or symcalc09 == -100 or symcalc10 == -100
change(x) =>
ta.change(x) and cond() == false
if
change(div1)
array.push(d, div1)
if
change(div2)
array.push(d, div2)
if
change(div3)
array.push(d, div3)
if
change(div4)
array.push(d, div4)
if
change(div5)
array.push(d, div5)
if
change(div6)
array.push(d, div6)
if
change(div7)
array.push(d, div7)
if
change(div8)
array.push(d, div8)
if
change(div9)
array.push(d, div9)
finDiv() => array.sum(d)
// _______________________________________________________
//
// Arrays
// _______________________________________________________
array.set(strin, 0, asset1), array.set(strin, 1, asset2)
array.set(strin, 2, asset3), array.set(strin, 3, asset4)
array.set(strin, 4, asset5), array.set(strin, 5, asset6)
array.set(strin, 6, asset7), array.set(strin, 7, asset8)
array.set(strin, 8, asset9), array.set(strin, 9, asset10)
sort(x, x1) =>
s = array.new_string(array.size(x))
s1 = array.copy(x1)
if array.size(x) == array.size(x1)
array.sort(s1, order.descending)
for i = 0 to array.size(x) - 1
s3 = array.get(x, math.max(0, array.indexof(x1, array.get(s1, i))))
array.set(s, i, s3)
[s, s1]
// _______________________________________________________
//
// Array Fills
// _______________________________________________________
if change(bar_index)
array.push(x1, symcalc01x * wX1 +
symcalc02x * wX2 +
symcalc03x * wX3 +
symcalc04x * wX4 +
symcalc05x * wX5 +
symcalc06x * wX6 +
symcalc07x * wX7 +
symcalc08x * wX8 +
symcalc09x * wX9 +
symcalc10x * wX10)
array.push(currentR, symcalc01x * wX1 +
symcalc02x * wX2 +
symcalc03x * wX3 +
symcalc04x * wX4 +
symcalc05x * wX5 +
symcalc06x * wX6 +
symcalc07x * wX7 +
symcalc08x * wX8 +
symcalc09x * wX9 +
symcalc10x * wX10)
array.set(x,0, symcalc01x * wX1)
array.set(x,1, symcalc02x * wX2)
array.set(x,2, symcalc03x * wX3)
array.set(x,3, symcalc04x * wX4)
array.set(x,4, symcalc05x * wX5)
array.set(x,5, symcalc06x * wX6)
array.set(x,6, symcalc07x * wX7)
array.set(x,7, symcalc08x * wX8)
array.set(x,8, symcalc09x * wX9)
array.set(x,9, symcalc10x * wX10)
array.push(test, PnLz(close, z))
[xSort, xSort1] = sort(strin, x)
// _______________________________________________________
//
// Data for Plots
// _______________________________________________________
xY := cond() == true ? 0 :
z +
symcalc01 * wX1 +
symcalc02 * wX2 +
symcalc03 * wX3 +
symcalc04 * wX4 +
symcalc05 * wX5 +
symcalc06 * wX6 +
symcalc07 * wX7 +
symcalc08 * wX8 +
symcalc09 * wX9 +
symcalc10 * wX10
array.set(weight, 0, wX1), array.set(weight, 1, wX2), array.set(weight, 2, wX3)
array.set(weight, 3, wX4), array.set(weight, 4, wX5), array.set(weight, 5, wX6)
array.set(weight, 6, wX7), array.set(weight, 7, wX8), array.set(weight, 8, wX9)
array.set(weight, 9, wX10)
wString = array.sum(weight) == 100.00 ? na : "\n(Summed Weight Should Equal 100%)"
for i = 0 to array.size(xSort) - 1
matS := matS + array.get(xSort, i) + "\n"
matX := matX + str.tostring(array.get(xSort1, i), format.percent) + "\n"
// _______________________________________________________
//
// Beta
// _______________________________________________________
ind() =>
switch dex
"SPX" => SPX1
"NASDAQ" => ND1
"RUT" => RT1
"NIFTY" => NY1
"FTSE" => FT1
"HSI" => HA1
"NIKKEI" => NI1
"DAX" => DE1
"TSX" => CA1
"IBOV" => IN1
clo() =>
switch dex
"SPX" => spClose
"NASDAQ" => ndClose
"RUT" => rtClose
"NIFTY" => nyClose
"FTSE" => ftClose
"HSI" => haClose
"NIKKEI" => niClose
"DAX" => deClose
"TSX" => caClose
"IBOV" => ibClose
ret() =>
switch dex
"SPX" => SPXx
"NASDAQ" => NASDAQx
"RUT" => RUTx
"NIFTY" => NIFTYx
"FTSE" => FTSEx
"HSI" => HANGx
"NIKKEI" => NIKKEIx
"DAX" => DEx
"TSX" => TSXx
"IBOV" => IBOVx
combX() =>
nz(f) +
nz(f1) +
nz(f2) +
nz(f3) +
nz(f4) +
nz(f5) +
nz(f6) +
nz(f7) +
nz(f8) +
nz(f9)
cagrCalc() =>
math.avg(
cagr,
cagr1,
cagr2,
cagr3,
cagr4,
cagr5,
cagr6,
cagr7,
cagr8,
cagr9
)
* (
w1 +
w2 +
w3 +
w4 +
w5 +
w6 +
w7 +
w8 +
w9 +
w10
)
/ 10
cmgrCalc() =>
math.avg(
cmgr,
cmgr1,
cmgr2,
cmgr3,
cmgr4,
cmgr5,
cmgr6,
cmgr7,
cmgr8,
cmgr9
)
* (
w1 +
w2 +
w3 +
w4 +
w5 +
w6 +
w7 +
w8 +
w9 +
w10
)
beta() =>
correlation = ta.correlation(combX(), ind(), 252)
correlationFin = correlation * (ta.stdev(combX(), 252) / ta.stdev(ind(), 252))
correlationFin
finCAGR = fixnan(cagrCalc())
finCMGR = fixnan(cmgrCalc())
beta = str.tostring(beta(), format.mintick)
// _______________________________________________________
//
// VaR & CVaR
// _______________________________________________________
if change(bar_index)
array.push(min, combX())
array.push(benMin, (ind()))
if array.size(min) > 250
array.shift(min)
if array.size(benMin) > 250
array.shift(benMin)
fin = array.percentile_nearest_rank(min, 5)
finBen = array.percentile_nearest_rank(benMin, 5)
if
combX() < fin
array.push(es, combX())
if
ind() < finBen
array.push(benEs, ind())
if
change(year(time))
if
array.size(es) > 0
array.shift(es)
if
array.size(benEs) > 0
array.shift(benEs)
// _______________________________________________________
//
// Sharpe and Classic Correlation
// _______________________________________________________
rf = request.security("DGS10", "D", ((close / 252)))
if
change(bar_index)
array.push(sH, combX() - rf)
array.push(avg, array.avg(sH))
array.push(SsH, (ind()) - rf)
array.push(Savg, array.avg(SsH))
array.push(dd, combX())
array.push(sDD, SPXx)
if
array.size(sH) > 30
array.push(sHigh, (array.avg(sH)) / array.stdev(avg))
array.push(SsHigh, (array.avg(SsH)) / array.stdev(Savg))
if
array.size(sH) > 252
array.shift(sH)
array.shift(avg)
array.shift(SsH)
array.shift(Savg)
sharpe = (array.avg(sH)) / array.stdev(avg)
Ssharpe = (array.avg(SsH)) / array.stdev(Savg)
pE = request.quandl("MULTPL/SP500_PE_RATIO_MONTH")
// _______________________________________________________
//
// Drawdown & Correlation & R-Squared
// _______________________________________________________
corr = ta.correlation(combX(), ind(), 252)
maxDD = array.min(currentR)
maxSDD = array.min(sDD)
R2() =>
math.pow(ta.correlation(combX(), ind(), 252), 2)
Rx2 = R2() * 100
spDraw = .0
spDrawDown = .0
spMaxDrawDown = .0
if
array.size(x1) > 0
spDraw := spDraw[1] > clo() ? spDraw[1] : clo()
spDrawDown := clo() / spDraw - 1
spMaxDrawDown := spMaxDrawDown[1] < spDrawDown ? spMaxDrawDown[1] : spDrawDown
// _______________________________________________________
//
// Table
// _______________________________________________________
merge(v, w, x, y, z) =>
table.merge_cells(v, w, x, y, z)
y = array.new_table(
1,
table.new(
position.bottom_right,
6,
12,
bgcolor = na,
frame_width = 1,
border_width = 1,
border_color = color.white,
frame_color = color.white)
)
if
tab == "Yes"
if
barstate.islast
if
array.size(x1) > 0
table.cell(array.get(y, 0), 2, 0,
text = "Total Return\n" + str.tostring(array.get(x1, array.size(x1) - 1) + nz(finDiv()), format.percent) ,
bgcolor = array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 1,
text = "Constituents",
bgcolor = array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 2, 1,
text = "Component Returns",
bgcolor = array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 2,
text = matS + "\n",
bgcolor = array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 2, 2,
text = "\n" + matX + "\nDividend Yield: " + str.tostring(nz(finDiv()), format.percent),
bgcolor = array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 4,
text = "Portfolio Beta: " + beta,
bgcolor = color.new(color.blue, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 4,
text = str.tostring(dex) + " Beta: 1.00" ,
bgcolor = color.new(color.blue, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 5,
text = "Portfolio VaR: " + str.tostring(fin, format.percent),
bgcolor = col == "Yes" and fin > finBen ? color.new(color.green, 90) : col == "Yes" and fin < finBen ? color.new(color.red, 90) :
array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 6,
text = "Portfolio CVaR: " + str.tostring(array.avg(es), format.percent),
bgcolor = col == "Yes" and array.avg(es) > array.avg(benEs) ? color.new(color.green, 90) : col == "Yes" and array.avg(es) < array.avg(benEs) ? color.new(color.red, 90) :
array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 5,
text = str.tostring(dex) + " VaR: " + str.tostring(finBen, format.percent),
bgcolor = col == "Yes" and fin > finBen ? color.new(color.red, 90) : col == "Yes" and fin < finBen ? color.new(color.green, 90) :
array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 6,
text = str.tostring(dex) + " CVaR: " + str.tostring(array.avg(benEs), format.percent),
bgcolor = col == "Yes" and array.avg(es) > array.avg(benEs) ? color.new(color.red, 90) : col == "Yes" and array.avg(es) < array.avg(benEs) ? color.new(color.green, 90) :
array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 7,
text = "Portfolio Sharpe Ratio: " + str.tostring(sharpe, format.mintick) + " (Highest: " + str.tostring(array.max(sHigh), format.mintick) + ")",
bgcolor = col == "Yes" and sharpe > Ssharpe ? color.new(color.green, 90) : col == "Yes" and sharpe < Ssharpe ? color.new(color.red, 90) :
array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 7,
text = str.tostring(dex) + " Sharpe Ratio: " + str.tostring(Ssharpe, format.mintick),
bgcolor =col == "Yes" and sharpe < Ssharpe ? color.new(color.green, 90) : col == "Yes" and sharpe > Ssharpe ? color.new(color.red, 90) :
array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 10,
text = "Portfolio Correlation to " + str.tostring(dex) + ": " + str.tostring(corr * 100, format.percent),
bgcolor = col == "Yes" ? color.from_gradient(corr, 0.0, 1.0, color.new(color.green, 90) , color.new(color.red, 90)) :
array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 8,
text = "Max % Loss on Initial Investment: " + str.tostring(maxDD, format.percent) + "\n(When Holding Since Start Date)",
bgcolor = col == "Yes" and maxDD > maxSDD ? color.new(color.green, 90) : col == "Yes" and maxDD < maxSDD ? color.new(color.red, 90) :
array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 11,
text = "Portfolio R²: " + str.tostring(Rx2, format.percent),
bgcolor = col == "Yes" ? color.from_gradient(Rx2, 0, 100, color.new(color.red, 90), color.new(color.green, 90)) :
array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 9,
text = "CAGR: " + str.tostring(finCAGR, format.percent) + "\n" + "\nCMGR: " + str.tostring(finCMGR, "#0.0000") + "%",
bgcolor = array.get(x1, array.size(x1) - 1) > (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 9,
text = str.tostring(dex) + " Max Drawdown : " + str.tostring(spMaxDrawDown * 100, format.percent) + "\n(Highest Close to Lowest Close)",
bgcolor = array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 10,
text = "Risk-Free Rate: " + str.tostring(rf * 252, format.percent),
bgcolor = col == "Yes" ? color.new(color.white, 90) : array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 8,
text = str.tostring(dex) + " Max % Loss on Initial Investment: " + str.tostring(maxSDD, format.percent) + "\n(When Holding Since Start Date)",
bgcolor = col == "Yes" and maxDD < maxSDD ? color.new(color.green, 90) : col == "Yes" and maxDD < maxSDD ? color.new(color.red, 90) :
array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 11,
text = "S&P 500 P/E: " + str.tostring(pE, format.mintick),
bgcolor = col == "Yes" ? color.new(color.blue, 90) : array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 1, 0,
text =
w1 +
w2 +
w3 +
w4 +
w5 +
w6 +
w7 +
w8 +
w9 +
w10 == 100.0 ?
str.tostring(
w1 +
w2 +
w3 +
w4 +
w5 +
w6 +
w7 +
w8 +
w9 +
w10 , format.percent) + " Weight " +
wString + "\n\n" :
str.tostring(
w1 +
w2 +
w3 +
w4 +
w5 +
w6 +
w7 +
w8 +
w9 +
w10 , format.percent) + "Weight " + "\n"+ wString + "\n",
bgcolor = color.new(color.white, 90) ,
text_color = color.white)
table.cell(array.get(y, 0), 3, 0,
text = "Asset Total Return\n" + str.tostring((((close / z) - 1) * 100), format.percent),
bgcolor = array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 1,
text = "Indices",
bgcolor = array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 3, 2,
text = World(),
bgcolor = array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 4, 2,
text = WorldP(),
bgcolor = array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
table.cell(array.get(y, 0), 4, 1,
text = "Index Returns",
bgcolor = array.get(x1, array.size(x1) - 1) < (((close / z) - 1) * 100) ? color.new(color.green, 90) : color.new(color.red, 90),
text_color = color.white)
merge(array.get(y, 0), 3, 4, 4, 4 )
merge(array.get(y, 0), 3, 5, 4, 5 )
merge(array.get(y, 0), 3, 6, 4, 6 )
merge(array.get(y, 0), 1, 5, 2, 5 )
merge(array.get(y, 0), 1, 6, 2, 6 )
merge(array.get(y, 0), 1, 7, 2, 7 )
merge(array.get(y, 0), 1, 4, 2, 4 )
merge(array.get(y, 0), 3, 7, 4, 7 )
merge(array.get(y, 0), 1, 8, 2, 8 )
merge(array.get(y, 0), 1, 9, 2, 9 )
merge(array.get(y, 0), 3, 9, 4, 9 )
merge(array.get(y, 0), 3, 8, 4, 8 )
merge(array.get(y, 0), 1, 10, 2, 10)
merge(array.get(y, 0), 3, 10, 4, 10)
merge(array.get(y, 0), 3, 11, 4, 11)
merge(array.get(y, 0), 1, 11, 2, 11)
merge(array.get(y, 0), 3, 0, 4, 0)
/// _______________________________________________________
//
// Plots
// _______________________________________________________
t = plot(lin == "Yes" and cond() == false ? xY : na)
t1 = plot(lin == "Yes" ? z + (((close / z) - 1) * 100) : na, color = color.red)
t2 = plot(plo == "Yes" ? z + ret() : na, color = color.green)
fill(
t,
t1,
color = xY > z + (((close / z) - 1) * 100) and lin == "Yes" ? color.new(color.blue, 97) :
xY < z + (((close / z) - 1) * 100) and lin == "Yes" ? color.new(color.red, 97) :
na
)
Q1 = ta.change(month(time)) and month(time) == 01
Q2 = ta.change(month(time)) and month(time) == 04
Q3 = ta.change(month(time)) and month(time) == 07
Q4 = ta.change(month(time)) and month(time) == 10
if
cond() == false
and array.size(x1) > 0
if
lin == "Yes"
if Q1
array.push(mon, label.new(bar_index, xY, style = label.style_circle, size = size.auto, color = color.white))
array.push(mon1, label.new(bar_index, z + (((close / z) - 1) * 100), style = label.style_circle, color = color.white, size = size.auto))
if
plo == "Yes"
array.push(mon2, label.new(bar_index, z + ret(), style = label.style_circle, size = size.auto, color = color.white))
if Q2
array.push(mon, label.new(bar_index, xY, style = label.style_circle, size = size.auto, color = color.white))
array.push(mon1, label.new(bar_index, z + (((close / z) - 1) * 100), style = label.style_circle, color = color.white, size = size.auto))
if
plo == "Yes"
array.push(mon2, label.new(bar_index, z + ret(), style = label.style_circle, size = size.auto, color = color.white))
if Q3
array.push(mon, label.new(bar_index, xY, style = label.style_circle, size = size.auto, color = color.white))
array.push(mon1, label.new(bar_index, z + (((close / z) - 1) * 100), style = label.style_circle, color = color.white, size = size.auto))
if
plo == "Yes"
array.push(mon2, label.new(bar_index, z + ret(), style = label.style_circle, size = size.auto, color = color.white))
if Q4
array.push(mon, label.new(bar_index, xY, style = label.style_circle, size = size.auto, color = color.white))
array.push(mon1, label.new(bar_index, z + (((close / z) - 1) * 100), style = label.style_circle, color = color.white, size = size.auto))
if
plo == "Yes"
array.push(mon2, label.new(bar_index, z + ret(), style = label.style_circle, size = size.auto, color = color.white))
if
barstate.islast
array.push(
port, label.new(
x = bar_index + 50,
y = xY > z + (((close / z) - 1) * 100) ? xY * 1.01 : xY * .99,
text = "Portfolio Return: " + str.tostring(array.get(x1, array.size(x1) - 1) + nz(finDiv()), format.percent),
style = xY > z + (((close / z) - 1) * 100) ? label.style_label_down : label.style_label_up,
color = color.new(color.blue, 50),
textcolor = color.white)
)
array.push(
asset, label.new(
x = bar_index + 50,
y = xY > z + (((close / z) - 1) * 100) ? z + (((close / z) - 1) * 100) * .99 : z + (((close / z) - 1) * 100) * 1.01,
text = "Asset Return: " + str.tostring((((close / z) - 1) * 100), format.percent),
color = color.new(color.red, 50),
style = z + (((close / z) - 1) * 100) < xY ? label.style_label_up : label.style_label_down,
textcolor = color.white)
)
array.push(
pX, line.new(
x1 = bar_index,
y1 = xY,
x2= bar_index + 50,
y2 = xY,
color = color.blue)
)
array.push(
pX1, line.new(
x1 = bar_index,
y1 = z + (((close / z) - 1) * 100),
x2 = bar_index + 50,
y2 = z + (((close / z) - 1) * 100),
color = color.red)
)
array.push(
pX2, line.new(
x1 =
bar_index + 50,
y1 = xY,
x2 = bar_index + 50,
y2 = math.avg(z + (((close / z) - 1) * 100), xY),
color = color.blue)
)
array.push(
pX3, line.new(
x1 = bar_index + 50,
y1 = z + (((close / z) - 1) * 100),
x2 = bar_index + 50,
y2= math.avg(z + (((close / z) - 1) * 100), xY),
color = color.red)
)
array.push(
pX4, line.new(
x1 = bar_index,
y1 = math.avg(z + (((close / z) - 1) * 100), xY),
x2 = bar_index + 50,
y2 = math.avg(z + (((close / z) - 1) * 100), xY),
color = na)
)
if
plo == "Yes"
array.push(
inLI, line.new(
x1 = bar_index,
y1 = z + ret(),
x2= bar_index + 50,
y2 = z + ret(),
color = color.green)
)
array.push(
inL, label.new(
x = bar_index + 50,
y = z + ret(),
text = str.tostring(dex) +" Return: " + str.tostring(ret(), format.percent),
color = color.new(color.green, 50),
style = label.style_label_left,
textcolor = color.white)
)
// _______________________________________________________
//
// Lines & Labels
// _______________________________________________________
if
array.size(pX) > 0
array.push(
pXL, linefill.new(
line1 = array.get(pX, array.size(pX) - 1),
line2 = array.get(pX4, array.size(pX4) - 1),
color = color.new(color.blue, 92))
)
array.push(
pXL1, linefill.new(
line1 = array.get(pX1, array.size(pX1) - 1),
line2 = array.get(pX4, array.size(pX4) - 1),
color = color.new(color.red, 92))
)
if
array.size(port) > 1
label.delete(array.shift(port))
label.delete(array.shift(asset))
line.delete (array.shift(pX))
line.delete (array.shift(pX1))
line.delete (array.shift(pX2))
line.delete (array.shift(pX3))
line.delete (array.shift(pX4))
if
array.size(inLI) > 0
line.delete (array.shift(inLI))
label.delete(array.shift(inL))
// _______________________________________________________
//
// Time Start Marker
// _______________________________________________________
if
c > 0
and c1 > 0
and c2 > 0
and c3 > 0
and c4 > 0
and c5 > 0
and c6 > 0
and c7 > 0
and c8 > 0
and c9 > 0
cond2 := true
if
cond2[1] == false
if
cond2 == true
array.push(
startDate, label.new(
x =bar_index,
y =high * 1.20,
text = "All Assets Started \nTrading by This Session\n" + str.tostring(year(time)) + "/" + str.tostring(month(time)) + "/" + str.tostring(dayofmonth(time)),
textcolor = color.black, color = color.new(color.white, 50),
style = label.style_label_right)
)
bgcolor(cond2[1] == false and cond2 == true ? color.white : cond2 == true ? color.new(color.white, 99) : na)
|
COT Report BTC Positions | https://www.tradingview.com/script/r788Syfd-COT-Report-BTC-Positions/ | nino_trade | https://www.tradingview.com/u/nino_trade/ | 159 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nino_trade
//@version=5
indicator("COT Report BTC Positions", overlay=false, explicit_plot_zorder=true)
// const
int P_L = 0
int P_S = 1
COLOR_D = #565656
COLOR_AM = #2FBCFE
COLOR_LM = #3BAE6B
COLOR_OR = #C565ED
COLOR_NR = #D31926
// input
string positionString = input.string("Long", "position", options=["Long", "Short"], group="ticker")
int position = switch positionString
"Long" => P_L
"Short" => P_S
bool showD = input.bool(true, "dealer", group="category")
bool showAM = input.bool(true, "asset manager", group="category")
bool showLM = input.bool(true, "leverage funds", group="category")
bool showOR = input.bool(true, "other reportable", group="category")
bool showNR = input.bool(true, "non reportable", group="category")
// source const
cftc = "133741"
string dpLongs = "COT3:" + cftc + "_F_DP_L"
string dpShorts = "COT3:" + cftc + "_F_DP_S"
string ampLongs = "COT3:" + cftc + "_F_AMP_L"
string ampShorts = "COT3:" + cftc + "_F_AMP_S"
string lmpLongs = "COT3:" + cftc + "_F_LMP_L"
string lmpShorts = "COT3:" + cftc + "_F_LMP_S"
string orpLongs = "COT3:" + cftc + "_F_ORP_L"
string orpShorts = "COT3:" + cftc + "_F_ORP_S"
string nrpLongs = "COT3:" + cftc + "_F_NRP_L"
string nrpShorts = "COT3:" + cftc + "_F_NRP_S"
// func
f_getLSSource(position) =>
string dS = na
string amS = na
string lmS = na
string orS = na
string nrS = na
if position == P_L
dS := dpLongs
amS := ampLongs
lmS := lmpLongs
orS := orpLongs
nrS := nrpLongs
else if position == P_S
dS := dpShorts
amS := ampShorts
lmS := lmpShorts
orS := orpShorts
nrS := nrpShorts
[dS, amS, lmS, orS, nrS]
f_security(_sym, _res, _src, _rep) =>
request.security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1]
// source data
[dS, amS, lmS, orS, nrS] = f_getLSSource(position)
sD = (na(dS) or not showD) ? na : f_security(dS, "D", close, false)
sAM = (na(amS) or not showAM) ? na : f_security(amS, "D", close, false)
sLM = (na(lmS) or not showLM) ? na : f_security(lmS, "D", close, false)
sOR = (na(orS) or not showOR) ? na : f_security(orS, "D", close, false)
sNR = (na(nrS) or not showNR) ? na : f_security(nrS, "D", close, false)
// plot, explicit_plot_zorder is ON
plot(showD ? sD : na, 'Dealer', color=color.new(COLOR_D, 0), style=plot.style_line, linewidth=2)
plot(showAM ? sAM : na, 'Asset Mgr', color=color.new(COLOR_AM, 0), style=plot.style_line, linewidth=2)
plot(showLM ? sLM : na, 'Lev Funds', color=color.new(COLOR_LM, 0), style=plot.style_line, linewidth=2)
plot(showOR ? sOR : na, 'Other Rept', color=color.new(COLOR_OR, 0), style=plot.style_line, linewidth=2)
plot(showNR ? sNR : na, 'Non Rept', color=color.new(COLOR_NR, 0), style=plot.style_line, linewidth=2)
|
Market Profile Fixed View | https://www.tradingview.com/script/gYDi6bse-Market-Profile-Fixed-View/ | noop-noop | https://www.tradingview.com/u/noop-noop/ | 1,130 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © noop42
//@version=5
indicator(title="Market Profile Fixed View", shorttitle="MPFV", overlay=true, max_bars_back=1000, max_boxes_count = 500)
invert_colors = input.bool(title="Invert colors", defval=false, group='Color options', group="Display Options")
color_style = input.string("R/G", options=["R/G", "G/B", "B/R"], title="Shading colors", group="Display Options")
z_color = input.int(0, "Third Color", minval=0, maxval=255, group="Display Options")
trans = input.int(30, "Transparency", minval=0, maxval=100, group="Display Options")
bars_nb = input.int(100, "Bars number", maxval=200, minval=3, group="Display Options")
black_borders = input.bool(false, "Black borders on bars", group="Display Options")
display_width = input.int(1, "Display width", group="Display Options")
limits_color=input.color(#00bcd4bb, "High and Low colors", group="Display Options")
bg_color=input.color(#40aec920, "Market profile area background color", group="Display Options")
poc_col = input.color(#ff0000, "Poc color", group="Display Options")
show_poc = input.bool(true, "Show POC", group="Display Options")
extend_poc = input.bool(false, "Extend POC", group="Display Options")
show_box_background = input.bool(true, "Show Market Profile area background", group="Display Options")
show_histogram = input.bool(true, "Show histogram", group="Display Options")
show_high_low = input.bool(true, "Show high/low levels", group="Display Options")
startCalculationDate = input.time(timestamp("20 Jan 2021"), "Start Calculation", confirm=true, group="Data")
endCalculationDate = input.time(timestamp("20 Jan 2021"), "End Calculation", confirm=true, group="Data")
var line topline = na
var line botline = na
var line poc = na
var int beg_offset = 0
var int end_offset = 0
var max_score = 0
var poc_price = 0.0
var float box_width = 0
var bars_score = array.new<int>(bars_nb)
var profile_bars = array.new<box>(bars_nb)
color_value(value, transp=0) =>
step = (255/100.0)
d = value * step
x = 0.0
y = 0.0
z = z_color
if invert_colors
y := value < 50 ? d : 127
x := value < 50 ? 127: 255 - d
else
x := value < 50 ? d : 127
y := value < 50 ? 127: 255 - d
col = color.rgb(math.round(x), math.round(y), math.round(z), transp)
if color_style == "B/R"
col := color.rgb(math.round(y), math.round(z), math.round(x), transp)
if color_style == "G/B"
col := color.rgb(math.round(z), math.round(x), math.round(y), transp)
col
find_h(x, y) =>
h = high
for i=x to y
if high[i] > h
h := high[i]
h
find_l(x, y) =>
l = low
for i=x to y
if low[i] < l
l := low[i]
l
defined = false
if time >= startCalculationDate
beg_offset += 1
if time >= endCalculationDate
end_offset += 1
defined := true
if not defined[1] and defined
h = find_h(beg_offset, end_offset)
l = find_l(beg_offset, end_offset)
if show_high_low
topline := line.new(bar_index-beg_offset, h, bar_index-end_offset, h, color=limits_color)
botline := line.new(bar_index-beg_offset, l, bar_index-end_offset, l, color=limits_color)
if show_box_background
box.new(bar_index-beg_offset, h, bar_index-end_offset, l, bgcolor=bg_color, border_color=#00000000)
if show_poc
ext = extend_poc ? extend.right : extend.none
poc := line.new(bar_index-beg_offset, 0.0, bar_index-end_offset, 0.0, color=poc_col, width=2, extend=ext)
box_width := (h - l) / (bars_nb)
for i=0 to bars_nb-1
score = 0
for x=0 to beg_offset
// Candle is in current bar
in_bar = (high[x] <= h and high[x] >= h-box_width) or (low[x] <= h and low[x] >= h-box_width) or (high[x] > h and low[x] < h-box_width)
if in_bar
score += display_width
if score > max_score
max_score := score
poc_price := h - (box_width/2)
line.set_y1(poc, poc_price)
line.set_y2(poc, poc_price)
array.insert(profile_bars,i, box.new(bar_index-beg_offset, h, bar_index-(beg_offset-score), h-box_width))
array.insert(bars_score,i, score)
h -= box_width
for i=0 to bars_nb-1
f = 100 / max_score
bar_col = show_histogram ? color_value(array.get(bars_score, i)*f, trans) : na
box.set_bgcolor(array.get(profile_bars, i), bar_col)
box.set_border_color(array.get(profile_bars, i), (black_borders ? #000000 : bar_col))
|
SMT Pair (Nephew_Sam_) | https://www.tradingview.com/script/eQmZdVBd-SMT-Pair-Nephew-Sam/ | nephew_sam_ | https://www.tradingview.com/u/nephew_sam_/ | 841 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Nephew_Sam_
//@version=5
indicator(title='SMT Pair (Nephew_Sam_)')
// ----- INPUTS -----
var GRP1 = "SMT settings"
chartType = input.string(title="Line Chart or Candlesticks", defval="CandleSticks", options=["CandleSticks", "Lines"], group = GRP1, tooltip="Should the SMT chart show as a line chart or candlesticks?")
leftbars = input.int(title="Pivot Lookback Left", defval=7, group = GRP1, tooltip="The pivot should be the lowest/highest point in a minimum of x previous candles")
rightBars = input.int(title="Pivot Lookback Right", defval=1, group = GRP1, tooltip="The pivot should be the lowest/highest point in a minium of x next candles (the higher the value, the delayed the confirmation)")
hideLines = input.bool(true, title='Hide Divergence Lines?', group = GRP1)
var GRP2 = "Pair-SMT-Inverse Settings"
pair1 = input.symbol(title='(1) Pair', defval="EURUSD", inline = "1", group = GRP2)
smt1 = input.symbol(title='SMT', defval="DXY", inline = "1", group = GRP2)
smt1_i = input.bool(title=' ', defval=true, inline = "1", group = GRP2)
pair2 = input.symbol(title='(2) Pair', defval="GBPUSD", inline = "2", group = GRP2)
smt2 = input.symbol(title='SMT', defval="EURUSD", inline = "2", group = GRP2)
smt2_i = input.bool(title=' ', defval=false, inline = "2", group = GRP2)
pair3 = input.symbol(title='(3) Pair', defval="AUDUSD", inline = "3", group = GRP2)
smt3 = input.symbol(title='SMT', defval="NZDUSD", inline = "3", group = GRP2)
smt3_i = input.bool(title=' ', defval=false, inline = "3", group = GRP2)
pair4 = input.symbol(title='(4) Pair', defval="XAUUSD", inline = "4", group = GRP2)
smt4 = input.symbol(title='SMT', defval="XAGUSD", inline = "4", group = GRP2)
smt4_i = input.bool(title=' ', defval=false, inline = "4", group = GRP2)
pair5 = input.symbol(title='(5) Pair', defval="BTCUSD", inline = "5", group = GRP2)
smt5 = input.symbol(title='SMT', defval="ALTPERP", inline = "5", group = GRP2)
smt5_i = input.bool(title=' ', defval=false, inline = "5", group = GRP2)
pair6 = input.symbol(title='(6) Pair', defval="USOIL", inline = "6", group = GRP2)
smt6 = input.symbol(title='SMT', defval="UKOIL", inline = "6", group = GRP2)
smt6_i = input.bool(title=' ', defval=false, inline = "6", group = GRP2)
pair7 = input.symbol(title='(7) Pair', defval="SPX500USD", inline = "7", group = GRP2)
smt7 = input.symbol(title='SMT', defval="US30USD", inline = "7", group = GRP2)
smt7_i = input.bool(title=' ', defval=false, inline = "7", group = GRP2)
pair8 = input.symbol(title='(8) Pair', defval="GBPJPY", inline = "8", group = GRP2)
smt8 = input.symbol(title='SMT', defval="USDJPY", inline = "8", group = GRP2)
smt8_i = input.bool(title=' ', defval=false, inline = "8", group = GRP2)
pair9 = input.symbol(title='(9) Pair', defval="ETHUSD", inline = "9", group = GRP2)
smt9 = input.symbol(title='SMT', defval="BTCUSD", inline = "9", group = GRP2)
smt9_i = input.bool(title=' ', defval=false, inline = "9", group = GRP2)
pair10 = input.symbol(title='(10) Pair', defval="NAS100USD", inline = "10", group = GRP2)
smt10 = input.symbol(title='SMT', defval="SPX500USD", inline = "10", group = GRP2)
smt10_i = input.bool(title=' ', defval=false, inline = "10", group = GRP2)
defaultSmt = input.symbol(title='Default SMT', defval="DXY", inline="11", group = GRP2, tooltip="The default SMT divergence pair for all other symbols")
defaultSmt_i = input.bool(title=' ', defval=true, inline="11", group = GRP2)
showdebug = input.bool(false, title='Hover for tips ->', group = GRP2,
tooltip="1. Use checkmark to get the inverse of a pair \n\n" +
"2. For crypto pairs, make sure your pair/smt symbol is correct\n" +
"(BTCUSD / BTCUSDT / BTCUSDTPERP ...) \n\n" +
"3. You can get an index of FX base pairs by averaging the majors (divide JPY by 100):\n" +
"(EURUSD+EURGBP+EURCHF+EURJPY/100+EURAUD+EURNZD+EURCAD)/7\n" +
"(GBPUSD+GBPEUR+GBPCHF+GBPJPY/100+GBPAUD+GBPCAD+GBPNZD)/7 etc..."
)
// ----- INPUTS -----
// ----- SYMBOL -----
symbol = syminfo.ticker // Current Symbol
_i(_pair) => str.contains(_pair, symbol)
smt = _i(pair1) ? smt1 :
_i(pair2) ? smt2 :
_i(pair3) ? smt3 :
_i(pair4) ? smt4 :
_i(pair5) ? smt5 :
_i(pair6) ? smt6 :
_i(pair7) ? smt7 :
_i(pair8) ? smt8 :
_i(pair9) ? smt9 :
_i(pair10) ? smt10 :
_i(smt1) ? pair1 :
_i(smt2) ? pair2 :
_i(smt3) ? pair3 :
_i(smt4) ? pair4 :
_i(smt5) ? pair5 :
_i(smt6) ? pair6 :
_i(smt7) ? pair7 :
_i(smt8) ? pair8 :
_i(smt9) ? pair9 :
_i(smt10) ? pair10 :
defaultSmt
smt_i = _i(pair1) ? smt1_i :
_i(pair2) ? smt2_i :
_i(pair3) ? smt3_i :
_i(pair4) ? smt4_i :
_i(pair5) ? smt5_i :
_i(pair6) ? smt6_i :
_i(pair7) ? smt7_i :
_i(pair8) ? smt8_i :
_i(pair9) ? smt9_i :
_i(pair10) ? smt10_i :
defaultSmt_i
// ----- SYMBOL -----
// ----- OHLC -----
smtH(i = 0) => smt_i ? request.security(smt, timeframe.period, 1 / high[i]) : request.security(smt, timeframe.period, high[i])
smtL(i = 0) => smt_i ? request.security(smt, timeframe.period, 1 / low[i]) : request.security(smt, timeframe.period, low[i])
smtC(i = 0) => smt_i ? request.security(smt, timeframe.period, 1 / close[i]) : request.security(smt, timeframe.period, close[i])
smtO(i = 0) => smt_i ? request.security(smt, timeframe.period, 1 / open[i]) : request.security(smt, timeframe.period, open[i])
// ----- OHLC -----
// ----- Plot -----
typeC = chartType == "CandleSticks"
// plot(typeC ? na : smtC(), color=color.new(color.orange, 0), linewidth=2, title='SMT Close')
plot(typeC ? na : smtH(), color=color.new(color.blue, 0), linewidth=2, title='SMT High')
plot(typeC ? na : smtL(), color=color.new(color.red, 0), linewidth=2, title='SMT Low')
plotcandle(typeC ? smtO() : na, typeC ? smtH() : na, typeC ? smtL() : na, typeC ? smtC() : na,
color=smtC() >= smtO() ? color.lime : color.red,
bordercolor=smtC() >= smtO() ? color.lime : color.red,
wickcolor=smtC() >= smtO() ? color.lime : color.red)
// ----- Plot -----
// ----- SMT Divergence -----
pivotL = ta.pivotlow(low, leftbars, rightBars)
pivotH = ta.pivothigh(high, leftbars, rightBars)
plFound = na(pivotL) ? false : true
phFound = na(pivotH) ? false : true
// Bullish Divergence
priceLL = low[rightBars] < ta.valuewhen(plFound, low[rightBars], 1)
smtHL = smtL(rightBars) > ta.valuewhen(plFound, smtL(rightBars), 1)
bullCond = priceLL and smtHL and plFound
plot(not hideLines and plFound ? smtL(rightBars) : na, offset=-rightBars, title='Regular Bullish', linewidth=2, color=bullCond ? color.lime : na)
// Bearish Divergence
priceHH = high[rightBars] > ta.valuewhen(phFound, high[rightBars], 1)
smtLH = smtH(rightBars) < ta.valuewhen(phFound, smtH(rightBars), 1)
bearCond = priceHH and smtLH and phFound
plot(not hideLines and phFound ? smtH(rightBars) : na, offset=-rightBars, title='Regular Bullish', linewidth=2, color=bearCond ? color.red : na)
// ----- SMT Divergence -----
// DEBUG
if(showdebug)
label.new(bar_index, smtH(), "Chart Pair: " + str.tostring(symbol) + "\n" + "SMT Pair: " + str.tostring(smt) + "\n" + "Inverse: " + str.tostring(smt_i), style = label.style_none, textcolor=color.blue) |
Z-Score with Buy & Sell Signals | https://www.tradingview.com/script/mmyFvori-Z-Score-with-Buy-Sell-Signals/ | Steversteves | https://www.tradingview.com/u/Steversteves/ | 472 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Steversteves
//@version=5
// For informational video, visit the link below:
// https://www.tradingview.com/chart/SPY/Wm4sYvcX-How-to-use-Z-Score-Indicator/
indicator("Z Score with Signals", max_labels_count = 500)
int lengthInput = input.int(500, "Length", minval = 2)
// Calculating High Z Score
a = ta.sma(high, lengthInput)
b = ta.stdev(high, lengthInput)
c = (high - a) / b
// Calculating Low Z Score
d = ta.sma(low, lengthInput)
e = ta.stdev(low, lengthInput)
f = (low - d) / e
// Calculating High and Low Average
z = (c + f) / 2
// Determine Colour
color BullColor = input.color(color.green, "Bull")
color BearColor = input.color(color.red, "Bear")
color BearishColor = input.color(color.orange, "BearishColour")
color BullishColor = input.color(color.orange, "BullishColour")
color VeryBearishColor = input.color(color.red, "Very Bearish")
color VeryBullishColor = input.color(color.green, "Very Bullish")
// Build color
bool bear = z < 0
bool bearish = z > 1.5 and z < 2.0
bool verybearish = z > 2.0
bool bullish = z < -1.5 and z > -2.0
bool verybullish = z < -2.0
color palette = bear ? BearColor : BullColor
color border = bearish ? BearishColor : bullish ? BullishColor : verybearish ? VeryBearishColor : verybullish ? VeryBullishColor : na
plot (z, "Z-Score", style=plot.style_histogram, color=palette)
// SMA line
plot(z, "Border", color = border, linewidth=3)
// Highest vs lowest nuy and sell
highz = ta.highest(z, lengthInput)
lowz = ta.lowest(z, lengthInput)
// Condition Alerts
var wait = 0
wait := wait + 1
if (z <= lowz) and (wait > 50)
wait := 10
label.new(x=bar_index, y=z, text="Buy", size = size.tiny, color=color.green)
alert("Buy The Dip "+syminfo.ticker, alert.freq_once_per_bar)
if (z >= highz) and (wait > 50)
wait := 10
label.new(x=bar_index, y=z, text="Sell", size = size.tiny, color=color.red)
alert("Sell The Rally "+syminfo.ticker, alert.freq_once_per_bar)
|
S2BU2 True Range Bands | https://www.tradingview.com/script/uhPZBXl7/ | sucks2bu2 | https://www.tradingview.com/u/sucks2bu2/ | 27 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sucks2bu2
//@version=5
indicator(title = 'S2BU2 True Range Bands', shorttitle = 'S2BU2 TRB', timeframe = '', timeframe_gaps = true, overlay = true)
//==================================define Inputs==================================//
periodInput = input.int(title = 'ATR Length', defval = 14, minval = 1)
atrFactor = input.float(title = 'ATR Multiplier', defval = 1.0, minval = 0.1)
//==================================calculate data==================================//
float atr = ta.rma(ta.tr(true),periodInput)*atrFactor
//bands
float maOpen = ta.ema(open, periodInput)
float upperBand = maOpen + nz(atr[1])
float lowerBand = maOpen - nz(atr[1])
//====================================plot graphs====================================//
plotBase = plot(maOpen, color= color.white)
plotUpper = plot(upperBand, title = 'Upper Band', color = color.green)
plotLower = plot(lowerBand, title = 'Lower Band', color = color.red)
//fill space between bands
fill(plotBase, plotUpper, title = 'Background Positive', color = color.rgb(66, 245, 120, 95))
fill(plotBase, plotLower, title = 'Background Negative', color = color.rgb(245, 66, 66, 95)) |
Titans Engulfing Retracement Zones | https://www.tradingview.com/script/Chp9fVUS-Titans-Engulfing-Retracement-Zones/ | mmmarsh | https://www.tradingview.com/u/mmmarsh/ | 119 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mmmarsh
//@version=5
indicator("Titans Engulfing Retracement Zones", "TERZ", overlay=true, max_lines_count=500, max_boxes_count=500)
//This indicator comprises 3 concepts.
//The engulfing candle concept at user-defined higher timeframe summarises an impulse move.
//The user-defined retracement levels denotes target entry and target exit zones.
//The direction of trade is further enhanced by a long candle wick condition indicating rejection in the other direction.
//Mechanics
//When an engulfing candle with a long wick is detected on the higher timeframe, the entery and exit zones are plotted.
//The plots remain until a engulfing candle with long wick is detected.
string tfInput = input.timeframe("60", "Higher Timeframe")
// Initialize Global Variables
var Entry1=float(na)
var Entry2=float(na)
var Profit1=float(na)
var Profit2=float(na)
var line Entry1Line=na
var line Entry2Line=na
var line Profit1Line=na
var line Profit2Line=na
var box EntryBox=na
var box ProfitBox=na
var CandleRange=float(na)
//Get Higher TimeFrame Data Series
Close=request.security(syminfo.tickerid, tfInput, close)
Open=request.security(syminfo.tickerid, tfInput, open)
High=request.security(syminfo.tickerid, tfInput, high)
Low=request.security(syminfo.tickerid, tfInput, low)
CandleRange:=math.abs(High-Low)
//ID Bullish and Bearish Engulfing Candles
Bullish=(Close>Open and Close>Close[1] and Open<Open[1] and math.abs(Close-Open)>math.abs(Close[1]-Open[1]))? true : false
Bearish=(Open>Close and Close<Close[1] and Open>Open[1] and math.abs(Close-Open)>math.abs(Close[1]-Open[1]))? true : false
//Check Engulfing Candle Wick is longer than Previous Candle Wick
LongWick=false
PreviousCandleBullish= Close[1]>Open[1]? true : false
if Bullish and PreviousCandleBullish and (Open-Low)<(Open[1]-Low[1])
LongWick:=true
else if Bullish and not PreviousCandleBullish and (Open-Low)<(Close[1]-Low[1])
LongWick:=true
else if Bearish and PreviousCandleBullish and (High-Open)<(High[1]-Close[1])
LongWick:=true
else if Bearish and not PreviousCandleBullish and (High-Open)<(High[1]-Open[1])
LongWick:=true
else
LongWick:=false
//Set Zone Levels
RatioEntry1=input.float(0.000,'Entry 1')
RatioEntry2=input.float(0.382,'Entry 2')
RatioProfit1=input.float(0.786,'Profit 1')
RatioProfit2=input.float(1.618,'Profit 2')
//Calculate Levels for Valid Engulfing Condition
if Bullish and LongWick
Entry1:=Open+CandleRange*RatioEntry1
Entry2:=Open+CandleRange*RatioEntry2
Profit1:=Open+CandleRange*RatioProfit1
Profit2:=Open+CandleRange*RatioProfit2
if Bearish and LongWick
Entry1:=Open-CandleRange*RatioEntry1
Entry2:=Open-CandleRange*RatioEntry2
Profit1:=Open-CandleRange*RatioProfit1
Profit2:=Open-CandleRange*RatioProfit2
// Detect changes in timeframe.
bool newTF = ta.change(time(tfInput))
if newTF
// New bar in higher timeframe; reset values and create new lines and box.
Entry1Line:= line.new(bar_index - 1, Entry1, bar_index, Entry1, color = color.blue, width = 1)
Entry2Line:= line.new(bar_index - 1, Entry1, bar_index, Entry1, color = color.blue, width = 1)
Profit1Line:= line.new(bar_index - 1, Profit1, bar_index, Profit1, color = color.orange, width = 1)
Profit2Line:= line.new(bar_index - 1, Profit2, bar_index, Profit2, color = color.orange, width = 1)
EntryBox := box.new(bar_index - 1, Entry1, bar_index, Entry2, border_color = na, bgcolor = color.new(color.blue, 50))
ProfitBox := box.new(bar_index - 1, Profit1, bar_index, Profit2, border_color = na, bgcolor = color.new(color.orange, 50))
int(na)
else
// On other bars, extend the right coordinate of lines and box.
line.set_x2(Entry1Line, bar_index)
line.set_x2(Entry2Line, bar_index)
line.set_x2(Profit1Line, bar_index)
line.set_x2(Profit2Line, bar_index)
box.set_right(EntryBox, bar_index)
box.set_right(ProfitBox, bar_index)
int(na)
plotshape(Bullish,style=shape.triangleup,location=location.belowbar,color=color.new(color.green,20))
plotshape(Bearish,style=shape.triangledown,location=location.abovebar,color=color.new(color.red,20))
alertcondition((Bullish and LongWick) or (Bearish and LongWick), 'Engulfing with Wick', '{{exchange}}:{{ticker}} - Engulfing candle with long wick detected on higher timeframe at {{timenow}}. New target zones marked') |
RSI Wave Signals | https://www.tradingview.com/script/gztIGBjt-RSI-Wave-Signals/ | bartua | https://www.tradingview.com/u/bartua/ | 270 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bartua
// Optimized Trend Tracker function under copyright and courtesy of KivancOzbilgic.
//@version=5
indicator("RSI Wave Signals", overlay=false)
period1 = input(2,"Period For MA")
mtp1 = input.float(0.7,"Trailing Percentage of MA",step=0.1)
rsiLength = input(12,"RSI Length")
ottFunction(src,length,percent)=>
valpha=2/(length+1)
vud1=src>src[1] ? src-src[1] : 0
vdd1=src<src[1] ? src[1]-src : 0
vUD=math.sum(vud1,9)
vDD=math.sum(vdd1,9)
vCMO=nz((vUD-vDD)/(vUD+vDD))
VAR=0.0
VAR:=nz(valpha*math.abs(vCMO)*src)+(1-valpha*math.abs(vCMO))*nz(VAR[1])
MAvg=VAR
fark=MAvg*percent*0.01
longStop = MAvg - fark
longStopPrev = nz(longStop[1], longStop)
longStop := MAvg > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = MAvg + fark
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := MAvg < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dir
MT = dir==1 ? longStop: shortStop
OTT=MAvg>MT ? MT*(200+percent)/200 : MT*(200-percent)/200
[dir,OTT[2],MAvg]
//MACD Calculations//
rsi = ta.rsi(close,rsiLength)+1000
[dir1,ott1,sl1] = ottFunction(rsi,period1,mtp1)
plot(ott1,title="OTT",linewidth=1,color=color.white)
plot(sl1,title="SL",linewidth=2,color=color.aqua)
overSoldLevel = input(40,title="Oversold Level") +1000
overBoughtLevel = input(60,title="Overbought Level") +1000
plot(overSoldLevel, title="Oversold",style=plot.style_circles,color=color.blue)
plot(overBoughtLevel, title="Overbought",style=plot.style_circles,color=color.blue)
|
Relative Strength Super Smoother by lastguru | https://www.tradingview.com/script/1c25ztKi-Relative-Strength-Super-Smoother-by-lastguru/ | lastguru | https://www.tradingview.com/u/lastguru/ | 25 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © lastguru, 2022. All right reserved
//@version=5
indicator("Relative Strength Super Smoother by lastguru", "RSSS [lastguru]", overlay=true)
import lastguru/CommonFilters/1 as cf
import lastguru/LengthAdaptation/4 as la
////////////
// Inputs //
////////////
src = input(close, title="Source", inline="1")
DynamicLow = input.int(title="Lower Bound", defval=8)
DynamicHigh = input.int(title="Upper Bound", defval=50)
RSLen = input.int(title="RSI Length (if 0, use Upper Bound)", defval=0)
newLen = math.round(la.vidyaRS(src, RSLen == 0 ? DynamicHigh : RSLen, DynamicLow, DynamicHigh))
float out = cf.supers2(src, newLen)
//////////////
// Plotting //
//////////////
plot(out, "RSSS", color=color.yellow, linewidth=2)
|
Capeya Bar Color | https://www.tradingview.com/script/YCdny8jJ-Capeya-Bar-Color/ | Sekiyo | https://www.tradingview.com/u/Sekiyo/ | 9 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sekiyo
//@version=5
indicator("Capeya Bar Color", overlay=true)
//INPUTs
isC2C = input.bool(false, "Close to Close")
isDol = input.bool(false, "Dollar Volume")
thsld = input.float(1.0, "Threasold")
Color_Up = input.color(color.blue, "Bullish Color")
Color_Do = input.color(color.fuchsia, "Bearish Color")
Volume = isDol ? volume * close : volume
isbullish = isC2C ? close[1] <= close and Volume > thsld * Volume[1] : open <= close and Volume > thsld * Volume[1]
isbearish = isC2C ? close[1] > close and Volume > thsld * Volume[1] : open > close and Volume > thsld * Volume[1]
//PALETTEs
Palette_Vol = isbullish ? Color_Up : isbearish ? Color_Do : na
barcolor(Palette_Vol) |
Squeeze M + ADX + TTM (Trading Latino & John Carter) by [Rolgui] | https://www.tradingview.com/script/dD46cfeI/ | rolgui | https://www.tradingview.com/u/rolgui/ | 353 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rolgui
// @version=4
// 'All in One' indicator for TradingLatino's strategy combined with John F. Carter's strategy (turned off by default).
study(title="Squeeze M. + ADX + TTM (TradingLatino & John F. Carter) by [Rolgui]", shorttitle="SQZ+ADX+TTM [R]", overlay=false)
// 1) Squeeze Momentum Oscillator
// original code section by @ LazyBear
show_SQZ = input(true, title="Show Squeeze Oscillator")
allLengthValue = input(20, title="BB Length", type=input.integer)
BB_mult = input(2.0,title="BB MultFactor")
lengthKC=input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")
linearMomentum = input(20, title="Linear Momentum", type=input.integer)
useTrueRangeM = true
// Calculate BB
source = close
BB_basis = sma(source, allLengthValue)
dev = BB_mult * stdev(source, allLengthValue)
upperBB = BB_basis + dev
lowerBB = BB_basis - dev
// Calculate KC
KC_basis = sma(source, lengthKC)
range = useTrueRangeM ? tr : (high - low)
devKC = sma(range, allLengthValue)
upperKC = KC_basis + devKC * multKC
lowerKC = KC_basis - devKC * multKC
sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz = (sqzOn == false) and (sqzOff == false)
val = linreg(source - avg(avg(highest(high, linearMomentum), lowest(low, linearMomentum)),sma(close,linearMomentum)), linearMomentum,0)
bcolor = iff( val > 0, iff( val > nz(val[1]), color.rgb(46, 245, 39, 0), color.rgb(16, 120, 13, 0)), iff( val < nz(val[1]), color.rgb(217, 6, 6, 0), color.rgb(98, 0, 0, 0)))
sz = linreg(source - avg(avg(highest(high, allLengthValue), lowest(low, allLengthValue)), sma(close, allLengthValue)), allLengthValue, 0)
//****************************************************************************************************************************************************************************************//
// 2) Average Directional Indez
// original code section by @ matetaronna
int scale = 75
useTrueRange = true
show_ADX = input(true, title="Show Average Directional Index")
scaleADX = 2.0
float far = 0
int adxlen = input(14, title="ADX Longitud", minval=1, step=1)
int dilen = 14
keyLevel = input(23, title="Key Level", minval=1, step=1)
// ADX Calculations
dirmov(len) =>
up = change(high)
down = -change(low)
truerange = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
[adx, plus, minus]
// ADX Output values
[adxValue, diplus, diminus] = adx(dilen, adxlen)
// Setting indicator's scale to match the others.
biggest(series) =>
max = 0.0
max := nz(max[1], series)
if series > max
max := series
max
ni = biggest(sz)
far1=far* ni/scale
adx_scale = (adxValue - keyLevel) * ni/scale
adx_scale2 = (adxValue - keyLevel+far) * ni/scale
//****************************************************************************************************************************************************************************************//
// 3) Trade The Market Waves A, B and C
// original code section by @ jombie
showWaves = input(false, title = "Show TTM Waves", type=input.bool)
usewa = showWaves
waveALength = input(title="Wave A Length", type=input.integer, defval=55, minval=0)
usewb = showWaves
waveBLength = input(title="Wave B Length", type=input.integer, defval=144, minval=0)
usewc = showWaves
waveCLength = input(title="Wave C Length", type=input.integer, defval=233, minval=0)
// Wave A
fastMA1 = usewa ? ema(close, 8) : na
slowMA1 = usewa ? ema(close, waveALength) : na
macd1 = usewa ? fastMA1 - slowMA1 : na
signal1 = usewa ? ema(macd1, waveALength) : na
histA = usewa ? macd1 - signal1 : na
// Wave B
fastMA3 = usewb ? ema(close, 8) : na
slowMA3 = usewb ? ema(close, waveBLength) : na
macd3 = usewb ? fastMA3 - slowMA3 : na
signal3 = usewb ? ema(macd3, waveALength) : na
histB = usewb ? macd3 - signal3 : na
// Wave C
fastMA5 = usewc ? ema(close, 8) : na
slowMA5 = usewc ? ema(close, waveCLength) : na
macd5 = usewc ? fastMA5 - slowMA5 : na
signal5 = usewc ? ema(macd5, waveCLength) : na
histC = usewc ? macd5 - signal5 : na
//****************************************************************************************************************************************************************************************//
// 4) Squeeze Momentum Compression
// original code section by @ joren
// Keltner Levels
KC_mult_high = 1.0
KC_mult_mid = 1.5
KC_mult_low = 2.0
KC_upper_high = KC_basis + devKC * KC_mult_high
KC_lower_high = KC_basis - devKC * KC_mult_high
KC_upper_mid = KC_basis + devKC * KC_mult_mid
KC_lower_mid = KC_basis - devKC * KC_mult_mid
KC_upper_low = KC_basis + devKC * KC_mult_low
KC_lower_low = KC_basis - devKC * KC_mult_low
// Squeeze Momentum Conditions
NoSqz = lowerBB < KC_lower_low or upperBB > KC_upper_low // No Squeeze.
LowSqz = lowerBB >= KC_lower_low or upperBB <= KC_upper_low // Low Compression.
MidSqz = lowerBB >= KC_lower_mid or upperBB <= KC_upper_mid // Mid Compression. -> Momentum
HighSqz = lowerBB >= KC_lower_high or upperBB <= KC_upper_high // High Compression. -> Momentum
// Squeeze Momentum colors
sq_color = HighSqz ? color.rgb(136, 0, 255, 0) : MidSqz ? color.rgb(136, 0, 255, 0) : LowSqz ? color.new(color.white, 0) : color.new(color.white, 0)
// Show Squeeze Momentum
showTTMSQZ = input(false, type=input.bool, title="Show Squeeze Momentum")
//****************************************************************************************************************************************************************************************//
// Draw plots section by visibility order.
// TTM Waves
plot(histA, color=color.new(color.teal, 80), style=plot.style_area, title="Wave A", linewidth=1)
plot(histB, color=color.new(color.orange, 90), style=plot.style_area, title="Wave B", linewidth=1)
plot(histC, color=color.new(color.yellow, 90), style=plot.style_area, title="Wave C", linewidth=1)
// Squeeze Oscillator
plot(show_SQZ ? val : na, title="Squeeze Oscillator", color=bcolor, style=plot.style_columns, linewidth=4)
// Key Level
plot(show_ADX ? far1 * scaleADX : na, color=color.white, title="Key Level", linewidth = 1)
// Squeeze Momentum
plot(showTTMSQZ? 0 : na, title='Squeeze Momentum', color=sq_color, style=plot.style_line, linewidth=2)
// ADX
p1 = plot(show_ADX ? adx_scale2 * scaleADX : show_ADX ? adx_scale * scaleADX : na, color = color.white, title = "ADX", linewidth = 2)
|
All Central Bank Interest Rates | https://www.tradingview.com/script/jP2n3Bax-All-Central-Bank-Interest-Rates/ | OrcChieftain | https://www.tradingview.com/u/OrcChieftain/ | 56 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © greenmask9
//@version=4
study(title = "All Central Bank Interest Rates", shorttitle = "CB Rates+", overlay=true, precision = 3)
////////////
last_update = input(true, "Last Indicator Update - 15.05.2022")
i_position = input(type = input.string, title = "Table Placement", defval = "Middle Right",
options = ["Top Right", "Middle Right", "Bottom Right", "Middle Center"])
i_two_historical = input(true, "Activate Two Historical Values")
i_table_width = input(title = "Text", defval = 8)
i_table_height = input(title = "Text", defval = 5)
ic_text = input(type = input.color, title = "Text", defval = color.new(color.yellow, 0))
ic_table = input(type = input.color, title = "Background", defval = color.new(color.gray, 70))
position = i_position == "Top Right" ? position.top_right : i_position == "Middle Right" ? position.middle_right : i_position == "Bottom Right" ? position.bottom_right : position.middle_center
var table perfTable = table.new(position, 3, 8, border_width = 1)
width = i_table_width
height = i_table_height
table.cell(perfTable, 0, 0, text = "USD: 3.500 \n ↑ 15.12.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
table.cell(perfTable, 0, 1, text = "CAD: 4.250 \n ↑ 07.12.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
table.cell(perfTable, 0, 2, text = "EUR: 2.500 \n - 15.12.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
table.cell(perfTable, 0, 3, text = "GBP: 3.500 \n ↑ 15.12.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
table.cell(perfTable, 0, 4, text = "CHF: 1.000 \n - 15.12.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
table.cell(perfTable, 0, 5, text = "AUD: 3.100 \n ↑ 06.12.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
table.cell(perfTable, 0, 6, text = "NZD: 4.250 \n ↑ 23.11.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
table.cell(perfTable, 0, 7, text = "JPY: -0.10 \n - 01.01.16", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
//if i_two_historical
// table.cell(perfTable, 1, 0, text = "USD: 1.000 \n ↑ 04.05.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 1, 1, text = "CAD: 1.000 \n ↑ 13.04.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 1, 2, text = "EUR: 0.050 \n - 04.09.14", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 1, 3, text = "GBP: 1.000 \n ↑ 05.05.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 1, 4, text = "CHF: -0.75 \n - 15.01.15", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 1, 5, text = "AUD: 0.350 \n ↑ 03.05.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 1, 6, text = "NZD: 1.500 \n ↑ 13.04.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 1, 7, text = "JPY: 0.000 \n - 05.10.10", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
//
// table.cell(perfTable, 2, 0, text = "USD: 0.500 \n ↑ 16.03.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 2, 1, text = "CAD: 0.500 \n ↑ 02.03.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 2, 2, text = "EUR: 0.150 \n - 05.07.14", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 2, 3, text = "GBP: 0.750 \n ↑ 16.03.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 2, 4, text = "CHF: -0.50 \n - 18.12.14", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 2, 5, text = "AUD: 0.100 \n - 03.11.20", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 2, 6, text = "NZD: 1.000 \n ↑ 22.02.22", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
// table.cell(perfTable, 2, 7, text = "JPY: 0.100 \n - 19.12.08", bgcolor = ic_table, text_color = ic_text, width = width, height = height)
|
TASC 2022.05 Relative Strength Exponential Moving Average | https://www.tradingview.com/script/b3DVUyB3-TASC-2022-05-Relative-Strength-Exponential-Moving-Average/ | PineCodersTASC | https://www.tradingview.com/u/PineCodersTASC/ | 165 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCodersTASC
// TASC Issue: May 2022 - Vol. 40, Issue 6
// Article: Relative Strength Moving Averages
// Part 1: The Relative Strength
// Exponential Moving Average (RS EMA)
// Article By: Vitali Apirine
// Language: TradingView's Pine Script v5
// Provided By: PineCoders, for tradingview.com
//@version=5
indicator('TASC 2022.05 Relative Strength EMA', 'RSEMA', true)
float src = input.source(close, 'Source:')
int periods = input.int(50, 'EMA Length:', minval=14)
int pds = input.int(50, 'RS Length:', minval=4)
float mltp = input.int(10, 'RS Multiplier:', minval=0)
rsema(float source = close,
simple int emaPeriod = 50,
simple int rsPeriod = 50,
float multiplier = 10.0
) =>
var float mltp1 = 2.0 / (emaPeriod + 1.0)
var float coef1 = 2.0 / (rsPeriod + 1.0)
var float coef2 = 1.0 - coef1
float diff = source - nz(source[1], source)
float cup = diff > 0 ? diff : 0.0
float cdn = diff < 0 ? math.abs(diff) : 0.0
float acup = na, acup := coef1 * cup + coef2 * nz(acup[1])
float acdn = na, acdn := coef1 * cdn + coef2 * nz(acdn[1])
float rs = math.abs(acup - acdn) / (acup + acdn)
float rate = mltp1 * (1.0 + nz(rs, 0.00001) * multiplier)
float rsma = na
rsma := rate * source + (1.0 - rate) * nz(rsma[1], source)
rsma
float rsema = rsema(src, periods, pds, mltp)
plot(rsema, title='RS EMA', color=#009900, linewidth=2)
|
Playing the cross | https://www.tradingview.com/script/s7Biyzhv-Playing-the-cross/ | Glenn234 | https://www.tradingview.com/u/Glenn234/ | 5 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Glenn234
//@version=5
indicator("Playing the cross", shorttitle="PtC", overlay=true)
// Ichimoku code - Kijun-Sen
basePeriods = input.int(26, minval=1, title="Kijun-Sen length")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
KijunSen = donchian(basePeriods)
plot(KijunSen, color=color.green, title="Kijun-Sen")
// Moving Average Exponential code
len = input.int(55, minval=1, title="EMA length")
src = input(close, title="Source")
MovingAverage = ta.ema(src, len)
plot(MovingAverage, title="EMA", color=color.red)
// Cross code
Up = MovingAverage > KijunSen and MovingAverage[1] < KijunSen[1]
Down = MovingAverage < KijunSen and MovingAverage[1] > KijunSen[1]
bgcolor(Up ? color.new(color.green, 60) : na, title="Up Cross")
bgcolor(Down ? color.new(color.red, 60) : na, title="Down Cross")
|
Bears Bulls Impulse | https://www.tradingview.com/script/sg0qhVuS-Bears-Bulls-Impulse/ | ThiagoSchmitz | https://www.tradingview.com/u/ThiagoSchmitz/ | 56 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ThiagoSchmitz
//@version=5
indicator("Bears Bulls Impulse")
// ———————————————————— Inputs {
int lwma_period = input.int(13, "LWMA Period", minval=1)
int lwma_weight = input.int(1, "LWMA Weight", minval=1)
float srcInput = input.source(hlc3, "Source")
// }
// ———————————————————— Functions {
// @function Get the value of Linear-weighted Moving Average
// @param (src source) Source for the calculation. Default is hlc3
// @param (period int) Lookback period to be get the LWMA
// @param (weight int) Amount of weight to be use on the LWMA calculation
// @returns (float) A float variable reflecting the LWMA value
get_lwma(src,period, weight) =>
sub = (weight/period)-1
float p = na
float d = na
float sum = 0
float divider = 0
for i = 0 to period-1
p := src[i] * ((weight-i)-sub)
d := (weight-i)-sub
sum := sum + p
divider := divider + d
sum / divider
// }
// ———————————————————— Calculations and Plots {
lwma = get_lwma(srcInput, lwma_period, lwma_weight)
color histColor = (low - lwma) + (high - lwma) >= 0 ? color.green : color.red
plot(1, "Bulls Bears", histColor, 2, plot.style_histogram)
// }
|
KINSKI USDT Market Cap Dominance | https://www.tradingview.com/script/aA0U6tJl/ | KINSKI | https://www.tradingview.com/u/KINSKI/ | 55 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © KINSKI
//@version=5
indicator('KINSKI USDT Market Cap Dominance', shorttitle='USDT Market Cap Dominance', precision=0, overlay=false)
//************ Colors
color colorDefault = #9900FF
color colorUptrend = #00FF11
color colorDowntrend = #FF0004
color valColorsUpTrendHistogram = #007007, color valColorsUpTrendStrongHistogram = #00FF11, color valColorsUpWeakHistogram = #007a08, color valColorsUpTrendStrongHintHistogram = #e8be00
color valColorsDownTrendHistogram = #8A0002, color valColorsDownTrendStrongHistogram = #FF0004, color valColorsDownTrendWeakHistogram = #750001
color valColorsNeutral = #4f4f4f, color valColorMA = #9900FF
//********** Functions
_funcLineStyle(_type) =>
switch _type
"Circles" => plot.style_circles
"Stepline" => plot.style_stepline
"Line With Breaks" => plot.style_linebr
"Step Line With Diamonds" => plot.style_stepline_diamond
=>
plot.style_line
// Smoothed Moving Average (SMMA)
_funcSMMA(_src, _len) =>
tmpSMA = ta.sma(_src, _len)
tmpVal = 0.0
na(tmpVal[1]) ? tmpSMA : (tmpVal[1] * (_len - 1) + _src) / _len
// Triple EMA (TEMA)
_funcTEMA(_src, _len) =>
ema1 = ta.ema(_src, _len)
ema2 = ta.ema(ema1, _len)
ema3 = ta.ema(ema2, _len)
3 * (ema1 - ema2) + ema3
// Double Expotential Moving Average (DEMA)
_funcDEMA(_src, _len) =>
2 * ta.ema(_src, _len) - ta.ema(ta.ema(_src, _len), _len)
// Exponential Hull Moving Average (EHMA)
_funcEHMA(_src, _len) =>
tmpVal = math.max(2, _len)
ta.ema(2 * ta.ema(_src, tmpVal / 2) - ta.ema(_src, tmpVal), math.round(math.sqrt(tmpVal)))
// Kaufman's Adaptive Moving Average (KAMA)
_funcKAMA(_src, _len) =>
tmpVal = 0.0
sum_1 = math.sum(math.abs(_src - _src[1]), _len)
sum_2 = math.sum(math.abs(_src - _src[1]), _len)
nz(tmpVal[1]) + math.pow((sum_1 != 0 ? math.abs(_src - _src[_len]) / sum_2 : 0) * (0.666 - 0.0645) + 0.0645, 2) * (_src - nz(tmpVal[1]))
// Variable Index Dynamic Average (VIDYA)
_funcVIDYA(_src, _len) =>
_diff = ta.change(_src)
_uppperSum = math.sum(_diff > 0 ? math.abs(_diff) : 0, _len)
_lowerSum = math.sum(_diff < 0 ? math.abs(_diff) : 0, _len)
_chandeMomentumOscillator = (_uppperSum - _lowerSum) / (_uppperSum + _lowerSum)
_factor = 2 / (_len + 1)
tmpVal = 0.0
_src * _factor * math.abs(_chandeMomentumOscillator) + nz(tmpVal[1]) * (1 - _factor * math.abs(_chandeMomentumOscillator))
// Coefficient of Variation Weighted Moving Average (COVWMA)
_funcCOVWMA(_src, _len) =>
_coefficientOfVariation = ta.stdev(_src, _len) / ta.sma(_src, _len)
_cw = _src * _coefficientOfVariation
math.sum(_cw, _len) / math.sum(_coefficientOfVariation, _len)
// Fractal Adaptive Moving Average (FRAMA)
_funcFRAMA(_src, _len) =>
_coefficient = -4.6
_n3 = (ta.highest(high, _len) - ta.lowest(low, _len)) / _len
_hd2 = ta.highest(high, _len / 2)
_ld2 = ta.lowest(low, _len / 2)
_n2 = (_hd2 - _ld2) / (_len / 2)
_n1 = (_hd2[_len / 2] - _ld2[_len / 2]) / (_len / 2)
_dim = _n1 > 0 and _n2 > 0 and _n3 > 0 ? (math.log(_n1 + _n2) - math.log(_n3)) / math.log(2) : 0
_alpha = math.exp(_coefficient * (_dim - 1))
_sc = _alpha < 0.01 ? 0.01 : _alpha > 1 ? 1 : _alpha
ta.cum(1) <= 2 * _len ? _src : _src * _sc + nz(_src[1]) * (1 - _sc)
// Karobein
_funcKarobein(_src, _len) =>
tmpMA = ta.ema(_src, _len)
tmpUpper = ta.ema(tmpMA < tmpMA[1] ? tmpMA/tmpMA[1] : 0, _len)
tmpLower = ta.ema(tmpMA > tmpMA[1] ? tmpMA/tmpMA[1] : 0, _len)
tmpRescaleResult = (tmpMA/tmpMA[1]) / (tmpMA/tmpMA[1] + tmpLower)
(2*((tmpMA/tmpMA[1]) / (tmpMA/tmpMA[1] + tmpRescaleResult * tmpUpper)) - 1) * 100
// RSX based Noise Remover based Noise Remover
_funcRemoveNoise(_src, _len) =>
f8 = 100 * _src
f10 = nz(f8[1])
v8 = f8 - f10
f18 = 3 / (_len + 2)
f20 = 1 - f18
f28 = 0.0
f28 := f20 * nz(f28[1]) + f18 * v8
f30 = 0.0
f30 := f18 * f28 + f20 * nz(f30[1])
vC = f28 * 1.5 - f30 * 0.5
f38 = 0.0
f38 := f20 * nz(f38[1]) + f18 * vC
f40 = 0.0
f40 := f18 * f38 + f20 * nz(f40[1])
v10 = f38 * 1.5 - f40 * 0.5
f48 = 0.0
f48 := f20 * nz(f48[1]) + f18 * v10
f50 = 0.0
f50 := f18 * f48 + f20 * nz(f50[1])
v14 = f48 * 1.5 - f50 * 0.5
f58 = 0.0
f58 := f20 * nz(f58[1]) + f18 * math.abs(v8)
f60 = 0.0
f60 := f18 * f58 + f20 * nz(f60[1])
v18 = f58 * 1.5 - f60 * 0.5
f68 = 0.0
f68 := f20 * nz(f68[1]) + f18 * v18
f70 = 0.0
f70 := f18 * f68 + f20 * nz(f70[1])
v1C = f68 * 1.5 - f70 * 0.5
f78 = 0.0
f78 := f20 * nz(f78[1]) + f18 * v1C
f80 = 0.0
f80 := f18 * f78 + f20 * nz(f80[1])
v20 = f78 * 1.5 - f80 * 0.5
f88_ = 0.0
f90_ = 0.0
f88 = 0.0
f90_ := nz(f90_[1]) == 0 ? 1 : nz(f88[1]) <= nz(f90_[1]) ? nz(f88[1]) + 1 : nz(f90_[1]) + 1
f88 := nz(f90_[1]) == 0 and _len - 1 >= 5 ? _len - 1 : 5
f0 = f88 >= f90_ and f8 != f10 ? 1 : 0
f90 = f88 == f90_ and f0 == 0 ? 0 : f90_
v4_ = f88 < f90 and v20 > 0 ? (v14 / v20 + 1) * 50 : 50
v4_ > 100 ? 100 : v4_ < 0 ? 0 : v4_
// calculate the moving average with the transferred settings
_funcCalcMA(_type, _src, _len) =>
float ma = switch _type
"COVWMA" => _funcCOVWMA(_src, _len)
"DEMA" => _funcDEMA(_src, _len)
"EMA" => ta.ema(_src, _len)
"EHMA" => _funcEHMA(_src, _len)
"HMA" => ta.hma(_src, _len)
"KAMA" => _funcKAMA(_src, _len)
"RMA" => ta.rma(_src, _len)
"RSX based Noise Remover" => _funcRemoveNoise(_src, _len)
"SMA" => ta.sma(_src, _len)
"SMMA" => _funcSMMA(_src, _len)
"TEMA" => _funcTEMA(_src, _len)
"FRAMA" => _funcFRAMA(_src, _len)
"VWMA" => ta.vwma(_src, _len)
"VIDYA" => _funcVIDYA(_src, _len)
"WMA" => ta.wma(_src, _len)
"Karobein" => _funcKarobein(_src, _len)
=>
float(na)
_funcCalcHistogramColor(_val) =>
conditionColors_1 = _val > nz(_val[1]) ? valColorsUpTrendStrongHistogram : valColorsUpTrendHistogram
conditionColors_2 = _val < nz(_val[1]) ? valColorsDownTrendStrongHistogram : valColorsDownTrendHistogram
(_val == -0.00 or _val == 0.00) ? valColorsNeutral : _val > 0 ? conditionColors_1 : conditionColors_2
_funcHistogram(_type, _src, _len) =>
tmpHistogramSignal = _funcCalcMA(_type, _src, _len)
tmpHistogram = _src - tmpHistogramSignal
tmpAdvancedRatingColor = _funcCalcHistogramColor(tmpHistogram)
[tmpHistogram, tmpAdvancedRatingColor]
//********** Inputs
bool inputShowAsHistogram = input.bool(title='Show as Histogram', group='Settings', defval=false)
string inputUsdtVariant = input.string(title='Variant', group='Settings', defval='CRYPTOCAP:USDT.D', options=['CRYPTOCAP:USDT', 'CRYPTOCAP:USDT.D', 'CRYPTOCAP:OTHERS.D'])
inputTimeframe = input.timeframe("", "Resolution:", group="Settings")
inputSource = input(title='Source', group='Settings', defval=close)
string inputMaType = input.string(title='Smoothing: Type', group='Smoothing', defval='WMA', options=['DISABLED', 'COVWMA', 'DEMA', 'EMA', 'EHMA', 'FRAMA', 'HMA', 'KAMA', 'Karobein', 'RMA', 'RSX based Noise Remover', 'SMA', 'SMMA', 'TEMA', 'VIDYA', 'VWMA', 'WMA'])
int inputMaLength = input.int(title='Smoothing: Period', group='Smoothing', minval=1, maxval=1000, defval=5)
// Histogram
string inputHistogramType = input.string(title='Smoothing:', group='Histogram', defval='WMA', options=['DISABLED', 'COVWMA', 'DEMA', 'EMA', 'EHMA', 'FRAMA', 'HMA', 'KAMA', 'Karobein', 'RMA', 'RSX based Noise Remover', 'SMA', 'SMMA', 'TEMA', 'VIDYA', 'VWMA', 'WMA'])
int inputHistogramLength = input.int(title='Period:', group='Histogram', defval=4, maxval=100)
// Styles
bool inputShowUpDownMovements = input.bool(title='Show Up/Down Movemnts', group='Style', defval=false)
color inputColorDefault = input(title='Color: Default', group='Style', defval=colorDefault)
color inputColorUptrend = input(title='Color: Uptrend', group='Style', defval=colorUptrend)
color inputColorDowntrend = input(title='Color: Downtrend', group='Style', defval=colorDowntrend)
int inputLineWidth = input.int(title='Size', group='Style', minval=1, maxval=4, defval=2, step=1)
int inputLineTransparency = input.int(title='Transparency', group='Style', minval=0, maxval=100, defval=0, step=4)
string inputLineStyle = input.string(title='Type', group='Style', defval='Line', options=['Line', 'Stepline', 'Step Line With Diamonds', 'Circles'])
//********** Calculation
float valUsdtMarketCap = request.security(inputUsdtVariant, inputTimeframe, inputSource)
float valUsdtMarketCapFinal = inputMaType != 'DISABLED' ? _funcCalcMA(inputMaType, valUsdtMarketCap, inputMaLength) : valUsdtMarketCap
bool valIsUptrend = valUsdtMarketCapFinal > nz(valUsdtMarketCapFinal[1])
color valFinalColor = inputShowUpDownMovements ? (valIsUptrend ? inputColorUptrend : inputColorDowntrend) : inputColorDefault
[valPlotHistogram, valPlotHistogramColor] = _funcHistogram(inputHistogramType, valUsdtMarketCapFinal, inputHistogramLength)
//************ Plotting
plot(inputShowAsHistogram ? na : valUsdtMarketCapFinal-valPlotHistogram, title='USDT', color=color.new(valFinalColor, inputLineTransparency), linewidth=inputLineWidth, style=_funcLineStyle(inputLineStyle))
plot(inputShowAsHistogram ? valPlotHistogram : na, title='Histogram', style=plot.style_columns, color=color.new(valPlotHistogramColor, 0), linewidth=2)
|
Bollinger Band with Moving Average & Pin Bars | https://www.tradingview.com/script/RszS7122-Bollinger-Band-with-Moving-Average-Pin-Bars/ | gary_trades | https://www.tradingview.com/u/gary_trades/ | 74 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gary_trades
//This indicator was specifically built to be used for trading the Scalpius Trading System promoted by @scottphillipstrading
//Additionally I've added daily and weekly Highs, Lows and Central Pivot lines
//The central indicators used in the Scalpius trading system which are included here are:
//The Bollinger Band, chart plotting of Pin Bars (Hammers & Shooting Stars) and a adjustable moving average,
//the user can select EMA, SMA or WMA and length, the default settings are 8EMA as per the Scalpius system rules.
//@version=5
indicator(shorttitle="BolBand, MA & PinBar", title="Bollinger Band with Moving Average & Pin Bars", overlay=true)
//SCANNER FOR PIN BARS
hammer = (math.min(open,close)-low)>= (2*math.abs(open-close)) and close > (((high-low)/2)+low)
shootingStar = (high-math.max(open,close))>= (2*math.abs(open-close)) and close < (((high-low)/2)+low)
//Plot Pins Bars
plotchar(shootingStar, location=location.belowbar, color=color.red, size=size.tiny, char="S")
plotchar(hammer, location=location.abovebar, color=color.green, size=size.tiny, char="H")
//BOLLINGER BAND
BB_len = input.int(20, "BolBand Length", minval=1)
mult = input.float(2.00, minval=0.001, maxval=50, title="BolBand StdDev")
basis = ta.sma(close, BB_len)
dev = mult * ta.stdev(close, BB_len)
upper = basis + dev
lower = basis - dev
//Plot for Bollinger Band
plot(basis, "BolBand Basis", color=#872323)
p1 = plot(upper, "BolBand Upper", color=color.gray)
p2 = plot(lower, "BolBand Lower", color=color.gray)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 90))
//MOVING AVERAGE
MA_len = input.int(8, minval=1, title="MA Length")
MA_src = input(close, title="MA Source")
MA_type = input.string(defval = 'EMA', title = 'MA Type', options = ['SMA','WMA','EMA'])
ma = switch MA_type
'SMA' =>ta.sma(MA_src, MA_len)
'WMA' =>ta.wma(MA_src, MA_len)
'EMA' =>ta.ema(MA_src, MA_len)
//Plot for Moving Average
plot(ma, title= 'Moving Average',color=color.blue, linewidth=2)
//DAILY & WEEKLY LEVELS (high,low & pivot)
Show_d_lines = input.bool(title="Show Daily HiLo Lines?", defval=true)
Day_HiLo_labels = input.bool(title="Daily HiLo Labels?", defval=true)
Day_p_line = input.bool(title="Show Day Pivot Line?", defval=true)
Day_Pivot_label = input.bool(title="Daily Pivot Label?", defval=true)
Show_w_lines = input.bool(title="Show Weekly HiLo Lines?", defval=true)
Week_HiLo_labels = input.bool(title="Weekly HiLo Labels?", defval=true)
Week_p_line = input.bool(title="Show Weekly Pivot Line?", defval=true)
Week_Pivot_label = input.bool(title="Weekly Pivot Label?", defval=true)
//Line and label colors
d_HiLo_col = input.color(color.green, "Daily High/Low level colors", group="Drawings")
w_HiLo_col = input.color(color.yellow, "Weekly High/Low level colors", group="Drawings")
Pivot_col = input.color(color.gray, "Pivot level color", group="Drawings")
//Required calculations
d_high = request.security(syminfo.tickerid, "D", high[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
d_low = request.security(syminfo.tickerid, "D", low[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
d_close = request.security(syminfo.tickerid, "D", close[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
d_pivot = request.security(syminfo.tickerid, "D", hlc3[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
w_high = request.security(syminfo.tickerid, "W", high[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
w_low = request.security(syminfo.tickerid, "W", low[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
w_close = request.security(syminfo.tickerid, "W", close[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
w_pivot = request.security(syminfo.tickerid, "W", hlc3[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//Plots for levels
plot(Show_d_lines ? d_high : na, "Prev Day Hi", color=d_HiLo_col, trackprice=true, style=plot.style_cross, linewidth=1)
plot(Show_d_lines ? d_low : na, "Prev Day Lo", color=d_HiLo_col, trackprice=true, style=plot.style_cross, linewidth=1)
plot(Day_p_line ? d_pivot : na, "Day Pivot Point", color=Pivot_col, trackprice=true, style=plot.style_cross, linewidth=1)
plot(Show_w_lines ? w_high : na, "Prev Week Hi", color=w_HiLo_col, trackprice=true, style=plot.style_cross, linewidth=1)
plot(Show_w_lines ? w_low : na, "Prev Week Lo", color=w_HiLo_col, trackprice=true, style=plot.style_cross, linewidth=1)
plot(Week_p_line ? w_pivot : na, "Week Pivot Point", color=Pivot_col, trackprice=true, style=plot.style_cross, linewidth=1)
//Labels
bar_offset = input.int(title="label offset", defval = -10)
d_HiLabel = Day_HiLo_labels ? label.new(x=bar_index - bar_offset, y=d_high, text="Prev Day Hi", textcolor=d_HiLo_col, style=label.style_none):na
label.delete(d_HiLabel[1])
d_LoLabel = Day_HiLo_labels ? label.new(x=bar_index - bar_offset, y=d_low, text="Prev Day Low", textcolor=d_HiLo_col, style=label.style_none):na
label.delete(d_LoLabel[1])
d_PivotLabel = Day_Pivot_label ? label.new(x=bar_index - bar_offset, y=d_pivot, text="Daily Pivot", textcolor=Pivot_col, style=label.style_none):na
label.delete(d_PivotLabel[1])
w_HiLabel = Week_HiLo_labels ? label.new(x=bar_index - bar_offset, y=w_high, text="Prev Week Hi", textcolor=w_HiLo_col, style=label.style_none):na
label.delete(w_HiLabel[1])
w_LoLabel = Week_HiLo_labels ? label.new(x=bar_index - bar_offset, y=w_low, text="Prev Week Low", textcolor=w_HiLo_col, style=label.style_none):na
label.delete(w_LoLabel[1])
w_PivotLabel = Week_Pivot_label ? label.new(x=bar_index - bar_offset, y=w_pivot, text="Weekly Pivot", textcolor=Pivot_col, style=label.style_none):na
label.delete(w_PivotLabel[1]) |
HTF Liquidity Levels | https://www.tradingview.com/script/PL0iPxy0-HTF-Liquidity-Levels/ | sbtnc | https://www.tradingview.com/u/sbtnc/ | 2,949 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sbtnc
// Created: 2022-04-26
// Last modified: 2023-09-04
// Version 3.0
//@version=5
indicator("HTF Liquidity Levels", "HTF Liquidity", true, max_lines_count=500)
//--------------------------------------------------------------------
//#region Constants
//--------------------------------------------------------------------
int LINE_OFFSET_START = 0
int LINE_OFFSET_END = 25
//#endregion
//--------------------------------------------------------------------
//#region Inputs
//--------------------------------------------------------------------
group1 = "Liquidity Levels"
group2 = "Purged Levels"
purgeTimeframeTooltip = "Clear all the purged levels on a new timeframe rotation."
isEnabledInput1 = input (true, "", inline="Level1", group=group1)
timeframeInput1 = input.timeframe ("M", "", inline="Level1", group=group1)
upperColorInput1 = input (color.rgb(135, 254, 7, 90), "", inline="Level1", group=group1)
lowerColorInput1 = input (color.new(color.orange, 90), "", inline="Level1", group=group1)
widthInput1 = input (10, "Width", inline="Level1", group=group1, display=display.none)
isEnabledInput2 = input (true, "", inline="Level2", group=group1)
timeframeInput2 = input.timeframe ("W", "", inline="Level2", group=group1)
upperColorInput2 = input (color.new(color.lime, 70), "", inline="Level2", group=group1)
lowerColorInput2 = input (color.new(color.red, 70), "", inline="Level2", group=group1)
widthInput2 = input (5, "Width", inline="Level2", group=group1, display=display.none)
isEnabledInput3 = input (true, "", inline="Level3", group=group1)
timeframeInput3 = input.timeframe ("D", "", inline="Level3", group=group1)
upperColorInput3 = input (color.new(color.green, 70), "", inline="Level3", group=group1)
lowerColorInput3 = input (color.rgb(242, 54, 69, 70), "", inline="Level3", group=group1)
widthInput3 = input (2, "Width", inline="Level3", group=group1, display=display.none)
isEnabledInput4 = input (false, "", inline="Level4", group=group1)
timeframeInput4 = input.timeframe ("240", "", inline="Level4", group=group1)
upperColorInput4 = input (color.rgb(0, 151, 167, 70), "", inline="Level4", group=group1)
lowerColorInput4 = input (color.rgb(123, 31, 162, 70), "", inline="Level4", group=group1)
widthInput4 = input (1, "Width", inline="Level4", group=group1, display=display.none)
isEnabledInput5 = input (false, "", inline="Level5", group=group1)
timeframeInput5 = input.timeframe ("60", "", inline="Level5", group=group1)
upperColorInput5 = input (color.rgb(0, 96, 100, 70), "", inline="Level5", group=group1)
lowerColorInput5 = input (color.rgb(74, 20, 140, 70), "", inline="Level5", group=group1)
widthInput5 = input (1, "Width", inline="Level5", group=group1, display=display.none)
purgedColorInput = input (color.new(color.gray, 70), "Color", group=group2)
purgedStyleInput = input.string ("Dashed", "Style", ["Solid", "Dashed", "Dotted"], group=group2, display=display.none)
purgeTimeframeInput = input.timeframe ("D", "Removal", tooltip=purgeTimeframeTooltip, group=group2, display=display.none)
//#endregion
//--------------------------------------------------------------------
//#region Types
//--------------------------------------------------------------------
type Level
float price
line line
//#endregion
//--------------------------------------------------------------------
//#region Variables declarations
//--------------------------------------------------------------------
var highsArray = array.new<Level>()
var lowsArray = array.new<Level>()
var purgedArray = array.new<Level>()
[prevHigh1, prevLow1] = request.security(syminfo.tickerid, timeframeInput1, [high[1], low[1]], lookahead=barmerge.lookahead_on)
[prevHigh2, prevLow2] = request.security(syminfo.tickerid, timeframeInput2, [high[1], low[1]], lookahead=barmerge.lookahead_on)
[prevHigh3, prevLow3] = request.security(syminfo.tickerid, timeframeInput3, [high[1], low[1]], lookahead=barmerge.lookahead_on)
[prevHigh4, prevLow4] = request.security(syminfo.tickerid, timeframeInput4, [high[1], low[1]], lookahead=barmerge.lookahead_on)
[prevHigh5, prevLow5] = request.security(syminfo.tickerid, timeframeInput5, [high[1], low[1]], lookahead=barmerge.lookahead_on)
//#endregion
//--------------------------------------------------------------------
//#region Functions & methods
//--------------------------------------------------------------------
// @function Check if a given timeframe is equal or higher than the chart's timeframe
// @returns bool
f_isHigherTimeframe(string timeframe) => timeframe.in_seconds(timeframe) >= timeframe.in_seconds()
// @function Produce the line style argument for the `style` parameter from the input settings
// @returns (const string) `line.style_*` built-in constants
f_getLineStyle() =>
switch purgedStyleInput
"Solid" => line.style_solid
"Dotted" => line.style_dotted
"Dashed" => line.style_dashed
// @function Draw a liquidity level
// @returns (line) A new `line` object
f_drawLine(float y, color color, int width) => line.new(bar_index, y, bar_index, y, color=color, width=width)
// @function Create and store new upper and lower liquidity levels
// @returns void
f_createLevels(float h, float l, color upperColor, color lowerColor, int width) =>
highsArray.push(Level.new(h, f_drawLine(h, upperColor, width)))
lowsArray.push(Level.new(l, f_drawLine(l, lowerColor, width)))
// @function Update the levels' starting and ending positions
// @returns void
method updatePosition(array<Level> this) =>
_x1 = bar_index + LINE_OFFSET_START
_x2 = bar_index + LINE_OFFSET_END
for _level in this
_level.line.set_x1(_x1)
_level.line.set_x2(_x2)
// @function Transfer a level from an array to another
// @returns void
method transferTo(array<Level> this, array<Level> dest, int index) =>
dest.push(this.remove(index))
// @function Highlight a level that has its liquidity "purged"
// @returns void
method highlightPurgedLevel(line this) =>
var _style = f_getLineStyle()
this.set_color(purgedColorInput)
this.set_style(_style)
// @function Update the levels that got their liquidity "purged"
// @returns (bool) If at least one level was purged
method updateLevels(array<Level> this, array<Level> purgedArray, bool isUpperLevel) =>
_hasPurgedSome = false
_size = this.size()
if _size > 0
for i = _size -1 to 0
_level = this.get(i)
if isUpperLevel ? (high > _level.price) : (low < _level.price)
_level.line.highlightPurgedLevel()
this.transferTo(purgedArray, i)
_hasPurgedSome := true
_hasPurgedSome
// @function Remove the levels in the array and delete their lines
// @returns void
method clearLevels(array<Level> this) =>
_size = this.size()
if _size > 0
for i = _size -1 to 0
_level = this.remove(i)
_level.line.delete()
//#endregion
//--------------------------------------------------------------------
//#region Plotting & styling
//--------------------------------------------------------------------
// Create levels on historical bars
if isEnabledInput5 and f_isHigherTimeframe(timeframeInput5) and timeframe.change(timeframeInput5)
f_createLevels(prevHigh5, prevLow5, upperColorInput5, lowerColorInput5, widthInput5)
if isEnabledInput4 and f_isHigherTimeframe(timeframeInput4) and timeframe.change(timeframeInput4)
f_createLevels(prevHigh4, prevLow4, upperColorInput4, lowerColorInput4, widthInput4)
if isEnabledInput3 and f_isHigherTimeframe(timeframeInput3) and timeframe.change(timeframeInput3)
f_createLevels(prevHigh3, prevLow3, upperColorInput3, lowerColorInput3, widthInput3)
if isEnabledInput2 and f_isHigherTimeframe(timeframeInput2) and timeframe.change(timeframeInput2)
f_createLevels(prevHigh2, prevLow2, upperColorInput2, lowerColorInput2, widthInput2)
if isEnabledInput1 and f_isHigherTimeframe(timeframeInput1) and timeframe.change(timeframeInput1)
f_createLevels(prevHigh1, prevLow1, upperColorInput1, lowerColorInput1, widthInput1)
// Update the level positions to "float" at the right of the chart's last bar
if barstate.islast
highsArray.updatePosition()
lowsArray.updatePosition()
purgedArray.updatePosition()
// Update the levels that got their liquidity taken
hasPurgedSomeHighs = highsArray.updateLevels(purgedArray, true)
hasPurgedSomeLows = lowsArray.updateLevels(purgedArray, false)
// Clean up on a new resolution, the levels that had their liquidity taken
if timeframe.change(purgeTimeframeInput)
purgedArray.clearLevels()
//#endregion
//--------------------------------------------------------------------
//#region Alerts
//--------------------------------------------------------------------
alertcondition(hasPurgedSomeHighs, "Purging Up", "{{ticker}} Purging Up Liquidity")
alertcondition(hasPurgedSomeLows, "Purging Down", "{{ticker}} Purging Down Liquidity")
alertcondition(hasPurgedSomeHighs or hasPurgedSomeLows, "Purging", "{{ticker}} Purging Liquidity")
//#endregion |
Custom Moving Averages | https://www.tradingview.com/script/Y7XujtlB-Custom-Moving-Averages/ | gliderfund | https://www.tradingview.com/u/gliderfund/ | 73 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gliderfund
//@version=5
indicator(title = "Custom Moving Averages", shorttitle = "MA Custom", overlay = true)
// #############################################
// #############################################
// VERSION
// #############################################
// #############################################
// This is a useful indicator which allows you to plot multiple fully customized Moving Averages. Here are some of its features:
// [list]
// [*]Ability to fine-tune a wide variety of moving averages: smoothing type, periods, offsets, timeframes, sources, thickness, line/label color and text color.
// [*]Descriptive labels to avoid misreading.
// [*]Simple and well-organized Input Tab.
// [/list]
// ---------------------------------------------
// [list]
// [*]Ability to plot up to 7 Moving Averages
// [*]Offset can be positive or negative
// [/list]
// #############################################
// #############################################
// LIBRARIES
// #############################################
// #############################################
import gliderfund/StapleIndicators/1 as com
// #############################################
// #############################################
// INPUTS
// #############################################
// #############################################
// Custom MA #1
customMa1 = input.bool(defval = true, title = "MA #1:", group="Custom MA #1", inline = "custom1top")
customMode1 = input.string(defval = "Ema", title = "", options=["Sma", "Ema", "Dema", "Tema", "Wma", "Vwma", "Hma", "Lsma", "Rma", "Alma", "Tma", "Swma", "Dwma", "Smma", "Mav", "Zlema", "Azlema", "Jma", "Ssma", "All-Time"], tooltip = "", group = "Custom MA #1", inline = "custom1top")
inputTF1 = input.timeframe(defval = "", title = "TF", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Custom MA #1", inline = "custom1top")
chartTF1 = inputTF1 == ""
period1 = input.int(defval = 21, title = "Period", minval = 2, step = 1, group = "Custom MA #1", inline = "custom1mid")
offset1 = input.int(defval = 0, title = "Offset", step = 1, group = "Custom MA #1", inline = "custom1mid")
src1 = input.source(defval = close, title = "Source", group = "Custom MA #1", inline = "custom1mid")
thickLine1 = input.int(defval = 2, title = "Line: Thickness", minval = 1, step = 1, group = "Custom MA #1", inline = "custom1bottom")
colorMa1 = input.color(defval = #800080, title = "Color", tooltip = "", group = "Custom MA #1", inline = "custom1bottom")
colorText1 = input.color(defval = #FFFFFF, title = "Text", tooltip = "", group = "Custom MA #1", inline = "custom1bottom")
// Custom MA #2
customMa2 = input.bool(defval = true, title = "MA #2:", group="Custom MA #2", inline = "custom2top")
customMode2 = input.string(defval = "Sma", title = "", options=["Sma", "Ema", "Dema", "Tema", "Wma", "Vwma", "Hma", "Lsma", "Rma", "Alma", "Tma", "Swma", "Dwma", "Smma", "Mav", "Zlema", "Azlema", "Jma", "Ssma", "All-Time"], tooltip = "", group = "Custom MA #2", inline = "custom2top")
inputTF2 = input.timeframe(defval = "", title = "TF", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Custom MA #2", inline = "custom2top")
chartTF2 = inputTF2 == ""
period2 = input.int(defval = 50, title = "Period", minval = 2, step = 1, group = "Custom MA #2", inline = "custom2mid")
offset2 = input.int(defval = 0, title = "Offset", step = 1, group = "Custom MA #2", inline = "custom2mid")
src2 = input.source(defval = close, title = "Source", group = "Custom MA #2", inline = "custom2mid")
thickLine2 = input.int(defval = 2, title = "Line: Thickness", minval = 1, step = 1, group = "Custom MA #2", inline = "custom2bottom")
colorMa2 = input.color(defval = #008080, title = "Color", tooltip = "", group = "Custom MA #2", inline = "custom2bottom")
colorText2 = input.color(defval = #FFFFFF, title = "Text", tooltip = "", group = "Custom MA #2", inline = "custom2bottom")
// Custom MA #3
customMa3 = input.bool(defval = true, title = "MA #3:", group="Custom MA #3", inline = "custom3top")
customMode3 = input.string(defval = "Sma", title = "", options=["Sma", "Ema", "Dema", "Tema", "Wma", "Vwma", "Hma", "Lsma", "Rma", "Alma", "Tma", "Swma", "Dwma", "Smma", "Mav", "Zlema", "Azlema", "Jma", "Ssma", "All-Time"], tooltip = "", group = "Custom MA #3", inline = "custom3top")
inputTF3 = input.timeframe(defval = "", title = "TF", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Custom MA #3", inline = "custom3top")
chartTF3 = inputTF3 == ""
period3 = input.int(defval = 200, title = "Period", minval = 2, step = 1, group = "Custom MA #3", inline = "custom3mid")
offset3 = input.int(defval = 0, title = "Offset", step = 1, group = "Custom MA #3", inline = "custom3mid")
src3 = input.source(defval = close, title = "Source", group = "Custom MA #3", inline = "custom3mid")
thickLine3 = input.int(defval = 2, title = "Line: Thickness", minval = 1, step = 1, group = "Custom MA #3", inline = "custom3bottom")
colorMa3 = input.color(defval = #858500, title = "Color", tooltip = "", group = "Custom MA #3", inline = "custom3bottom")
colorText3 = input.color(defval = #FFFFFF, title = "Text", tooltip = "", group = "Custom MA #3", inline = "custom3bottom")
// Custom MA #4
customMa4 = input.bool(defval = false, title = "MA #4:", group="Custom MA #4", inline = "custom4top")
customMode4 = input.string(defval = "Sma", title = "", options=["Sma", "Ema", "Dema", "Tema", "Wma", "Vwma", "Hma", "Lsma", "Rma", "Alma", "Tma", "Swma", "Dwma", "Smma", "Mav", "Zlema", "Azlema", "Jma", "Ssma", "All-Time"], tooltip = "", group = "Custom MA #4", inline = "custom4top")
inputTF4 = input.timeframe(defval = "", title = "TF", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Custom MA #4", inline = "custom4top")
chartTF4 = inputTF4 == ""
period4 = input.int(defval = 100, title = "Period", minval = 2, step = 1, group = "Custom MA #4", inline = "custom4mid")
offset4 = input.int(defval = 0, title = "Offset", step = 1, group = "Custom MA #4", inline = "custom4mid")
src4 = input.source(defval = close, title = "Source", group = "Custom MA #4", inline = "custom4mid")
thickLine4 = input.int(defval = 2, title = "Line: Thickness", minval = 1, step = 1, group = "Custom MA #4", inline = "custom4bottom")
colorMa4 = input.color(defval = #FF8000, title = "Color", tooltip = "", group = "Custom MA #4", inline = "custom4bottom")
colorText4 = input.color(defval = #FFFFFF, title = "Text", tooltip = "", group = "Custom MA #4", inline = "custom4bottom")
// Custom MA #5
customMa5 = input.bool(defval = false, title = "MA #5:", group="Custom MA #5", inline = "custom5top")
customMode5 = input.string(defval = "All-Time", title = "", options=["Sma", "Ema", "Dema", "Tema", "Wma", "Vwma", "Hma", "Lsma", "Rma", "Alma", "Tma", "Swma", "Dwma", "Smma", "Mav", "Zlema", "Azlema", "Jma", "Ssma", "All-Time"], tooltip = "", group = "Custom MA #5", inline = "custom5top")
inputTF5 = input.timeframe(defval = "", title = "TF", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Custom MA #5", inline = "custom5top")
chartTF5 = inputTF5 == ""
period5 = input.int(defval = 100, title = "Period", minval = 2, step = 1, group = "Custom MA #5", inline = "custom5mid")
offset5 = input.int(defval = 0, title = "Offset", step = 1, group = "Custom MA #5", inline = "custom5mid")
src5 = input.source(defval = close, title = "Source", group = "Custom MA #5", inline = "custom5mid")
thickLine5 = input.int(defval = 2, title = "Line: Thickness", minval = 1, step = 1, group = "Custom MA #5", inline = "custom5bottom")
colorMa5 = input.color(defval = #008000, title = "Color", tooltip = "", group = "Custom MA #5", inline = "custom5bottom")
colorText5 = input.color(defval = #FFFFFF, title = "Text", tooltip = "", group = "Custom MA #5", inline = "custom5bottom")
// Custom MA #6
customMa6 = input.bool(defval = false, title = "MA #6:", group="Custom MA #6", inline = "custom6top")
customMode6 = input.string(defval = "Wma", title = "", options=["Sma", "Ema", "Dema", "Tema", "Wma", "Vwma", "Hma", "Lsma", "Rma", "Alma", "Tma", "Swma", "Dwma", "Smma", "Mav", "Zlema", "Azlema", "Jma", "Ssma", "All-Time"], tooltip = "", group = "Custom MA #6", inline = "custom6top")
inputTF6 = input.timeframe(defval = "", title = "TF", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Custom MA #6", inline = "custom6top")
chartTF6 = inputTF6 == ""
period6 = input.int(defval = 5, title = "Period", minval = 2, step = 1, group = "Custom MA #6", inline = "custom6mid")
offset6 = input.int(defval = 0, title = "Offset", step = 1, group = "Custom MA #6", inline = "custom6mid")
src6 = input.source(defval = close, title = "Source", group = "Custom MA #6", inline = "custom6mid")
thickLine6 = input.int(defval = 2, title = "Line: Thickness", minval = 1, step = 1, group = "Custom MA #6", inline = "custom6bottom")
colorMa6 = input.color(defval = #FF00FF, title = "Color", tooltip = "", group = "Custom MA #6", inline = "custom6bottom")
colorText6 = input.color(defval = #FFFFFF, title = "Text", tooltip = "", group = "Custom MA #6", inline = "custom6bottom")
// Custom MA #7
customMa7 = input.bool(defval = false, title = "MA #7:", group="Custom MA #7", inline = "custom7top")
customMode7 = input.string(defval = "Zlema", title = "", options=["Sma", "Ema", "Dema", "Tema", "Wma", "Vwma", "Hma", "Lsma", "Rma", "Alma", "Tma", "Swma", "Dwma", "Smma", "Mav", "Zlema", "Azlema", "Jma", "Ssma", "All-Time"], tooltip = "", group = "Custom MA #7", inline = "custom7top")
inputTF7 = input.timeframe(defval = "", title = "TF", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Custom MA #7", inline = "custom7top")
chartTF7 = inputTF7 == ""
period7 = input.int(defval = 9, title = "Period", minval = 2, step = 1, group = "Custom MA #7", inline = "custom7mid")
offset7 = input.int(defval = 0, title = "Offset", step = 1, group = "Custom MA #7", inline = "custom7mid")
src7 = input.source(defval = close, title = "Source", group = "Custom MA #7", inline = "custom7mid")
thickLine7 = input.int(defval = 2, title = "Line: Thickness", minval = 1, step = 1, group = "Custom MA #7", inline = "custom7bottom")
colorMa7 = input.color(defval = #0000FF, title = "Color", tooltip = "", group = "Custom MA #7", inline = "custom7bottom")
colorText7 = input.color(defval = #FFFFFF, title = "Text", tooltip = "", group = "Custom MA #7", inline = "custom7bottom")
// Labels
showLabel = input.bool(defval = true, title = "Show Labels", tooltip = "Displays a Label to identify the lines", group = "Labels")
// MA Parameters
// Linear Regression
lrOffset = input.int(defval = 0, title = "Linear Regression: Offset", minval = 0, step = 1, group = "Parameters", inline = "parametersLR")
// Alma
almaOffset = input.float(defval = 0.85, title = "Alma: Offset", minval = 0, step = 1, group = "Parameters", inline = "parametersAlma")
almaSigma = input.int(defval = 6, title = "Sigma", minval = 0, step = 1, group = "Parameters", inline = "parametersAlma")
// Jma
jmaPhase = input.float(defval = 50, title = "Jma: Phase", minval = 0, step = 1, group = "Parameters", inline = "parametersJma")
// Azlema
azlemaMode = input.string(defval = "Cosine", title = "Azlema: Adaptative Mode", tooltip = "", options=["In-Phase & Quadrature", "Cosine", "Average"], group = "Parameters", inline = "parametersAzlema")
// #############################################
// #############################################
// CALCULATION
// #############################################
// #############################################
ma1 = com.maCustom(customMode1, src1, period1, lrOffset, almaOffset, almaSigma, jmaPhase, azlemaMode)
ma2 = com.maCustom(customMode2, src2, period2, lrOffset, almaOffset, almaSigma, jmaPhase, azlemaMode)
ma3 = com.maCustom(customMode3, src3, period3, lrOffset, almaOffset, almaSigma, jmaPhase, azlemaMode)
ma4 = com.maCustom(customMode4, src4, period4, lrOffset, almaOffset, almaSigma, jmaPhase, azlemaMode)
ma5 = com.maCustom(customMode5, src5, period5, lrOffset, almaOffset, almaSigma, jmaPhase, azlemaMode)
ma6 = com.maCustom(customMode6, src6, period6, lrOffset, almaOffset, almaSigma, jmaPhase, azlemaMode)
ma7 = com.maCustom(customMode7, src7, period7, lrOffset, almaOffset, almaSigma, jmaPhase, azlemaMode)
maTF1 = request.security(syminfo.tickerid, inputTF1, ma1)
maTF2 = request.security(syminfo.tickerid, inputTF2, ma2)
maTF3 = request.security(syminfo.tickerid, inputTF3, ma3)
maTF4 = request.security(syminfo.tickerid, inputTF4, ma4)
maTF5 = request.security(syminfo.tickerid, inputTF5, ma5)
maTF6 = request.security(syminfo.tickerid, inputTF6, ma6)
maTF7 = request.security(syminfo.tickerid, inputTF7, ma7)
// #############################################
// #############################################
// PLOT
// #############################################
// #############################################
// Custom MAs
plot(series = customMa1 ? maTF1 : na, title = "Custom MA #1", color = colorMa1, linewidth = thickLine1, style = plot.style_line, offset = offset1, editable = true)
plot(series = customMa2 ? maTF2 : na, title = "Custom MA #2", color = colorMa2, linewidth = thickLine2, style = plot.style_line, offset = offset2, editable = true)
plot(series = customMa3 ? maTF3 : na, title = "Custom MA #3", color = colorMa3, linewidth = thickLine3, style = plot.style_line, offset = offset3, editable = true)
plot(series = customMa4 ? maTF4 : na, title = "Custom MA #4", color = colorMa4, linewidth = thickLine4, style = plot.style_line, offset = offset4, editable = true)
plot(series = customMa5 ? maTF5 : na, title = "Custom MA #5", color = colorMa5, linewidth = thickLine5, style = plot.style_line, offset = offset5, editable = true)
plot(series = customMa6 ? maTF6 : na, title = "Custom MA #6", color = colorMa6, linewidth = thickLine6, style = plot.style_line, offset = offset6, editable = true)
plot(series = customMa7 ? maTF7 : na, title = "Custom MA #7", color = colorMa7, linewidth = thickLine7, style = plot.style_line, offset = offset7, editable = true)
// Label Vars
var label label1 = na
offsetText1 = offset1 == 0 ? "" : "x" + str.tostring(offset1)
textLabel1 = chartTF1 ? customMode1 + "-" + str.tostring(period1) + offsetText1 : customMode1 + "-" + str.tostring(period1) + offsetText1 + " (" + inputTF1 + ")"
seriesLabel1 = barstate.islast ? maTF1 : na
offsetLabel1 = offset1 + 1
colorLabel1 = colorMa1
colorTextLabel1 = colorText1
conditionLabel1 = showLabel and customMa1 and barstate.islast
if conditionLabel1
label.delete(label1)
label1 := label.new(x = bar_index + offsetLabel1, y = seriesLabel1, text = textLabel1, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel1, style = label.style_label_left, textcolor = colorTextLabel1, size = size.normal, textalign = text.align_center)
var label label2 = na
offsetText2 = offset2 == 0 ? "" : "x" + str.tostring(offset2)
textLabel2 = chartTF2 ? customMode2 + "-" + str.tostring(period2) + offsetText2 : customMode2 + "-" + str.tostring(period2) + offsetText2 + " (" + inputTF2 + ")"
seriesLabel2 = barstate.islast ? maTF2 : na
offsetLabel2 = offset2 + 1
colorLabel2 = colorMa2
colorTextLabel2 = colorText2
conditionLabel2 = showLabel and customMa2 and barstate.islast
if conditionLabel2
label.delete(label2)
label2 := label.new(x = bar_index + offsetLabel2, y = seriesLabel2, text = textLabel2, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel2, style = label.style_label_left, textcolor = colorTextLabel2, size = size.normal, textalign = text.align_center)
var label label3 = na
offsetText3 = offset3 == 0 ? "" : "x" + str.tostring(offset3)
textLabel3 = chartTF3 ? customMode3 + "-" + str.tostring(period3) + offsetText3 : customMode3 + "-" + str.tostring(period3) + offsetText3 + " (" + inputTF3 + ")"
seriesLabel3 = barstate.islast ? maTF3 : na
offsetLabel3 = offset3 + 1
colorLabel3 = colorMa3
colorTextLabel3 = colorText3
conditionLabel3 = showLabel and customMa3 and barstate.islast
if conditionLabel3
label.delete(label3)
label3 := label.new(x = bar_index + offsetLabel3, y = seriesLabel3, text = textLabel3, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel3, style = label.style_label_left, textcolor = colorTextLabel3, size = size.normal, textalign = text.align_center)
var label label4 = na
offsetText4 = offset4 == 0 ? "" : "x" + str.tostring(offset4)
textLabel4 = chartTF4 ? customMode4 + "-" + str.tostring(period4) + offsetText4 : customMode4 + "-" + str.tostring(period4) + offsetText4 + " (" + inputTF4 + ")"
seriesLabel4 = barstate.islast ? maTF4 : na
offsetLabel4 = offset4 + 1
colorLabel4 = colorMa4
colorTextLabel4 = colorText4
conditionLabel4 = showLabel and customMa4 and barstate.islast
if conditionLabel4
label.delete(label4)
label4 := label.new(x = bar_index + offsetLabel4, y = seriesLabel4, text = textLabel4, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel4, style = label.style_label_left, textcolor = colorTextLabel4, size = size.normal, textalign = text.align_center)
var label label5 = na
offsetText5 = offset5 == 0 ? "" : "x" + str.tostring(offset5)
textLabel5 = chartTF5 ? customMode5 + "-" + str.tostring(period5) + offsetText5 : customMode5 + "-" + str.tostring(period5) + offsetText5 + " (" + inputTF5 + ")"
seriesLabel5 = barstate.islast ? maTF5 : na
offsetLabel5 = offset5 + 1
colorLabel5 = colorMa5
colorTextLabel5 = colorText5
conditionLabel5 = showLabel and customMa5 and barstate.islast
if conditionLabel5
label.delete(label5)
label5 := label.new(x = bar_index + offsetLabel5, y = seriesLabel5, text = textLabel5, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel5, style = label.style_label_left, textcolor = colorTextLabel5, size = size.normal, textalign = text.align_center)
var label label6 = na
offsetText6 = offset6 == 0 ? "" : "x" + str.tostring(offset6)
textLabel6 = chartTF6 ? customMode6 + "-" + str.tostring(period6) + offsetText6 : customMode6 + "-" + str.tostring(period6) + offsetText6 + " (" + inputTF6 + ")"
seriesLabel6 = barstate.islast ? maTF6 : na
offsetLabel6 = offset6 + 1
colorLabel6 = colorMa6
colorTextLabel6 = colorText6
conditionLabel6 = showLabel and customMa6 and barstate.islast
if conditionLabel6
label.delete(label6)
label6 := label.new(x = bar_index + offsetLabel6, y = seriesLabel6, text = textLabel6, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel6, style = label.style_label_left, textcolor = colorTextLabel6, size = size.normal, textalign = text.align_center)
var label label7 = na
offsetText7 = offset7 == 0 ? "" : "x" + str.tostring(offset7)
textLabel7 = chartTF7 ? customMode7 + "-" + str.tostring(period7) + offsetText7 : customMode7 + "-" + str.tostring(period7) + offsetText7 + " (" + inputTF7 + ")"
seriesLabel7 = barstate.islast ? maTF7 : na
offsetLabel7 = offset7 + 1
colorLabel7 = colorMa7
colorTextLabel7 = colorText7
conditionLabel7 = showLabel and customMa7 and barstate.islast
if conditionLabel7
label.delete(label7)
label7 := label.new(x = bar_index + offsetLabel7, y = seriesLabel7, text = textLabel7, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel7, style = label.style_label_left, textcolor = colorTextLabel7, size = size.normal, textalign = text.align_center)
|
Staple MAs | https://www.tradingview.com/script/qVwZ0EIn-Staple-MAs/ | gliderfund | https://www.tradingview.com/u/gliderfund/ | 21 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gliderfund
//@version=5
indicator(title = "Staple MAs", shorttitle = "MAs", overlay = true)
// #############################################
// #############################################
// VERSION
// #############################################
// #############################################
// This is a useful indicator which allows you to plot multiple common predefined Moving Averages (Ema and Sma). Here are some of its features:
// [list]
// [*]Ability to quickly display many common EMAs and SMAs.
// [*]Multiple timeframes.
// [*]Descriptive labels to avoid misreading.
// [*]Simple and well-organized Input Tab.
// [/list]
// #############################################
// #############################################
// LIBRARIES
// #############################################
// #############################################
import gliderfund/StapleIndicators/1 as com
// #############################################
// #############################################
// INPUTS
// #############################################
// #############################################
// GROUP: EMA VIEW
showEma3 = input.bool(defval = false, title = "Ema(3)", group="EMA", inline = "ema1")
showEma5 = input.bool(defval = false, title = "Ema(5)", group="EMA", inline = "ema1")
showEma8 = input.bool(defval = false, title = "Ema(8)", group="EMA", inline = "ema1")
showEma9 = input.bool(defval = false, title = "Ema(9)", group="EMA", inline = "ema1")
showEma13 = input.bool(defval = false, title = "Ema(13)", group="EMA", inline = "ema2")
showEma18 = input.bool(defval = false, title = "Ema(18)", group="EMA", inline = "ema2")
showEma21 = input.bool(defval = true, title = "Ema(21)", group="EMA", inline = "ema2")
showEma34 = input.bool(defval = false, title = "Ema(34)", group="EMA", inline = "ema2")
showEma50 = input.bool(defval = false, title = "Ema(50)", group="EMA", inline = "ema3")
showEma55 = input.bool(defval = false, title = "Ema(55)", group="EMA", inline = "ema3")
showEma89 = input.bool(defval = false, title = "Ema(89)", group="EMA", inline = "ema3")
showEma100 = input.bool(defval = false, title = "Ema(100)", group="EMA", inline = "ema4")
showEma144 = input.bool(defval = false, title = "Ema(144)", group="EMA", inline = "ema4")
showEma200 = input.bool(defval = false, title = "Ema(200)", group="EMA", inline = "ema4")
showEma377 = input.bool(defval = false, title = "Ema(377)", group="EMA", inline = "ema4")
// GROUP: SMA VIEW
showSma3 = input.bool(defval = false, title = "Sma(3)", group="SMA", inline = "sma1")
showSma5 = input.bool(defval = false, title = "Sma(5)", group="SMA", inline = "sma1")
showSma6 = input.bool(defval = false, title = "Sma(6)", group="SMA", inline = "sma1")
showSma7 = input.bool(defval = false, title = "Sma(7)", group="SMA", inline = "sma1")
showSma8 = input.bool(defval = false, title = "Sma(8)", group="SMA", inline = "sma1")
showSma10 = input.bool(defval = false, title = "Sma(10)", group="SMA", inline = "sma2")
showSma20 = input.bool(defval = false, title = "Sma(20)", group="SMA", inline = "sma2")
showSma25 = input.bool(defval = false, title = "Sma(25)", group="SMA", inline = "sma2")
showSma30 = input.bool(defval = false, title = "Sma(30)", group="SMA", inline = "sma2")
showSma50 = input.bool(defval = false, title = "Sma(50)", group="SMA", inline = "sma2")
showSma100 = input.bool(defval = true, title = "Sma(100)", group="SMA", inline = "sma3")
showSma200 = input.bool(defval = true, title = "Sma(200)", group="SMA", inline = "sma3")
showSmaAllTime = input.bool(defval = false, title = "Sma(All-Time)", group="SMA", inline = "sma3")
// GROUP: GENERAL PARAMETERS
srcMa = input.source(defval = close, title = "Source", group = "General Parameters", inline = "param1")
// Offsets
offsetLine = input.int(defval = 0, title = "Offset", minval = 0, step = 1, group = "General Parameters", inline = "param1")
// Line
thickLine = input.int(defval = 2, title = "Thickness", minval = 1, step = 1, group = "General Parameters", inline = "param1")
// Label
showLabel = input.bool(defval = true, title = "Labels", tooltip = "Displays a Label identifying the line being displayed", group = "General Parameters", inline = "param2")
// GROUP: TIME FRAME
customTF1 = input.bool(defval = false, title = "#1", group="Timeframe", inline = "tf1")
inputTF1 = input.timeframe(defval = "", title = "", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Timeframe", inline = "tf1")
chartTF1 = inputTF1 == ""
maSelectTF1 = input.string(defval = "Ema-21", title = "", options=["None", "Sma-3", "Ema-3", "Sma-5", "Ema-5", "Sma-6", "Sma-7", "Sma-8", "Ema-8", "Ema-9", "Sma-10", "Ema-13", "Ema-18", "Sma-20", "Ema-21", "Sma-30", "Ema-34", "Sma-50", "Ema-50", "Ema-55", "Ema-89", "Sma-100", "Ema-100", "Ema-144", "Sma-200", "Ema-200", "Ema-377"], tooltip = "Select the MA to be displayed from a Higher Timeframe. Using this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.", group = "Timeframe", inline = "tf1")
offset1 = input.int(defval = 0, title = "Offset:", minval = 0, step = 1, group = "Timeframe", inline = "tf1")
customTF2 = input.bool(defval = false, title = "#2", group="Timeframe", inline = "tf2")
inputTF2 = input.timeframe(defval = "", title = "", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Timeframe", inline = "tf2")
chartTF2 = inputTF2 == ""
maSelectTF2 = input.string(defval = "Sma-100", title = "", options=["None", "Sma-3", "Ema-3", "Sma-5", "Ema-5", "Sma-6", "Sma-7", "Sma-8", "Ema-8", "Ema-9", "Sma-10", "Ema-13", "Ema-18", "Sma-20", "Ema-21", "Sma-30", "Ema-34", "Sma-50", "Ema-50", "Ema-55", "Ema-89", "Sma-100", "Ema-100", "Ema-144", "Sma-200", "Ema-200", "Ema-377"], tooltip = "Select the MA to be displayed from a Higher Timeframe. Using this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.", group = "Timeframe", inline = "tf2")
offset2 = input.int(defval = 0, title = "Offset:", minval = 0, step = 1, group = "Timeframe", inline = "tf2")
customTF3 = input.bool(defval = false, title = "#3", group="Timeframe", inline = "tf3")
inputTF3 = input.timeframe(defval = "", title = "", tooltip = "You're able to plot the MAs from a Higher Timeframe. With this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.\n\nPlease select 'Chart' to return back to the current selected timeframe at Tradingview toolbar.", group = "Timeframe", inline = "tf3")
chartTF3 = inputTF3 == ""
maSelectTF3 = input.string(defval = "Sma-200", title = "", options=["None", "Sma-3", "Ema-3", "Sma-5", "Ema-5", "Sma-6", "Sma-7", "Sma-8", "Ema-8", "Ema-9", "Sma-10", "Ema-13", "Ema-18", "Sma-20", "Ema-21", "Sma-30", "Ema-34", "Sma-50", "Ema-50", "Ema-55", "Ema-89", "Sma-100", "Ema-100", "Ema-144", "Sma-200", "Ema-200", "Ema-377"], tooltip = "Select the MA to be displayed from a Higher Timeframe. Using this feature, you could for instance draw the Daily SMA-100 on a 4-hour chart.\n\nBeware that you must select a higher timeframe than the current one in the chart. Plotting the MAs from lower timeframes could induce some calculation errors.", group = "Timeframe", inline = "tf3")
offset3 = input.int(defval = 0, title = "Offset:", minval = 0, step = 1, group = "Timeframe", inline = "tf3")
// GROUP: THEMING
// Lines
transpLine = 0
transpLabel = 0
// #############################################
// #############################################
// CALCULATION
// #############################################
// #############################################
// MAs
[ema3, ema5, ema8, ema9, ema13, ema18, ema21, ema34, ema50, ema55, ema89, ema100, ema144, ema200, ema377] = com.emaPreset(srcMa)
[sma3, sma5, sma6, sma7, sma8, sma10, sma20, sma25, sma30, sma50, sma100, sma200, smaAllTime] = com.smaPreset(srcMa)
// Multi timeframe
maTF1 = request.security(syminfo.tickerid, inputTF1, com.maSelect(maSelectTF1, srcMa))
maTF2 = request.security(syminfo.tickerid, inputTF2, com.maSelect(maSelectTF2, srcMa))
maTF3 = request.security(syminfo.tickerid, inputTF3, com.maSelect(maSelectTF3, srcMa))
// #############################################
// #############################################
// THEMING
// #############################################
// #############################################
// EMA
colorEma3 = color.new(#FFC04D, transpLine)
colorEma5 = color.new(#FFB733, transpLine)
colorEma8 = color.new(#FFAE1A, transpLine)
colorEma9 = color.new(#FFA500, transpLine)
colorEma13 = color.new(#E6CCE6, transpLine)
colorEma18 = color.new(#CC99CC, transpLine)
colorEma21 = color.new(#CC99CC, transpLine)
colorEma34 = color.new(#C080C0, transpLine)
colorEma50 = color.new(#B366B3, transpLine)
colorEma55 = color.new(#A64DA6, transpLine)
colorEma89 = color.new(#993399, transpLine)
colorEma100 = color.new(#99CCCC, transpLine)
colorEma144 = color.new(#80C0C0, transpLine)
colorEma200 = color.new(#66B3B3, transpLine)
colorEma377 = color.new(#339999, transpLine)
// SMA
colorSma3 = color.new(#FFC966, transpLine)
colorSma5 = color.new(#FFC04D, transpLine)
colorSma6 = color.new(#FFB733, transpLine)
colorSma7 = color.new(#FFAE1A, transpLine)
colorSma8 = color.new(#FFA500, transpLine)
colorSma10 = color.new(#E6CCE6, transpLine)
colorSma20 = color.new(#D9B3D9, transpLine)
colorSma25 = color.new(#CC99CC, transpLine)
colorSma30 = color.new(#C080C0, transpLine)
colorSma50 = color.new(#B366B3, transpLine)
colorSma100 = color.new(#99CCCC, transpLine)
colorSma200 = color.new(#66B3B3, transpLine)
colorSmaAllTime = color.new(#339999, transpLine)
// Custom Timeframe
colorTF1 = color.new(#99CC99, transpLine)
colorTF2 = color.new(#80C080, transpLine)
colorTF3 = color.new(#66B366, transpLine)
// Text
colorTextLabel = color.new(#404040, transpLabel)
// #############################################
// #############################################
// PLOT
// #############################################
// #############################################
// EMA
plot(series = showEma3 ? ema3 : na, title = "Ema-3", color = colorEma3, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma5 ? ema5 : na, title = "Ema-5", color = colorEma5, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma8 ? ema8 : na, title = "Ema-8", color = colorEma8, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma9 ? ema9 : na, title = "Ema-9", color = colorEma9, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma13 ? ema13 : na, title = "Ema-13", color = colorEma13, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma18 ? ema18 : na, title = "Ema-18", color = colorEma18, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma21 ? ema21 : na, title = "Ema-21", color = colorEma21, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma34 ? ema34 : na, title = "Ema-34", color = colorEma34, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma50 ? ema50 : na, title = "Ema-50", color = colorEma50, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma55 ? ema55 : na, title = "Ema-55", color = colorEma55, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma89 ? ema89 : na, title = "Ema-89", color = colorEma89, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma100 ? ema100 : na, title = "Ema-100", color = colorEma100, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma144 ? ema144 : na, title = "Ema-144", color = colorEma144, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma200 ? ema200 : na, title = "Ema-200", color = colorEma200, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showEma377 ? ema377 : na, title = "Ema-377", color = colorEma377, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
// SMA
plot(series = showSma3 ? sma3 : na, title = "Sma-3", color = colorSma3, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma5 ? sma5 : na, title = "Sma-5", color = colorSma5, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma6 ? sma6 : na, title = "Sma-6", color = colorSma6, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma7 ? sma7 : na, title = "Sma-7", color = colorSma7, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma8 ? sma8 : na, title = "Sma-8", color = colorSma8, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma10 ? sma10 : na, title = "Sma-10", color = colorSma10, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma20 ? sma20 : na, title = "Sma-20", color = colorSma20, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma25 ? sma25 : na, title = "Sma-25", color = colorSma25, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma30 ? sma30 : na, title = "Sma-30", color = colorSma30, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma50 ? sma50 : na, title = "Sma-50", color = colorSma50, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma100 ? sma100 : na, title = "Sma-100", color = colorSma100, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSma200 ? sma200 : na, title = "Sma-200", color = colorSma200, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
plot(series = showSmaAllTime ? smaAllTime : na, title = "Sma All-Time", color = colorSmaAllTime, linewidth = thickLine, style = plot.style_line, offset = offsetLine, editable = true)
// Custom Timeframe
plot(series = customTF1 ? maTF1 : na, title = "Custom TF #1", color = colorTF1, linewidth = thickLine, style = plot.style_line, offset = offset1, editable = true)
plot(series = customTF2 ? maTF2 : na, title = "Custom TF #2", color = colorTF2, linewidth = thickLine, style = plot.style_line, offset = offset2, editable = true)
plot(series = customTF3 ? maTF3 : na, title = "Custom TF #3", color = colorTF3, linewidth = thickLine, style = plot.style_line, offset = offset3, editable = true)
// Offset Text
offsetText = offsetLine == 0 ? "" : "x" + str.tostring(offsetLine)
// SMA Label Vars
var label label1 = na
textLabel1 = "Sma-3" + offsetText
seriesLabel1 = barstate.islast ? sma3 : na
offsetLabel1 = offsetLine + 1
colorLabel1 = colorSma3
conditionLabel1 = showLabel and showSma3 and barstate.islast
var label label2 = na
textLabel2 = "Sma-5" + offsetText
seriesLabel2 = barstate.islast ? sma5 : na
offsetLabel2 = offsetLine + 1
colorLabel2 = colorSma5
conditionLabel2 = showLabel and showSma5 and barstate.islast
var label label3 = na
textLabel3 = "Sma-6" + offsetText
seriesLabel3 = barstate.islast ? sma6 : na
offsetLabel3 = offsetLine + 1
colorLabel3 = colorSma6
conditionLabel3 = showLabel and showSma6 and barstate.islast
var label label4 = na
textLabel4 = "Sma-7" + offsetText
seriesLabel4 = barstate.islast ? sma7 : na
offsetLabel4 = offsetLine + 1
colorLabel4 = colorSma7
conditionLabel4 = showLabel and showSma7 and barstate.islast
var label label5 = na
textLabel5 = "Sma-8" + offsetText
seriesLabel5 = barstate.islast ? sma8 : na
offsetLabel5 = offsetLine + 1
colorLabel5 = colorSma8
conditionLabel5 = showLabel and showSma8 and barstate.islast
var label label6 = na
textLabel6 = "Sma-10" + offsetText
seriesLabel6 = barstate.islast ? sma10 : na
offsetLabel6 = offsetLine + 1
colorLabel6 = colorSma10
conditionLabel6 = showLabel and showSma10 and barstate.islast
var label label7 = na
textLabel7 = "Sma-20" + offsetText
seriesLabel7 = barstate.islast ? sma20 : na
offsetLabel7 = offsetLine + 1
colorLabel7 = colorSma20
conditionLabel7 = showLabel and showSma20 and barstate.islast
var label label8 = na
textLabel8 = "Sma-25" + offsetText
seriesLabel8 = barstate.islast ? sma25 : na
offsetLabel8 = offsetLine + 1
colorLabel8 = colorSma25
conditionLabel8 = showLabel and showSma25 and barstate.islast
var label label9 = na
textLabel9 = "Sma-30" + offsetText
seriesLabel9 = barstate.islast ? sma30 : na
offsetLabel9 = offsetLine + 1
colorLabel9 = colorSma30
conditionLabel9 = showLabel and showSma30 and barstate.islast
var label label10 = na
textLabel10 = "Sma-50" + offsetText
seriesLabel10 = barstate.islast ? sma50 : na
offsetLabel10 = offsetLine + 1
colorLabel10 = colorSma50
conditionLabel10 = showLabel and showSma50 and barstate.islast
var label label11 = na
textLabel11 = "Sma-100" + offsetText
seriesLabel11 = barstate.islast ? sma100 : na
offsetLabel11 = offsetLine + 1
colorLabel11 = colorSma100
conditionLabel11 = showLabel and showSma100 and barstate.islast
var label label12 = na
textLabel12 = "Sma-200" + offsetText
seriesLabel12 = barstate.islast ? sma200 : na
offsetLabel12 = offsetLine + 1
colorLabel12 = colorSma200
conditionLabel12 = showLabel and showSma200 and barstate.islast
var label label13 = na
textLabel13 = "Sma All-Time" + offsetText
seriesLabel13 = barstate.islast ? smaAllTime : na
offsetLabel13 = offsetLine + 1
colorLabel13 = colorSmaAllTime
conditionLabel13 = showLabel and showSmaAllTime and barstate.islast
if conditionLabel1
label.delete(label1)
label1 := label.new(x = bar_index + offsetLabel1, y = seriesLabel1, text = textLabel1, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel1, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel2
label.delete(label2)
label2 := label.new(x = bar_index + offsetLabel2, y = seriesLabel2, text = textLabel2, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel2, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel3
label.delete(label3)
label3 := label.new(x = bar_index + offsetLabel3, y = seriesLabel3, text = textLabel3, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel3, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel4
label.delete(label4)
label4 := label.new(x = bar_index + offsetLabel4, y = seriesLabel4, text = textLabel4, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel4, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel5
label.delete(label5)
label5 := label.new(x = bar_index + offsetLabel5, y = seriesLabel5, text = textLabel5, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel5, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel6
label.delete(label6)
label6 := label.new(x = bar_index + offsetLabel6, y = seriesLabel6, text = textLabel6, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel6, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel7
label.delete(label7)
label7 := label.new(x = bar_index + offsetLabel7, y = seriesLabel7, text = textLabel7, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel7, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel8
label.delete(label8)
label8 := label.new(x = bar_index + offsetLabel8, y = seriesLabel8, text = textLabel8, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel8, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel9
label.delete(label9)
label9 := label.new(x = bar_index + offsetLabel9, y = seriesLabel9, text = textLabel9, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel9, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel10
label.delete(label10)
label10 := label.new(x = bar_index + offsetLabel10, y = seriesLabel10, text = textLabel10, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel10, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel11
label.delete(label11)
label11 := label.new(x = bar_index + offsetLabel11, y = seriesLabel11, text = textLabel11, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel11, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel12
label.delete(label12)
label12 := label.new(x = bar_index + offsetLabel12, y = seriesLabel12, text = textLabel12, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel12, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel13
label.delete(label13)
label13 := label.new(x = bar_index + offsetLabel13, y = seriesLabel13, text = textLabel13, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel13, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
// EMA Label
var label label50 = na
textLabel50 = "Ema-3" + offsetText
seriesLabel50 = barstate.islast ? ema3 : na
offsetLabel50 = offsetLine + 1
colorLabel50 = colorEma3
conditionLabel50 = showLabel and showEma3 and barstate.islast
var label label51 = na
textLabel51 = "Ema-5" + offsetText
seriesLabel51 = barstate.islast ? ema5 : na
offsetLabel51 = offsetLine + 1
colorLabel51 = colorEma5
conditionLabel51 = showLabel and showEma5 and barstate.islast
var label label52 = na
textLabel52 = "Ema-8" + offsetText
seriesLabel52 = barstate.islast ? ema8 : na
offsetLabel52 = offsetLine + 1
colorLabel52 = colorEma8
conditionLabel52 = showLabel and showEma8 and barstate.islast
var label label53 = na
textLabel53 = "Ema-9" + offsetText
seriesLabel53 = barstate.islast ? ema9 : na
offsetLabel53 = offsetLine + 1
colorLabel53 = colorEma9
conditionLabel53 = showLabel and showEma9 and barstate.islast
var label label54 = na
textLabel54 = "Ema-13" + offsetText
seriesLabel54 = barstate.islast ? ema13 : na
offsetLabel54 = offsetLine + 1
colorLabel54 = colorEma13
conditionLabel54 = showLabel and showEma13 and barstate.islast
var label label55 = na
textLabel55 = "Ema-18" + offsetText
seriesLabel55 = barstate.islast ? ema18 : na
offsetLabel55 = offsetLine + 1
colorLabel55 = colorEma18
conditionLabel55 = showLabel and showEma18 and barstate.islast
var label label56 = na
textLabel56 = "Ema-21" + offsetText
seriesLabel56 = barstate.islast ? ema21 : na
offsetLabel56 = offsetLine + 1
colorLabel56 = colorEma21
conditionLabel56 = showLabel and showEma21 and barstate.islast
var label label57 = na
textLabel57 = "Ema-34" + offsetText
seriesLabel57 = barstate.islast ? ema34 : na
offsetLabel57 = offsetLine + 1
colorLabel57 = colorEma34
conditionLabel57 = showLabel and showEma34 and barstate.islast
var label label58 = na
textLabel58 = "Ema-50" + offsetText
seriesLabel58 = barstate.islast ? ema50 : na
offsetLabel58 = offsetLine + 1
colorLabel58 = colorEma50
conditionLabel58 = showLabel and showEma50 and barstate.islast
var label label59 = na
textLabel59 = "Ema-55" + offsetText
seriesLabel59 = barstate.islast ? ema55 : na
offsetLabel59 = offsetLine + 1
colorLabel59 = colorEma55
conditionLabel59 = showLabel and showEma55 and barstate.islast
var label label60 = na
textLabel60 = "Ema-89" + offsetText
seriesLabel60 = barstate.islast ? ema89 : na
offsetLabel60 = offsetLine + 1
colorLabel60 = colorEma89
conditionLabel60 = showLabel and showEma89 and barstate.islast
var label label61 = na
textLabel61 = "Ema-100" + offsetText
seriesLabel61 = barstate.islast ? ema100 : na
offsetLabel61 = offsetLine + 1
colorLabel61 = colorEma100
conditionLabel61 = showLabel and showEma100 and barstate.islast
var label label62 = na
textLabel62 = "Ema-144" + offsetText
seriesLabel62 = barstate.islast ? ema144 : na
offsetLabel62 = offsetLine + 1
colorLabel62 = colorEma144
conditionLabel62 = showLabel and showEma144 and barstate.islast
var label label63 = na
textLabel63 = "Ema-200" + offsetText
seriesLabel63 = barstate.islast ? ema200 : na
offsetLabel63 = offsetLine + 1
colorLabel63 = colorEma200
conditionLabel63 = showLabel and showEma200 and barstate.islast
var label label64 = na
textLabel64 = "Ema-377" + offsetText
seriesLabel64 = barstate.islast ? ema377 : na
offsetLabel64 = offsetLine + 1
colorLabel64 = colorEma377
conditionLabel64 = showLabel and showEma377 and barstate.islast
if conditionLabel50
label.delete(label50)
label50 := label.new(x = bar_index + offsetLabel50, y = seriesLabel50, text = textLabel50, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel50, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel51
label.delete(label51)
label51 := label.new(x = bar_index + offsetLabel51, y = seriesLabel51, text = textLabel51, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel51, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel52
label.delete(label52)
label52 := label.new(x = bar_index + offsetLabel52, y = seriesLabel52, text = textLabel52, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel52, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel53
label.delete(label53)
label53 := label.new(x = bar_index + offsetLabel53, y = seriesLabel53, text = textLabel53, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel53, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel54
label.delete(label54)
label54 := label.new(x = bar_index + offsetLabel54, y = seriesLabel54, text = textLabel54, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel54, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel55
label.delete(label55)
label55 := label.new(x = bar_index + offsetLabel55, y = seriesLabel55, text = textLabel55, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel55, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel56
label.delete(label56)
label56 := label.new(x = bar_index + offsetLabel56, y = seriesLabel56, text = textLabel56, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel56, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel57
label.delete(label57)
label57 := label.new(x = bar_index + offsetLabel57, y = seriesLabel57, text = textLabel57, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel57, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel58
label.delete(label58)
label58 := label.new(x = bar_index + offsetLabel58, y = seriesLabel58, text = textLabel58, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel58, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel59
label.delete(label59)
label59 := label.new(x = bar_index + offsetLabel59, y = seriesLabel59, text = textLabel59, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel59, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel60
label.delete(label60)
label60 := label.new(x = bar_index + offsetLabel60, y = seriesLabel60, text = textLabel60, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel60, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel61
label.delete(label61)
label61 := label.new(x = bar_index + offsetLabel61, y = seriesLabel61, text = textLabel61, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel61, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel62
label.delete(label62)
label62 := label.new(x = bar_index + offsetLabel62, y = seriesLabel62, text = textLabel62, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel62, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel63
label.delete(label63)
label63 := label.new(x = bar_index + offsetLabel63, y = seriesLabel63, text = textLabel63, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel63, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel64
label.delete(label64)
label64 := label.new(x = bar_index + offsetLabel64, y = seriesLabel64, text = textLabel64, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel64, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
// Custom Timeframe Label Vars
var label label90 = na
textOffset90 = offset1 > 0 ? "x" + str.tostring(offset1) : ""
textLabel90 = chartTF1 ? maSelectTF1 + textOffset90 : maSelectTF1 + " (" + inputTF1 + ") " + textOffset90
seriesLabel90 = barstate.islast ? maTF1 : na
offsetLabel90 = offset1 + 1
colorLabel90 = colorTF1
conditionLabel90 = showLabel and customTF1 and barstate.islast
var label label91 = na
textOffset91 = offset2 > 0 ? "x" + str.tostring(offset2) : ""
textLabel91 = chartTF2 ? maSelectTF2 + textOffset91 : maSelectTF2 + " (" + inputTF2 + ") " + textOffset91
seriesLabel91 = barstate.islast ? maTF2 : na
offsetLabel91 = offset2 + 1
colorLabel91 = colorTF2
conditionLabel91 = showLabel and customTF2 and barstate.islast
var label label92 = na
textOffset92 = offset3 > 0 ? "x" + str.tostring(offset3) : ""
textLabel92 = chartTF3 ? maSelectTF3 + textOffset92 : maSelectTF3 + " (" + inputTF3 + ") " + textOffset92
seriesLabel92 = barstate.islast ? maTF3 : na
offsetLabel92 = offset3 + 1
colorLabel92 = colorTF3
conditionLabel92 = showLabel and customTF3 and barstate.islast
if conditionLabel90
label.delete(label90)
label90 := label.new(x = bar_index + offsetLabel90, y = seriesLabel90, text = textLabel90, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel90, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel91
label.delete(label91)
label91 := label.new(x = bar_index + offsetLabel91, y = seriesLabel91, text = textLabel91, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel91, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
if conditionLabel92
label.delete(label92)
label92 := label.new(x = bar_index + offsetLabel92, y = seriesLabel92, text = textLabel92, xloc = xloc.bar_index, yloc = yloc.price, color = colorLabel92, style = label.style_label_left, textcolor = colorTextLabel, size = size.normal, textalign = text.align_center)
|
Fractal Dimension | https://www.tradingview.com/script/HIQx24Uv-Fractal-Dimension/ | IvarssonAnalytics | https://www.tradingview.com/u/IvarssonAnalytics/ | 20 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © IvarssonAnalytics
//@version=5
indicator("Fractal Dimension")
ri = math.log(close/close[1])
n = 65
Rin = math.log(close/close[n])
Nin = (math.sum(math.abs(ri),n))/(math.abs(Rin)/n)
Din = math.log(Nin)/math.log(n)
plot(Din)
plot(1.25)
|
Rolling VWAP with stdev | https://www.tradingview.com/script/fnFvu80c-Rolling-VWAP-with-stdev/ | UnknownUnicorn17032407 | https://www.tradingview.com/u/UnknownUnicorn17032407/ | 75 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TradingView
// modified by xcpov, april 2022
// added standard deviation plots with the option
// to show 2 standard deviations
//@version=5
indicator("Rolling VWAP with stdev", "RVWAPsd", true)
import PineCoders/ConditionalAverages/1 as pc
// ———————————————————— Constants and Inputs {
int MS_IN_MIN = 60 * 1000
int MS_IN_HOUR = MS_IN_MIN * 60
int MS_IN_DAY = MS_IN_HOUR * 24
var string TT_WINDOW = "By default, the time period used to calculate the RVWAP automatically adjusts with the chart's timeframe.
Check this to use a fixed-size time period instead, which you define with the following three values."
var string TT_MINBARS = "The minimum number of last values to keep in the moving window, even if these values are outside the time period.
This avoids situations where a large time gap between two bars would cause the time window to be empty."
float srcInput = input.source(hlc3, "Source", tooltip = "The source used to calculate the VWAP. The default is the average of the high, low and close prices.")
var string GRP2 = '═══════════ Time Period ═══════════'
bool fixedTfInput = input.bool(false, "Use a fixed time period", group = GRP2, tooltip = TT_WINDOW)
int daysInput = input.int(1, "Days", 0, 90, group = GRP2) * MS_IN_DAY
int hoursInput = input.int(0, "Hours", 0, 23, group = GRP2) * MS_IN_HOUR
int minsInput = input.int(0, "Minutes", 0, 59, group = GRP2) * MS_IN_MIN
bool tableInput = input.bool(true, "Show time period", group = GRP2, tooltip = "Displays the time period of the rolling window.")
string textSizeInput = input.string("large", "Text size", group = GRP2, options = ["tiny", "small", "normal", "large", "huge", "auto"])
string tableYposInput = input.string("bottom", "Position ", inline = "21", group = GRP2, options = ["top", "middle", "bottom"])
string tableXposInput = input.string("right", "", inline = "21", group = GRP2, options = ["left", "center", "right"])
var string GRP3 = '════════ Minimum Window Size ════════'
int minBarsInput = input.int(10, "Bars", group = GRP3, tooltip = TT_MINBARS)
// }
// ———————————————————— Functions {
timeStep() =>
// @function Determines a time period from the chart's timeframe.
// @returns (int) A value of time in milliseconds that is appropriate for the current chart timeframe. To be used in the RVWAP calculation.
int tfInMs = timeframe.in_seconds() * 1000
float step =
switch
tfInMs <= MS_IN_MIN => MS_IN_HOUR
tfInMs <= MS_IN_MIN * 5 => MS_IN_HOUR * 4
tfInMs <= MS_IN_HOUR => MS_IN_DAY * 1
tfInMs <= MS_IN_HOUR * 4 => MS_IN_DAY * 3
tfInMs <= MS_IN_HOUR * 12 => MS_IN_DAY * 7
tfInMs <= MS_IN_DAY => MS_IN_DAY * 30.4375
tfInMs <= MS_IN_DAY * 7 => MS_IN_DAY * 90
=> MS_IN_DAY * 365
int result = int(step)
tfString(int timeInMs) =>
// @function Produces a string corresponding to the input time in days, hours, and minutes.
// @param (series int) A time value in milliseconds to be converted to a string variable.
// @returns (string) A string variable reflecting the amount of time from the input time.
int s = timeInMs / 1000
int m = s / 60
int h = m / 60
int tm = math.floor(m % 60)
int th = math.floor(h % 24)
int d = math.floor(h / 24)
string result =
switch
d == 30 and th == 10 and tm == 30 => "1M"
d == 7 and th == 0 and tm == 0 => "1W"
=>
string dStr = d ? str.tostring(d) + "D " : ""
string hStr = th ? str.tostring(th) + "H " : ""
string mStr = tm ? str.tostring(tm) + "min" : ""
dStr + hStr + mStr
// }
// ———————————————————— Calculations and Plots {
// Stop the indicator on charts with no volume.
if barstate.islast and ta.cum(nz(volume)) == 0
runtime.error("No volume is provided by the data vendor.")
// RVWAP
var int timeInMs = fixedTfInput ? minsInput + hoursInput + daysInput : timeStep()
float rollingVWAP = pc.totalForTimeWhen(srcInput * volume, timeInMs, true, minBarsInput) / pc.totalForTimeWhen(volume, timeInMs, true, minBarsInput)
plot(rollingVWAP, "Rolling VWAP", color.orange)
// Display of time period.
var table tfDisplay = table.new(tableYposInput + "_" + tableXposInput, 1, 1)
if tableInput
table.cell(tfDisplay, 0, 0, tfString(timeInMs), bgcolor = na, text_color = color.gray, text_size = textSizeInput)
//
// BEGIN MODIFICATIONS by xcpov, apr 2022
// plot standard deviation lines
//
plot(rollingVWAP + ta.stdev(rollingVWAP, minBarsInput), "Rolling VWAP + stdev", color.blue, display = display.all)
plot(rollingVWAP - ta.stdev(rollingVWAP, minBarsInput), "Rolling VWAP - stdev", color.blue, display = display.all)
plot(rollingVWAP + 2 * ta.stdev(rollingVWAP, minBarsInput), "Rolling VWAP + 2 stdev", color.white, display = display.none)
plot(rollingVWAP - 2 * ta.stdev(rollingVWAP, minBarsInput), "Rolling VWAP - 2 stdev", color.white, display = display.none)
// END MODIFICATIONS FOR STANDARD DEVIATION PLOTS
// }
|
[MACLEN] VolumenTotal | https://www.tradingview.com/script/ESGrStzu-MACLEN-VolumenTotal/ | MaclenMtz | https://www.tradingview.com/u/MaclenMtz/ | 18 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MaclenMtz
//@version=5
indicator("VolumenTotal")
vol1 = request.security("BINANCE:BTCUSDT", timeframe.period, volume)
vol2 = request.security("BITFINEX:BTCUSD", timeframe.period, volume)
vol3 = request.security("BINANCE:BTCUSDTPERP", timeframe.period, volume)
vol4 = request.security("BINANCEUS:BTCUSD", timeframe.period, volume)
vol5 = request.security("BINANCEUS:BTCUSDT", timeframe.period, volume)
vol6 = request.security("HUOBI:BTCUSDT", timeframe.period, volume)
vol7 = request.security("KRAKEN:BTCUSD", timeframe.period, volume)
vol8 = request.security("KRAKEN:BTCUSDT", timeframe.period, volume)
vol9 = request.security("BITMEX:XBTUSDT", timeframe.period, volume/close)
vol10 = request.security("FTX:BTCUSD", timeframe.period, volume/close)
vol11 = request.security("FTX:BTCPERP", timeframe.period, volume/close)
vol12 = request.security("COINBASE:BTCUSD", timeframe.period, volume)
vol13 = request.security("COINBASE:BTCUSDT", timeframe.period, volume)
vol14 = request.security("BITSO:BTCMXN", timeframe.period, volume)
volTot = vol1+vol2+vol3+vol4+vol5+vol6+vol7+vol8+vol9+vol10+vol11+vol12+vol13+vol14
plot(volTot, color=color.white, style=plot.style_histogram)
var table display = table.new(position.middle_right,1,1)
labelText = str.tostring(volTot)
table.cell(display,0,0,labelText)
|
USDC&USDT Dominance | https://www.tradingview.com/script/syW0qi6x-USDC-USDT-Dominance/ | xiaolaichen | https://www.tradingview.com/u/xiaolaichen/ | 76 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © xiaolaiseanchen
//@version=5
indicator("USDC&USDT&BUSD&DAI Dominance", overlay=false)
total = input.symbol("TOTAL", "Symbol")
usdt = input.symbol("usdt_marketcap", "Symbol")
usdc = input.symbol("usdc_marketcap", "Symbol")
busd = input.symbol("busd_marketcap", "Symbol")
dai = input.symbol("DAI_MARKETCAP","Symbol")
timeframeInput = input.timeframe("D", "Timeframe")
sourceInput = input.source(hl2, "Source")
periodInput = input(1, "Period")
usdc_d = request.security(usdc, timeframeInput, ta.sma(sourceInput, periodInput))
usdt_d = request.security(usdt, timeframeInput, ta.sma(sourceInput, periodInput))
busd_d = request.security(busd, timeframeInput, ta.sma(sourceInput, periodInput))
dai_d = request.security(dai, timeframeInput, ta.sma(sourceInput, periodInput))
total_d = request.security(total, timeframeInput, ta.sma(sourceInput, periodInput))
index = (usdc_d+usdt_d+busd_d+dai_d)/total_d
plot(index)
|
Global Trend [BEA] | https://www.tradingview.com/script/i21REzLB-Global-Trend-BEA/ | TJalam | https://www.tradingview.com/u/TJalam/ | 75 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Badshah.E.Alam
//@version=5
indicator('Global Trend', overlay=false, max_bars_back=200)
// Input for signal smoothing
use_sma=input(true,"Signal Smoothing",group="Trend smoothing")
slow_length = input(title="Length", defval=12,group="Trend smoothing")
//Inputs for plotting diffrent mareket trends
plot_asian=input(true,"plot Asian market trend",group="Plot Trend")
plot_Local=input(false,"plot Local market trend",group="Plot Trend")
plot_american=input(false,"plot American market trend",group="Plot Trend")
plot_european=input(false,"plot European market trend",group="Plot Trend")
plot_all=input(true,"plot Average of all market trend",group="Plot Trend")
use_todays_open=input(true,"Use Todays open instead of yesterdays close for calculation")
// function to calculate the % change w.r.t previous day close
function_get_per_change() =>
close_yest = use_todays_open?ta.valuewhen(ta.change(time('D')), open, 0):ta.valuewhen(ta.change(time('D')), close[1], 0)
per = (close - close_yest) / close_yest * 100
// Local indices (i am situated in India so i have picked up local index)
s01 = input.symbol('NSE:NIFTY',group="Local Market indices")
s02 = input.symbol('NSE:BANKNIFTY',group="Local Market indices")
s03 = input.symbol('NSE:CNXIT',group="Local Market indices")
s04 = input.symbol('NSE:CNXINFRA',group="Local Market indices")
s05 = input.symbol('NSE:CNXAUTO',group="Local Market indices")
s06 = input.symbol('NSE:CNXMETAL',group="Local Market indices")
s07 = input.symbol('NSE:CNXFMCG',group="Local Market indices")
s08 = input.symbol('NSE:CNXPHARMA',group="Local Market indices")
s09 = input.symbol('NSE:CNXMEDIA',group="Local Market indices")
s10 = input.symbol('NSE:CNXENERGY',group="Local Market indices")
// security call to get the % change w.r.t previous day close
perc01 = request.security(s01, '', function_get_per_change())
perc02 = request.security(s02, '', function_get_per_change())
perc03 = request.security(s03, '', function_get_per_change())
perc04 = request.security(s04, '', function_get_per_change())
perc05 = request.security(s05, '', function_get_per_change())
perc06 = request.security(s06, '', function_get_per_change())
perc07 = request.security(s07, '', function_get_per_change())
perc08 = request.security(s08, '', function_get_per_change())
perc09 = request.security(s09, '', function_get_per_change())
perc10 = request.security(s10, '', function_get_per_change())
// Major Asian market indices
a01 = input.symbol('NSE:NIFTY',group="Asian Market indices")
a02 = input.symbol('TVC:HSI',group="Asian Market indices")
a03 = input.symbol('TVC:NI225',group="Asian Market indices")
a04 = input.symbol('KRX:KOSPI',group="Asian Market indices")
a05 = input.symbol('TWSE_DLY:TAIEX',group="Asian Market indices")
a06 = input.symbol('BIST_DLY:XU100',group="Asian Market indices")
a07 = input.symbol('IDX_DLY:COMPOSITE',group="Asian Market indices")
a08 = input.symbol('TVC:STI',group="Asian Market indices")
a09 = input.symbol('BSE_DLY:SENSEX',group="Asian Market indices")
a10 = input.symbol('TFEX:S501!',group="Asian Market indices")
// security call to get the % change w.r.t previous day close
pera01 = request.security(a01, '', function_get_per_change())
pera02 = request.security(a02, '', function_get_per_change())
pera03 = request.security(a03, '', function_get_per_change())
pera04 = request.security(a04, '', function_get_per_change())
pera05 = request.security(a05, '', function_get_per_change())
pera06 = request.security(a06, '', function_get_per_change())
pera07 = request.security(a07, '', function_get_per_change())
pera08 = request.security(a08, '', function_get_per_change())
pera09 = request.security(a09, '', function_get_per_change())
pera10 = request.security(a10, '', function_get_per_change())
// Major Ameriacan market indices
e01 = input.symbol('CURRENCYCOM:US500',group="American Market indices")
e02 = input.symbol('DJ:DJI',group="American Market indices")
e03 = input.symbol('NASDAQ_DLY:NDX',group="American Market indices")
e04 = input.symbol('FX:US2000',group="American Market indices")
e05 = input.symbol('CSE:CSE25',group="American Market indices")
e06 = input.symbol('BMV_DLY:60',group="American Market indices")
e07 = input.symbol('PEPPERSTONE:NAS100',group="American Market indices")
e08 = input.symbol('PEPPERSTONE:US30',group="American Market indices")
e09 = input.symbol('BSE_DLY:SENSEX',group="American Market indices")
e10 = input.symbol('TVC:NI225',group="American Market indices")
// security call to get the % change w.r.t previous day close
pere01 = request.security(e01, '', function_get_per_change())
pere02 = request.security(e02, '', function_get_per_change())
pere03 = request.security(e03, '', function_get_per_change())
pere04 = request.security(e04, '', function_get_per_change())
pere05 = request.security(e05, '', function_get_per_change())
pere06 = request.security(e06, '', function_get_per_change())
pere07 = request.security(e07, '', function_get_per_change())
pere08 = request.security(e08, '', function_get_per_change())
pere09 = request.security(e09, '', function_get_per_change())
pere10 = request.security(e10, '', function_get_per_change())
// Major European market indices
m01 = input.symbol('CURRENCYCOM:UK100',group="European Market indices")
m02 = input.symbol('EURONEXT_DLY:N100',group="European Market indices")
m03 = input.symbol('TVC:CAC40',group="European Market indices")
m04 = input.symbol('XETR_DLY:DAX',group="European Market indices")
m05 = input.symbol('SIX_DLY:SMI',group="European Market indices")
m06 = input.symbol('EURONEXT_DLY:BEL20',group="European Market indices")
m07 = input.symbol('EURONEXT_DLY:AEX',group="European Market indices")
m08 = input.symbol('TVC:SX5E',group="European Market indices")
m09 = input.symbol('MOEX:IMOEX',group="European Market indices")
m10 = input.symbol('FOREXCOM:ITA40',group="European Market indices")
// security call to get the % change w.r.t previous day close
perm01 = request.security(m01, '', function_get_per_change())
perm02 = request.security(m02, '', function_get_per_change())
perm03 = request.security(m03, '', function_get_per_change())
perm04 = request.security(m04, '', function_get_per_change())
perm05 = request.security(m05, '', function_get_per_change())
perm06 = request.security(m06, '', function_get_per_change())
perm07 = request.security(m07, '', function_get_per_change())
perm08 = request.security(m08, '', function_get_per_change())
perm09 = request.security(m09, '', function_get_per_change())
perm10 = request.security(m10, '', function_get_per_change())
// sum of all local indices if % change greater than zero
sum_if_great_zero = perc01 > 0 ? perc01 : 0 +
perc02 > 0 ? perc02 : 0 +
perc03 > 0 ? perc03 : 0 +
perc04 > 0 ? perc04 : 0 +
perc05 > 0 ? perc05 : 0 +
perc06 > 0 ? perc06 : 0 +
perc07 > 0 ? perc07 : 0 +
perc08 > 0 ? perc08 : 0 +
perc09 > 0 ? perc09 : 0 +
perc10 > 0 ? perc10 : 0
// sum of all local indices if % change less than zero
sum_if_less_zero = -(perc01 < 0 ? perc01 : 0 +
perc02 < 0 ? perc02 : 0 +
perc03 < 0 ? perc03 : 0 +
perc04 < 0 ? perc04 : 0 +
perc05 < 0 ? perc05 : 0 +
perc06 < 0 ? perc06 : 0 +
perc07 < 0 ? perc07 : 0 +
perc08 < 0 ? perc08 : 0 +
perc09 < 0 ? perc09 : 0 +
perc10 < 0 ? perc10 : 0)
// sum of all asian indices if % change greater than zero
sum_if_great_zero_asian = pera01 > 0 ? pera01 : 0 +
pera02 > 0 ? pera02 : 0 +
pera03 > 0 ? pera03 : 0 +
pera04 > 0 ? pera04 : 0 +
pera05 > 0 ? pera05 : 0 +
pera06 > 0 ? pera06 : 0 +
pera07 > 0 ? pera07 : 0 +
pera08 > 0 ? pera08 : 0 +
pera09 > 0 ? pera09 : 0 +
pera10 > 0 ? pera10 : 0
// sum of all Asian indices if % change less than zero
sum_if_less_zero_asian = -(pera01 < 0 ? pera01 : 0 +
pera02 < 0 ? pera02 : 0 +
pera03 < 0 ? pera03 : 0 +
pera04 < 0 ? pera04 : 0 +
pera05 < 0 ? pera05 : 0 +
pera06 < 0 ? pera06 : 0 +
pera07 < 0 ? pera07 : 0 +
pera08 < 0 ? pera08 : 0 +
pera09 < 0 ? pera09 : 0 +
pera10 < 0 ? pera10 : 0 )
// sum of all European indices if % change greater than zero
sum_if_great_zero_europe = perm01 > 0 ? perm01 : 0 +
perm02 > 0 ? perm02 : 0 +
perm03 > 0 ? perm03 : 0 +
perm04 > 0 ? perm04 : 0 +
perm05 > 0 ? perm05 : 0 +
perm06 > 0 ? perm06 : 0 +
perm07 > 0 ? perm07 : 0 +
perm08 > 0 ? perm08 : 0 +
perm09 > 0 ? perm09 : 0 +
perm10 > 0 ? perm10 : 0
// sum of all European indices if % change less than zero
sum_if_less_zero_europe = -(perm01 < 0 ? perm01 : 0 +
perm02 < 0 ? perm02 : 0 +
perm03 < 0 ? perm03 : 0 +
perm04 < 0 ? perm04 : 0 +
perm05 < 0 ? perm05 : 0 +
perm06 < 0 ? perm06 : 0 +
perm07 < 0 ? perm07 : 0 +
perm08 < 0 ? perm08 : 0 +
perm09 < 0 ? perm09 : 0 +
perm10 < 0 ? perm10 : 0 )
// sum of all American indices if % change greater than zero
sum_if_great_zero_america = pere01 > 0 ? pere01 : 0 +
pere02 > 0 ? pere02 : 0 +
pere03 > 0 ? pere03 : 0 +
pere04 > 0 ? pere04 : 0 +
pere05 > 0 ? pere05 : 0 +
pere06 > 0 ? pere06 : 0 +
pere07 > 0 ? pere07 : 0 +
pere08 > 0 ? pere08 : 0 +
pere09 > 0 ? pere09 : 0 +
pere10 > 0 ? pere10 : 0
// sum of all American indices if % change less than zero
sum_if_less_zero_america = -(pere01 < 0 ? pere01 : 0 +
pere02 < 0 ? pere02 : 0 +
pere03 < 0 ? pere03 : 0 +
pere04 < 0 ? pere04 : 0 +
pere05 < 0 ? pere05 : 0 +
pere06 < 0 ? pere06 : 0 +
pere07 < 0 ? pere07 : 0 +
pere08 < 0 ? pere08 : 0 +
pere09 < 0 ? pere09 : 0 +
pere10 < 0 ? pere10 : 0 )
// % calculation and signal smooting options
plot_final_pos =use_sma? ta.sma(sum_if_great_zero / (sum_if_great_zero + sum_if_less_zero) * 100,slow_length):sum_if_great_zero / (sum_if_great_zero + sum_if_less_zero) * 100
plot_final_pos_asian =use_sma? ta.sma(sum_if_great_zero_asian / (sum_if_great_zero_asian + sum_if_less_zero_asian) * 100,slow_length):sum_if_great_zero_asian / (sum_if_great_zero_asian + sum_if_less_zero_asian)*100
plot_final_pos_europe =use_sma? ta.sma(sum_if_great_zero_europe / (sum_if_great_zero_europe + sum_if_less_zero_europe) * 100,slow_length):sum_if_great_zero_europe / (sum_if_great_zero_europe + sum_if_less_zero_europe) * 100
plot_final_pos_america =use_sma? ta.sma(sum_if_great_zero_america / (sum_if_great_zero_america + sum_if_less_zero_america) * 100,slow_length):sum_if_great_zero_america / (sum_if_great_zero_america + sum_if_less_zero_america) * 100
average_all=use_sma?ta.sma(math.avg(plot_final_pos,plot_final_pos_asian,plot_final_pos_europe),slow_length):math.avg(plot_final_pos,plot_final_pos_asian,plot_final_pos_europe)
// bg color if at day change
bgcolor(ta.change(time('D')) ? color.new(color.red,90) : na, title="Session change")
//plots
plot(series=plot_Local?plot_final_pos:na, style=plot.style_circles, color=color.new(color.green, 0), linewidth=2,title="Local Market circle")
plot(series=plot_Local?plot_final_pos:na, style=plot.style_line, color=color.new(color.green, 0), linewidth=1,title="Local Market Trend line")
plot(series=plot_asian?plot_final_pos_asian:na, style=plot.style_circles, color=color.new(color.lime, 0), linewidth=2,title="Asian Market Trend line")
plot(series=plot_asian?plot_final_pos_asian:na, style=plot.style_line, color=color.new(color.lime, 0), linewidth=1,title="Asian Market Trend line")
plot(series=plot_european?plot_final_pos_europe:na, style=plot.style_circles, color=color.new(#8AFF8A, 0), linewidth=2,title="European Market Trend line")
plot(series=plot_european?plot_final_pos_europe:na, style=plot.style_line, color=color.new(#8AFF8A, 0), linewidth=1,title="European Market Trend line")
plot(series=plot_american ?plot_final_pos_america:na, style=plot.style_circles, color=color.new(#8AFF8A, 0), linewidth=2,title="American Market Trend line")
plot(series=plot_american ?plot_final_pos_america:na, style=plot.style_line, color=color.new(#8AFF8A, 0), linewidth=1,title="American Market Trend line")
plot(series=plot_all?average_all:na, style=plot.style_circles, color=color.new(#488214, 0), linewidth=2,title="Average Market Trend line")
plot(series=plot_all?average_all:na, style=plot.style_line, color=color.new(#488214, 0), linewidth=1,title="Average All four Market Trend line")
hline(80,"Upper line",color=color.green)
hline(20,"Lower line",color=color.red)
// lable with values
if barstate.islast and plot_Local
l1=label.new(bar_index, plot_final_pos,' Local Market Trend ' + str.tostring(math.round(plot_final_pos,2)),color=color.new(color.red,100),textcolor=color.new(color.green,0))
label.delete(l1[1])
if barstate.islast and plot_asian
l2=label.new(bar_index,plot_final_pos_asian, ' Asian Market Trend ' + str.tostring(math.round(plot_final_pos_asian,2)),color=color.new(color.red,100),textcolor=color.new(color.lime,0))
label.delete(l2[1])
if barstate.islast and plot_european
l3=label.new(bar_index, plot_final_pos_europe, ' Europe Market Trend ' + str.tostring(math.round(plot_final_pos_europe,2)),color=color.new(color.red,100),textcolor=color.new(#8AFF8A,0))
label.delete(l3[1])
if barstate.islast and plot_american
l5=label.new(bar_index, plot_final_pos_america, ' American Market Trend ' + str.tostring(math.round(plot_final_pos_europe,2)),color=color.new(color.red,100),textcolor=color.new(#9CBA7F,0))
label.delete(l5[1])
if barstate.islast and plot_all
l4=label.new(bar_index, average_all, ' Average All four Market Trend ' + str.tostring(math.round(average_all,2)),color=color.new(color.red,100),textcolor=color.new(#488214,0))
label.delete(l4[1])
|
Reshape Table Matrix | https://www.tradingview.com/script/waOYbZGO-Reshape-Table-Matrix/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 52 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG
//@version=5
indicator('Reshape Table Matrix', overlay = true)
// 0.0 Input
// 1.0 Matrix Variables
// 2.0 Switch
// 3.0 Table
// 4.0 Construct
// ————————————————————————————————————————————————————————————————————————————— 0.0 Input {
i_b_reshape = input.bool(false, 'Reshape Table')
G = 'TABLE'
T1 = 'Tick to show table\n2) Small font size recommended for mobile app or multiple layout'
T2 = 'Table must be tick before change table position'
i_b_table = input.bool(true, 'Show Table |', group = G, inline = 'Table1')
i_s_font = input.string('normal', 'Font size', group = G, inline = 'Table1', options = ['tiny', 'small', 'normal', 'large', 'huge'], tooltip = T1)
i_s_Y = input.string('bottom', 'Table Position', group = G, inline = 'Table2', options = ['top', 'middle', 'bottom'])
i_s_X = input.string('left', '', group = G, inline = 'Table2', options = ['left', 'center', 'right'], tooltip = T2)
i_c_bgcolor = input.color(color.blue, 'Cell Background')
// }
// ————————————————————————————————————————————————————————————————————————————— 1.0 Matrix Variables
// ————————————————————————————————————————————————————————————————————————————— 1.1 Create a 2x3 matrix. {
var m1 = matrix.new<float>(2, 3)
// }
// ————————————————————————————————————————————————————————————————————————————— 1.2 Fill the matrix with values {
for _column = 0 to 2
matrix.set(m1, 0, _column, _column + 1)
matrix.set(m1, 1, _column, _column + 4)
// }
// ————————————————————————————————————————————————————————————————————————————— 1.3 Copy the matrix to a new one. {
var m2 = matrix.copy(m1)
// }
// ————————————————————————————————————————————————————————————————————————————— 1.4 Reshape the copy to a 3x2. {
matrix.reshape(m2, 3, 2)
// }
// ————————————————————————————————————————————————————————————————————————————— 2.0 Switch {
[_id, _columns, _rows] = switch i_b_reshape
true => [m2, 2, 3]
false => [m1, 3, 2]
// }
// ————————————————————————————————————————————————————————————————————————————— 3.0 Table {
// Display using a table.
var t = table.new(i_s_Y + '_' + i_s_X, _columns, _rows, border_width = 1)
// }
// ————————————————————————————————————————————————————————————————————————————— 4.0 Construct {
if barstate.islast
for _column = 0 to _columns -1
for _row = 0 to _rows - 1
table.cell(t, _column, _row, str.tostring(matrix.get(_id, _row, _column)), bgcolor = i_c_bgcolor, text_size = i_s_font)
// } |
Trapping Candles | https://www.tradingview.com/script/FvxeRa2f-Trapping-Candles/ | Jainbaba | https://www.tradingview.com/u/Jainbaba/ | 81 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Jainbaba
//@version=5
indicator("Trapping Candles",overlay = true)
bool val = false
bool val2 = false
if volume[0] > volume[1] and (close < open)
val := true
plotshape(val,style=shape.xcross,color=color.green)
//if volume[0] > volume[1] and (close > open)
// val2 := true
//plotshape(val2,style=shape.xcross,color=color.red,location=location.belowbar)
|
4C Volume w/ Relative Volume at Time | https://www.tradingview.com/script/GzJVCzp3-4C-Volume-w-Relative-Volume-at-Time/ | FourC | https://www.tradingview.com/u/FourC/ | 136 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FourC
//@version=5
// Credits to @author=e2e4mfck , @author=LucF, and TradingView as a large part of the RVOL code is from their indicator: 'Relative Volume At Time'
// Credit also goes to // @author LazyBear. Portions of the Volume indicator is adapted from - HawkEye Volume Indicator [LazyBear]
MAX_BARS_BACK = 5000
indicator('4C Volume w/ Relative Volume at Time', '4C Vol+RVOL', false, max_labels_count=500, max_bars_back=MAX_BARS_BACK)
////////VOLUME Indicator with moving average
_10 = input(true, '═══════════ "Hawkeye" Volume ════════════')
length = input(200)
range_1 = high - low
rangeAvg = ta.sma(range_1, length)
mov1 = input(true, title='Enable Simple Moving Avg')
mov2 = input.int(20, minval=1, title='Vol Moving Avg Length')
volumeA = ta.sma(volume, length)
divisor = input(3.6)
high1 = high[1]
low1 = low[1]
mid1 = hl2[1]
u1 = mid1 + (high1 - low1) / divisor
d1 = mid1 - (high1 - low1) / divisor
r_enabled1 = range_1 > rangeAvg and close < d1 and volume > volumeA
r_enabled2 = close < mid1
r_enabled = r_enabled1 or r_enabled2
g_enabled1 = close > mid1
g_enabled2 = range_1 > rangeAvg and close > u1 and volume > volumeA
g_enabled3 = high > high1 and range_1 < rangeAvg / 1.5 and volume < volumeA
g_enabled4 = low < low1 and range_1 < rangeAvg / 1.5 and volume > volumeA
g_enabled = g_enabled1 or g_enabled2 or g_enabled3 or g_enabled4
gr_enabled1 = range_1 > rangeAvg and close > d1 and close < u1 and volume > volumeA and volume < volumeA * 1.5 and volume > volume[1]
gr_enabled2 = range_1 < rangeAvg / 1.5 and volume < volumeA / 1.5
gr_enabled3 = close > d1 and close < u1
gr_enabled = gr_enabled1 or gr_enabled2 or gr_enabled3
v_color = gr_enabled ? color.gray : g_enabled ? color.rgb(0,255,0) : r_enabled ? color.rgb(255,0,0) : color.blue
plot(volume, style=plot.style_columns, color=v_color, title = 'Volume')
mov3 = ta.sma(volume, mov2)
plot(mov3 and mov1 ? mov3 : na, title='Volume Moving Avg', color=color.new(color.aqua, 0), linewidth=2)
////////Relative Volume at Time
// —————————— Constants and inputs {
// ————— Color constants for input default values.
var color c_BULL_BRIGHT = color.new(color.blue, 0)
var color c_BEAR_BRIGHT = color.new(color.purple, 0)
// ————— String constants used in input options.
// Boolean inputs.
var string ON = 'On'
var string OFF = 'Off'
// Calculation modes.
var string CM1 = 'Cumulate from Beginning of TF to Current Bar'
var string CM2 = 'Point-to-Point Bars at Same Offset from Beginning of TF'
// TF selection modes.
var string TF1 = 'Auto-Steps Timeframe'
var string TF2 = 'Fixed Timeframe'
var string TF3 = 'Time (only works with intraday timeframes)'
// Threshold modes.
var string TM1 = 'Fixed Value'
var string TM2 = 'Standard Deviation Channel From Fixed Lookback'
var string TM3 = 'High/Low Channel From Beginning of TF'
var string TM4 = 'High/Low Channel From Beginning of Past Volume Lookback'
var string TM5 = 'High/Low Channel From Fixed Lookback'
// Volatility filter modes.
var string VT1 = 'All'
var string VT2 = 'High only'
var string VT3 = 'Low only'
// ————— Inputs
_20 = input(true, '══════════ Relative Volume Colors ═══════════')
color i_c_bullBright = input(c_BULL_BRIGHT, 'High Relative Volume')
color i_c_bearBright = input(c_BEAR_BRIGHT, 'Low/Avg Relative Volume')
_40 = input(true, '═════════════ Settings ═════════════')
string i_calcMode = input.string(CM1, 'Calculation Mode', options=[CM1, CM2])
int i_period = input.int(5, 'Past Volume Lookback in TF units', minval=1)
string i_tfType = input.string(TF1, 'Define Timeframes Units Using', options=[TF1, TF2, TF3])
string i_tf = input.timeframe('D', ' Fixed')
int i_hour = input.int(09, ' Time (hour)', minval=0, maxval=23)
int i_minute = input.int(30, ' Time (minute)', minval=0, maxval=59)
string i_thresholdMode = input.string(TM1, 'Threshold Mode', options=[TM1, TM2, TM3, TM4, TM5])
float i_thresholdFixedVal = input.float(2.0, ' Fixed Threshold', minval=1, step=0.1)
int i_thresholdLookback = input.int(100, ' Channel Lookback', minval=1)
float i_thresholdStdevFac = input.float(1.0, ' StDev Factor', minval=0, step=0.1)
int i_avgPeriod = input.int(14, 'Period of RelVol Moving Average', minval=1)
int i_fastVolatility = input.int(7, 'High Volatility When Short-term ATR', minval=1)
int i_slowVolatility = input.int(40, ' Is Higher Than Long-term ATR', minval=2)
// }
// —————————— Functions {
// ————— Returns 1 when `_c` boolean is true, 0 if false.
f_01(_c) =>
_c ? 1 : 0
// ————— Converts current chart timeframe into a float minutes value.
f_chartTfInMinutes() =>
float _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
_resInMinutes
// ————— Returns `_tf` timeframe in float minutes.
f_tfInMinutes(_tf) =>
// _tf: TF (in `timeframe.period` string format) to be converted in float minutes.
// Dependency: f_chartTfInMinutes()
request.security(syminfo.tickerid, _tf, f_chartTfInMinutes(), lookahead=barmerge.lookahead_on)
// ————— Given a `_res` timeframe in float minutes, returns the ideal timeframe to use in calcs.
f_tfAutoSteps(_tf) =>
// _tf: chart's TF in fractional minutes from which to derive a HTF.
_tf <= 0.02 ? '1' : _tf <= 1 ? '60' : _tf < 60. * 24 ? '1D' : _tf == 60. * 24 ? '1W' : _tf < 60. * 24 * 30.4375 ? '1M' : '12M'
// ————— Function rounding OHLC values to tick precision.
f_ohlcRoundedToTick() =>
[math.round(open / syminfo.mintick) * syminfo.mintick, math.round(high / syminfo.mintick) * syminfo.mintick, math.round(low / syminfo.mintick) * syminfo.mintick, math.round(close / syminfo.mintick) * syminfo.mintick]
[o, h, l, c] = f_ohlcRoundedToTick()
// —————————— Bar up/dn states.
// ————— Returns true when a bar is considered to be an up bar.
f_barUp() =>
// Dependencies: `o` and `c`, which are the `open` and `close` values rounded to tick precision.
// Account for the normal "close > open" condition, but also for zero movement bars when their close is higher than previous close.
_barUp = c > o or c == o and c > nz(c[1], c)
_barUp
// ————— Returns true when a bar is considered to be a down bar.
f_barDn() =>
// Dependencies: `o` and `c`, which are the `open` and `close` values rounded to tick precision.
// Account for the normal "close < open" condition, but also for zero movement bars when their close is lower than previous close.
_barDn = c < o or c == o and c < nz(c[1], c)
_barDn
// ————— Function displays a label containing `_txt` at position `_y` in `_color` and at bar `_offset` from last bar. No background is used.
f_print(_txt, _y, _color, _offset) =>
// Keep track of minimum time between bars (chart's timeframe in ms) using `abs()` so this works with pre-1970 negative times.
var _tf = 10e15
_tf := math.min(math.abs(time - nz(time[1])), _tf)
// Calculate time offset for x position.
_t = int(time + _tf * _offset)
// Create the label on the first bar and only update it when on the dataset's last bar; it's more efficient.
var label _lbl = label.new(_t, _y, _txt, xloc.bar_time, yloc.price, #00000000, label.style_label_left, _color, size.large, text.align_left)
if barstate.islast
label.set_xy(_lbl, _t, _y)
label.set_text(_lbl, _txt)
label.set_textcolor(_lbl, _color)
// ————— Function appends the `_text` error message to the `_msg` string when `_error` is true.
f_checkError(_error, _msg, _text) =>
_error ? _msg + _text + '\n' : _msg
// ————— Function returns the farthest usable lookback, givne a user-selected number of periods.
f_optimalLookback(_barNosAtTfTransitions, _userPeriods) =>
// _barNosAtTfTransitions: Id of array containing bar nos of past TF transitions.
// _userPeriods : User-selected number of TF units to look back.
// Dependency: MAX_BARS_BACK
int _return = 0
// Loop from now to past TFs until we find a point back that's too far.
for _i = _userPeriods - 1 to 0 by 1
if bar_index - array.get(_barNosAtTfTransitions, _i) > MAX_BARS_BACK - 1
break
_return += 1
_return
_return
// ————— Function returning the average of past point-to-point volume, i.e., for the bars with the same offset from the beginning of the TF.
f_pastVolPtp(_msSinceStartOfTf, _timeAtFarthest, _periods) =>
// _msSinceStartOfTf: Bar's offset in milliseconds since the beginning of the TF.
// _timeAtFarthest : UTC time at the beginning of the lookback periods, so the farthest back we will be analyzing.
// _periods : number of past TFs units to average.
// Dependency: MAX_BARS_BACK
// Note that if bars with the same offset from the beginning of the TF are missing in the past TFs, the average will be calculated for a smaller number of TFs.
// Array holding the cumulative volume for each of the `_periods` TFs in our lookback,
// but only counting the bars within the current offset from the beginning of the current TF's beginning.
// We start with an empty array and add an element containing the cumulative volume for each TF in history we use.
float[] _volumes = array.new_float(0)
int _tfNo = 0
for _i = 1 to MAX_BARS_BACK - 2 by 1
if time[_i] < _timeAtFarthest or _tfNo >= _periods
// We are farther back than the beginning of the lookback, or the required qty of TFs has been processed; exit loop.
break
if _msSinceStartOfTf == nz(_msSinceStartOfTf[_i])
// A bar with the same time offset was found; add its volume.
_tfNo += 1
// Save the cumulated volume for the TF.
array.push(_volumes, volume[_i])
// ————— Return the avg of point-to-point volume.
float _return = nz(array.avg(_volumes))
_return
// ————— Function returning the average of cumulative past volume, i.e.,
// the total volume from the beginning of each TF in the past until the point in that TF
// corresponding to where the current bar is with regards to the beginning of the current TF.
f_pastVolCum(_msSinceStartOfTf, _timeAtFarthest, _periods, _timesAtTfTransitions) =>
// _msSinceStartOfTf : Bar's offset in milliseconds since the beginning of the TF.
// _timeAtFarthest : UTC time at the beginning of the lookback periods, so the farthest back we will be analyzing.
// _periods : number of past TFs units to average.
// _timesAtTfTransitions: Array id containing the time at TF transitions, so we know where to reset volume.
// Dependency: MAX_BARS_BACK
// Array holding the cumulative volume for each of the `_periods` TFs in our lookback,
// but only counting the bars within the current offset from the beginning of the current TF's beginning.
// We start with an empty array and add an element containing the cumulative volume for each TF in history we use.
float[] _volumes = array.new_float(0)
// Holds cumulative volume for the TF being cumulated in the loop.
float _cumVolTot = 0.
// Count of historical TFs we have analyzed.
int _tfNo = 1
// Non-capped no of user-selected periods.
var int _userSelectedNoOfPeriods = array.size(_timesAtTfTransitions) - 1
// Time at beginning of the TF the current bar belongs to; we will skip calcs until we're past that point.
float _timeAtStartOfCurrentTf = array.get(_timesAtTfTransitions, _userSelectedNoOfPeriods)
// Time at beginning of the TF the loop is calculating.
float _timeAtStartOfPastTf = array.get(_timesAtTfTransitions, _userSelectedNoOfPeriods - 1)
for _i = 1 to MAX_BARS_BACK - 2 by 1
float _time = time[_i]
if _time < _timeAtFarthest or _tfNo > _periods
// We are farther back than the beginning of the lookback, or the required qty of TFs has been processed; exit loop.
break
if _time < _timeAtStartOfCurrentTf
// We are past the current TF; we can calculate cumulative past volume.
if _time - _timeAtStartOfPastTf <= _msSinceStartOfTf
// The bar is in our scope; add its volume.
_cumVolTot += volume[_i]
if _time == _timeAtStartOfPastTf
// ————— We have reached the beginning of one of the TFs in our lookback; update/reset our numbers.
// Save the cumulated volume for the TF.
array.push(_volumes, _cumVolTot)
// Qty of processed TFs.
_tfNo += 1
// Get next TF's beginning time.
_timeAtStartOfPastTf := nz(array.get(_timesAtTfTransitions, math.max(0, _userSelectedNoOfPeriods - _tfNo)))
// Reset the TF's cum volume.
_cumVolTot := 0.
_cumVolTot
// ————— Return the avg of cumulative past volume.
float _return = nz(array.avg(_volumes))
_return
// ————— Function returning true when a high volatility condition is detected.
f_highVolatility() =>
// Dependencies : i_fastVolatility, i_slowVolatility
ta.atr(i_fastVolatility) > ta.atr(i_slowVolatility)
// }
// —————————— Calculations {
// ————— Determine timeframe from user selection.
var string tf = i_tfType == TF2 ? i_tf : f_tfAutoSteps(f_chartTfInMinutes())
// ————— Detect new TF.
// Logic for TOD TF units.
var int dailyTodTriggers = 0
float timeMark = timestamp(year, month, dayofmonth, i_hour, i_minute, 00)
float timeDailyClose = request.security(syminfo.tickerid, 'D', time_close, lookahead=barmerge.lookahead_on)
bool beginTime = time == timeMark
bool pastTime = time > timeMark
bool lastBarofDay = time_close == timeDailyClose
bool newday = ta.change(time('D'))
bool atOrPastBeginTime = false
if barstate.isfirst
atOrPastBeginTime := true
dailyTodTriggers := 1
dailyTodTriggers
else if newday
dailyTodTriggers := 0
dailyTodTriggers
if not beginTime[1] and beginTime or dailyTodTriggers == 0 and (pastTime or lastBarofDay)
// The user-defined TOD was reached, or it's the first time in the day that we are past it,
// or we are on the day's last bar and no suitable bar has been detected yet.
dailyTodTriggers += 1
atOrPastBeginTime := true
atOrPastBeginTime
// TF resets using user-selected mode.
bool tfReset = nz(i_tfType == TF3 and timeframe.isminutes ? atOrPastBeginTime : ta.change(time(tf)), true)
// ————— Manage TF transitions and cumulate volume of current TF.
// Array holding the time and bar_index at TF transitions.
var float[] timesAtTfTransitions = array.new_float(i_period + 1, time)
var int[] barNosAtTfTransitions = array.new_int(i_period + 1, 0)
// Cumulative volume of current TF.
var float cumVolume = 0.
// Time at point from where we calculate the time offset between the current bar and the beginning of the current TF.
var int timeAtStartOfTf = time
// Handle TF transition calcs.
if tfReset
// Maintain queues of the time and bar_index at which our last `i_period` TFs begin. We'll need this when calculating the cumulative past volume.
// The last element always contains the info for the current TF, which won't be used in calcs of past volume. If the period is capped, we won't be using all elements.
array.push(timesAtTfTransitions, time)
array.shift(timesAtTfTransitions)
array.push(barNosAtTfTransitions, bar_index)
array.shift(barNosAtTfTransitions)
// Reset cumulative volume from beginning of current TF.
cumVolume := volume
cumVolume
else
// Keep track of total volume from beginning of current TF.
cumVolume += volume
cumVolume
// ————— Get new time offsets.
// Cap period if user-selected one causes us to look back too far away.
int cappedPeriod = math.min(i_period, f_optimalLookback(barNosAtTfTransitions, i_period))
// Bar no at beginning of current TF.
int barAtStartOfTf = array.get(barNosAtTfTransitions, i_period)
// Save time on first bar.
var float timeAtBarZero = time
// Time at `cappedPeriod` * TF units back, which is the furthest in past we will look back.
float timeAtFarthestLookback = array.get(timesAtTfTransitions, i_period - cappedPeriod)
// Bar's offset in milliseconds since the beginning of the current TF.
float msSinceStartOfTf = time - array.get(timesAtTfTransitions, i_period)
// ————— Relative volume.
// Get past and current volume as per user-selected calc mode.
float pastVolume = i_calcMode == CM1 ? f_pastVolCum(msSinceStartOfTf, timeAtFarthestLookback, cappedPeriod, timesAtTfTransitions) : f_pastVolPtp(msSinceStartOfTf, timeAtFarthestLookback, cappedPeriod)
float currentVolume = i_calcMode == CM1 ? cumVolume : volume
float relVol = pastVolume == 0 ? 0. : currentVolume / pastVolume
// ————— Directional relvol avg.
float relVolDir = f_barUp() ? relVol : -relVol
float relVolAvgDir = ta.hma(relVolDir, i_avgPeriod)
// ————— Relvol avg.
float relVolAvg = ta.hma(relVol, i_avgPeriod)
// ————— Threshold
// Highs/Lows.
// Bar no at `cappedPeriod` TF units back.
int barAtFarthestLookback = array.get(barNosAtTfTransitions, i_period - cappedPeriod)
int hiLoLookback = i_thresholdMode == TM3 ? bar_index - barAtStartOfTf + 1 : i_thresholdMode == TM4 ? bar_index - barAtFarthestLookback + 1 : i_thresholdLookback
hiLoLookback := int(math.min(math.max(1, nz(hiLoLookback)), MAX_BARS_BACK - 1))
float hiLoHigh = ta.highest(relVol, hiLoLookback)
float hiLoLow = ta.lowest(relVol, hiLoLookback)
// Stdev.
float relVolStDev = ta.stdev(relVol, i_thresholdLookback)
float relVolSma = ta.sma(relVol, i_thresholdLookback)
float relVolStDevHigh = relVolSma + relVolStDev * i_thresholdStdevFac
float relVolStDevLow = math.max(0, relVolSma - relVolStDev * i_thresholdStdevFac)
[thresholdHi, thresholdLo] = if i_thresholdMode == TM1
[i_thresholdFixedVal, i_thresholdFixedVal]
else if i_thresholdMode == TM2
[relVolStDevHigh, relVolStDevLow]
else if i_thresholdMode == TM3 or i_thresholdMode == TM4 or i_thresholdMode == TM5
[hiLoHigh, hiLoLow]
// ————— Error conditions
// Critical errors causing plots to be hidden.
bool chartTfIsTooLow = f_chartTfInMinutes() > f_tfInMinutes(tf)
bool noRelVol = na(relVol)
bool noTfUnits = barAtStartOfTf == 0 and bar_index > MAX_BARS_BACK
bool noVolume = na(volume)
bool dontPlot = chartTfIsTooLow or noRelVol or noTfUnits or noVolume
// Non-critical errors.
bool lookbackIsTooBig = i_period != cappedPeriod
bool cantUseTod = i_tfType == TF3 and not timeframe.isminutes
// }
//RVOL Background Color Plot
color c_pastVolMark = relVol > 1 ? i_c_bullBright : i_c_bearBright
bgcolor(color.new(c_pastVolMark,50), title = 'RVOL Background Fill')
|
Macro EMA Correlation | https://www.tradingview.com/script/ttpdJKlO-Macro-EMA-Correlation/ | F_rank_01 | https://www.tradingview.com/u/F_rank_01/ | 60 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © castonguayfrancois9
//@version=5
indicator("Macro EMA Correlation", overlay = false)
// Time frame selection
tf = timeframe.period
// Pair selection
i_1 = input.bool(title = "BTC:USDT", defval = true, group = "Enablers")
i_2 = input.bool(title = "ETH:USDT", defval = true, group = "Enablers")
i_3 = input.bool(title = "TVC:GOLD", defval = true, group = "Enablers")
i_4 = input.bool(title = "TOTAL2", defval = true, group = "Enablers")
i_5 = input.bool(title = "TVC:US10Y", defval = true, group = "Enablers")
i_6 = input.bool(title = "USDT.D", defval = true, group = "Enablers")
i_7 = input.bool(title = "USD:JPY", defval = true, group = "Enablers")
// request.security fonction for each pair to get them on the same script and compare them with percentage variation
btcClose = request.security("BINANCE:BTCUSDT", tf, close)
btcEma50 = request.security("BINANCE:BTCUSDT", tf, ta.ema(btcClose, 100))
btcEmax = (btcClose/btcEma50)
colorA = color(na)
if i_1
colorA := color.green
else
colorA := color(na)
plot(ta.ema(btcEmax,100), color=colorA, linewidth =2)
ethClose = request.security("BINANCE:ETHUSDT", tf, close)
ethEma50 = request.security("BINANCE:ETHUSDT", tf, ta.ema(close, 100))
ethEmax = (ethClose/ethEma50)
colorB = color(na)
if i_2
colorB := color.blue
else
colorB := color(na)
plot(ta.ema(ethEmax,100), color=colorB)
paxClose = request.security("TVC:GOLD", tf, close)
paxEma50 = request.security("TVC:GOLD", tf, ta.ema(paxClose, 100))
paxEmax = (paxClose/paxEma50)
colorC = color(na)
if i_3
colorC := color.yellow
else
colorC := color(na)
plot(ta.ema(paxEmax,100), color=colorC, linewidth =2)
totalClose = request.security("CRYPTOCAP:TOTAL2", tf, close)
totalEma50 = request.security("CRYPTOCAP:TOTAL2", tf, ta.ema(totalClose, 100))
totalEmax = (totalClose/totalEma50)
colorD = color(na)
if i_4
colorD := color.fuchsia
else
colorD := color(na)
plot(ta.ema(totalEmax,100), color = colorD)
yieldClose = request.security("TVC:US10Y", tf, close)
yieldEma50 = request.security("TVC:US10Y", tf, ta.ema(close, 100))
yieldEmax = (yieldClose/yieldEma50)
colorE = color(na)
if i_5
colorE := color.gray
else
colorE := color(na)
plot(ta.ema(yieldEmax,100), color = colorE)
usdClose = request.security("CRYPTOCAP:USDT.D", tf, close)
usdDEma50 = request.security("CRYPTOCAP:USDT.D", tf, ta.ema(usdClose, 100))
usdDEmax = (usdClose/usdDEma50)
colorF = color(na)
if i_6
colorF := color.lime
else
colorF := color(na)
plot(ta.ema(usdDEmax,100), color = colorF)
yenClose = request.security("FX:USDJPY", tf, close)
yenEma50 = request.security("FX:USDJPY", tf, ta.ema(yenClose, 100))
yenEmax = (yenClose/yenEma50)
colorG = color(na)
if i_7
colorG := color.red
else
colorG := color(na)
plot(ta.ema(yenEmax,100), color = colorG, linewidth =2)
// Table indicating wich colored ema line correspond to wich asset
var table perfTable = table.new(position.bottom_right, 1, 7, border_width = 1)
if i_1
table.cell(perfTable, 0, 0, "BTC:USDT", bgcolor = colorA, text_color = color.new(color.black, 0), width = 12, height = 9, text_size = size.large)
if i_2
table.cell(perfTable, 0, 1, "ETH:USDT", bgcolor = colorB, text_color = color.new(color.black, 0), width = 12, height = 9, text_size = size.large)
if i_3
table.cell(perfTable, 0, 2, "TVC:GOLD", bgcolor = colorC, text_color = color.new(color.black, 0), width = 12, height = 9, text_size = size.large)
if i_4
table.cell(perfTable, 0, 3, "TOTAL2", bgcolor = colorD, text_color = color.new(color.black, 0), width = 12, height = 9, text_size = size.large)
if i_5
table.cell(perfTable, 0, 4, "TVC:US10Y", bgcolor = colorE, text_color = color.new(color.black, 0), width = 12, height = 9, text_size = size.large)
if i_6
table.cell(perfTable, 0, 5, "USDT.D", bgcolor = colorF, text_color = color.new(color.black, 0), width = 12, height = 9, text_size = size.large)
if i_7
table.cell(perfTable, 0, 6, "USD:JPY", bgcolor = colorG, text_color = color.new(color.black, 0), width = 12, height = 9, text_size = size.large) |
Wick/ Long / Short Monitor | https://www.tradingview.com/script/SOBzwfox-Wick-Long-Short-Monitor/ | bhavishya1312 | https://www.tradingview.com/u/bhavishya1312/ | 41 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bhavishya1312
//@version=5
indicator("Wick/ Long / Short Monitor", overlay=true)
pricechange = input.int(14, "change", confirm=true)
up14 = (high - open < pricechange)
down14 = (open - low < pricechange)
plotchar(up14, "up14", "*", location.belowbar, color.red, size=size.tiny)
plotchar(down14, "down14", "*", location.abovebar, color.red, size=size.tiny)
|
Heikin Ashi Count | https://www.tradingview.com/script/FnKEddhS/ | Julien-PH | https://www.tradingview.com/u/Julien-PH/ | 62 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Julien-PH
//@version=5
indicator(title="Heikin Ashi Count", shorttitle="HA Count", overlay=false)
// Input
timeframe = input.timeframe(defval="", title="Timeframe" , group="Heikin Ashi Settings")
lengthHAC = input.float(defval=1.15, minval=1, step=0.01, title="Counting length", group="Heikin Ashi Settings")
lengthDiv = input.float(defval=100 , minval=3, step=1 , title="Number of bars where we look for divergences" , group="Divergence Settings")
confirmedDiv = input.bool(true, title="Wait confirmation ?", tooltip="Authorize repainting, confirmation periode = 1", group="Divergence Settings")
// Method
isPL(src=close,left=3,right=0) =>
ta.pivotlow(src,left,right)
isPH(src=close,left=3,right=0) =>
ta.pivothigh(src,left,right)
haCountMethod(length) =>
hac = 50.0
hac := if barstate.isfirst
50
else if close > open
hac[1] / length + (100 * ((length - 1)/length))
else if close < open
hac[1] / length
else
hac[1]
isInBullDivergence(indicator,price=close,length=100,confirm=true) =>
isDiv = 0
confirmOffset = confirm ? 1 : 0
LL = indicator[0+confirmOffset]
if (isPL(indicator,right=confirmOffset) and indicator < 50)
for i = 1+confirmOffset to length+confirmOffset
if (LL > indicator[i] and indicator[i] < indicator[i+1])
LL := indicator[i]
if (price[i] > price[confirmOffset] and ta.lowestbars(price,i) < 3)
isDiv := i
isDiv
isInBearDivergence(indicator,price=close,length=100,confirm=true) =>
isDiv = 0
confirmOffset = confirm ? 1 : 0
HH = indicator[0+confirmOffset]
if (isPH(indicator,right=confirmOffset) and indicator > 50)
for i = 1+confirmOffset to length+confirmOffset
if (HH < indicator[i] and indicator[i] > indicator[i+1])
HH := indicator[i]
if (price[i] < price[confirmOffset] and ta.highestbars(price,i) < 3)
isDiv := i
isDiv
findDivergence(indicator,price=close,length=100,confirm=true) =>
bullDiv = isInBullDivergence(indicator,price,length,confirm)
bearDiv = isInBearDivergence(indicator,price,length,confirm)
[bullDiv,bearDiv]
// Heikin Ashi Count and divergences
hac = request.security(ticker.heikinashi(syminfo.tickerid), timeframe, haCountMethod(lengthHAC))
[bullDiv,bearDiv] = request.security( syminfo.tickerid , timeframe, findDivergence(hac,close,lengthDiv,confirmedDiv))
// Plot
bandTop = hline(100 , color=color.new(color.gray,0 ), linestyle=hline.style_solid)
bandMid = hline(50 , color=color.new(color.gray,50), linestyle=hline.style_solid)
bandBottom = hline(0 , color=color.new(color.gray,0 ), linestyle=hline.style_solid)
display_divs = input.bool(true,title="Display divergence signals ?" , group="Plot")
display_divline = input.bool(true,title="Display divergence lines ?" , group="Plot")
locOption = input.string(defval='Absolute', title='Location of the divergence signals', options=['Absolute','Value'], group='Plot')
colorHAC = input.color(color.new(color.orange,25), title="Heinkin Ashi Count color" , group="Plot")
colorBullDiv = input.color(color.new(color.green ,30), title="Bull Divergence color" , group="Plot")
colorBearDiv = input.color(color.new(color.red ,30), title="Bear Divergence color" , group="Plot")
confirmationOffset = confirmedDiv ? 1 : 0
plot(hac, title="HAC", color=colorHAC, linewidth=1, histbase=50, style=plot.style_area)
plotchar(display_divs and bullDiv ? (locOption == 'Value' ? hac[confirmationOffset] : 0 ) : na, title = 'Bull Divergence signal', char='•', color = colorBullDiv, location = location.absolute, size = size.small, offset = -confirmationOffset)
plotchar(display_divs and bearDiv ? (locOption == 'Value' ? hac[confirmationOffset] : 100) : na, title = 'Bear Divergence signal', char='•', color = colorBearDiv, location = location.absolute, size = size.small, offset = -confirmationOffset)
if display_divline and bullDiv>0
line.new(x1=bar_index-bullDiv, y1=math.round(hac[bullDiv]), x2=bar_index-confirmationOffset, y2=math.round(hac[confirmationOffset]), color=colorBullDiv, width = 1)
if display_divline and bearDiv>0
line.new(x1=bar_index-bearDiv, y1=math.round(hac[bearDiv]), x2=bar_index-confirmationOffset, y2=math.round(hac[confirmationOffset]), color=colorBearDiv, width = 1)
|
S2BU2 MACD Growthpercentages | https://www.tradingview.com/script/iQUjqM9r/ | sucks2bu2 | https://www.tradingview.com/u/sucks2bu2/ | 22 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sucks2bu2
// feel free to use this code but do not stick a pricetag on it and sell it under a different name by itself ...
//@version=5
indicator(title='S2BU2 MACD Growthpercentages', shorttitle='S2BU2 MC%', timeframe='', timeframe_gaps=true)
//=========================================presets=========================================//
//Set MA_lengths
periodFast = input.int(title='Fast Length', defval=12, minval=1)
periodSlow = input.int(title='Slow Length', defval=26, minval = 1)
periodSignal = input.int(title='Signal Smoothing', minval = 1, maxval = 50, defval = 9)
//set data_source
src = input(title='Source', defval=close)
//set histogram colors
greaterHist = input(title = 'Greater', group = 'style', defval = #1d6ff2)
lowerHist = input(title = 'Lower', group = 'style', defval = #7aa7f0)
//===================================calculate base data===================================//
// Calculate macd, signal, fast and slow MA
float fastMA = ta.ema(src, periodFast)
float slowMA = ta.ema(src, periodSlow)
float macd = fastMA - slowMA
float signal = ta.ema(macd, periodSignal)
//==================================calculate helper vars==================================//
//check mathematical signs of macd and signal
bool isSignalPositive = signal > 0
bool isMacdPositive = macd > 0
//determine relative pos between signal and macd
bool isMacdGreater = macd > signal
//========================================chartData========================================//
//calculate percentage based on position and sign of macd and signal
//signal + macd above 0-line, macd > signal
float hist = if (isSignalPositive == true and isMacdPositive == true and isMacdGreater == true)
signal/macd
else
//signal + macd above 0-line, macd < signal
if (isSignalPositive == true and isMacdPositive == true and isMacdGreater == false)
macd/signal
else
//signal + macd below 0-line, macd > signal
if (isSignalPositive == false and isMacdPositive == false and isMacdGreater == true)
//mirror macd + signal above 0-line, offset macd further above by new signal delta relative to 0-line
(math.abs(signal)/(math.abs(macd)+2*math.abs(signal)))
else
//signal + macd below 0-line, macd < signal
if (isSignalPositive == false and isMacdPositive == false and isMacdGreater == false)
//mirror macd + signal above 0-line, offset signal further above by new macd delta relative to 0-line
(math.abs(macd)/(math.abs(signal) + 2*math.abs(macd)))
else
//signal below 0-line, macd above 0-line
if (isSignalPositive == false and isMacdPositive == true)
//mirror signal above 0-line, offset macd further above by new signal delta relative to 0-line
(math.abs(signal)/(macd + 2*math.abs(signal)))
else
//signal above 0-line, macd below 0-line
if (isSignalPositive == true and isMacdPositive == false)
//mirror macd above 0-line, offset signal further above by new macd delta relative to 0-line
(math.abs(macd)/(signal + 2*math.abs(macd)))
//========================================misc========================================//
//select bar color depending on increased/decreased size of bar
colorHist = nz(hist[1]) < hist ? greaterHist:lowerHist
//plot bars with 100 multiplier for visibility
plot(hist*100, title='Bars', style=plot.style_columns, color=colorHist)
|
jma + dwma macd | https://www.tradingview.com/script/mSMh5nc2-jma-dwma-macd/ | multigrain | https://www.tradingview.com/u/multigrain/ | 40 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © multigrain
// @version=5
indicator('jma + dwma macd by multigrain', 'jma + dwma macd ', overlay=false)
//NAME TYPE DEFVAL TITLE MIN MAX GROUP
longs = input.bool (true, 'Enable longs?')
shorts = input.bool (false, 'Enable shorts?')
jmaSrc = input.source (close, 'JMA Source', group='JMA')
jmaLen = input.int (7, 'JMA Length', 0, 100, group='JMA')
jmaPhs = input.int (50, 'JMA Phase', -100, 100, group='JMA')
jmaPwr = input.float (1, 'JMA Power', 0.1, group='JMA')
dwmaSrc = input.source (close, 'DWMA Source', group='DWMA')
dwmaLen = input.int (10, 'DWMA Length', 1, 100, group='DWMA')
// Normalize
f_normalize(_src, _min, _max) =>
var _historicMin = 10e10
var _historicMax = -10e10
_historicMin := math.min(nz(_src, _historicMin), _historicMin)
_historicMax := math.max(nz(_src, _historicMax), _historicMax)
_min + (_max - _min) * (_src - _historicMin) / math.max(_historicMax - _historicMin, 10e-10)
// Jurik Moving Average
f_jma(_src, _length, _phase, _power) =>
phaseRatio = _phase < -100 ? 0.5 : _phase > 100 ? 2.5 : _phase / 100 + 1.5
beta = 0.45 * (_length - 1) / (0.45 * (_length - 1) + 2)
alpha = math.pow(beta, _power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * _src + alpha * nz(e0[1])
e1 = 0.0
e1 := (_src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
jma
// Double Weighted Moving Average
f_dwma(_src, _length) =>
ta.wma(ta.wma(_src, _length), _length)
// Calculations
jma = f_jma (jmaSrc, jmaLen, jmaPhs, jmaPwr)
dwma = f_dwma (dwmaSrc, dwmaLen)
osc = f_normalize (jma - dwma, -100, 100)
long = ta.crossover (jma, dwma)
long_tp = ta.pivothigh (jma, 1, 1) and jma > dwma
short_tp = ta.pivotlow (jma, 1, 1) and jma < dwma
short = ta.crossunder (jma, dwma)
// Colors
green = #0F7173
red = #F05D5E
tan = #D8A47F
grey = #939FA6
white = #FFFFFF
fillColor = osc > 0 ? green : red
// Plots
plot (osc, 'JMA/DWMA', fillColor, 1, plot.style_area)
plot (longs and long ? -107 : na, 'Long Signal', green, 2, plot.style_circles)
plot (longs and long_tp ? -107 : na, 'Long Take Profit', tan, 2, plot.style_circles)
plot (shorts and short ? 107 : na, 'Short Signal', red, 2, plot.style_circles)
plot (shorts and short_tp ? 107 : na, 'Short Take Profit', tan, 2, plot.style_circles)
// Alerts
alertcondition (longs ? long : na, "Long", "Long", alert.freq_once_per_bar_close)
alertcondition (longs ? long_tp : na, "Long Take Profit", "Long Take Profit", alert.freq_once_per_bar_close)
alertcondition (shorts ? short : na, "Short", "Short", alert.freq_once_per_bar_close)
alertcondition (shorts ? short_tp : na, "Short Take Profit", "Short Take Profit", alert.freq_once_per_bar_close)
|
OnChart Stochastic | https://www.tradingview.com/script/RoAwu3kJ-onchart-stochastic/ | Shuttle_Club | https://www.tradingview.com/u/Shuttle_Club/ | 79 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Shuttle_Club
//@version=5
indicator(title='OnChart Stochastic', overlay=true)
periodK = input.int(26, title='%K Leng', minval=1, inline='s1', group='===== STOCHASTIC OSCILLATOR =====')
smoothK = input.int(5, title='%K', minval=1, inline='s1', group='===== STOCHASTIC OSCILLATOR =====')
periodD = input.int(5, title='%D', minval=1, inline='s1', group='===== STOCHASTIC OSCILLATOR =====', tooltip='Parameters of a standard stochastic oscillator.\n\nПараметры стандартного стохастического осциллятора.')
MAtype = input.string(defval='SMA',title='MA type', options=['SMA','EMA','WMA','RMA'], inline='s2', group='===== MA RANGE FOR STOCHASTIC =====')
MAperiod = input.int(20, title='> >', minval=1, inline='s2', group='===== MA RANGE FOR STOCHASTIC =====')
MAsrc = input.source(close, title='>>', inline='s2', group='===== MA RANGE FOR STOCHASTIC =====', tooltip='Parameters of the middle price line, around which the upper and lower boundaries of the "stochastic" are built.\n\nПараметры средней ценовой линии, вокруг которой выстраивается верхняя и нижняя границы "стохастика".')
ATRperiod = input.int(20, title='ATR Len', minval=1, inline='s3', group='===== MA RANGE FOR STOCHASTIC =====')
up_level = input.int(80, title='UP', minval=1, inline='s3', group='===== MA RANGE FOR STOCHASTIC =====')
dn_level = input.int(20, title='DN', minval=1, inline='s3', group='===== MA RANGE FOR STOCHASTIC =====', tooltip='The period of daily volatility for building the range in which the "stochastic" moves.\n\nПериод дневной волатильности для построения рейнджа, в котором двигается "стохастик".')
showrange = input.bool(true,title='Show range ', inline='s4', group='===== MA RANGE FOR STOCHASTIC =====')
showcross = input.bool(false,title='Show cross', inline='s4', group='===== MA RANGE FOR STOCHASTIC =====')
Dhigh = request.security(syminfo.tickerid,'D',high[1])
Dlow = request.security(syminfo.tickerid,'D',low[1])
Dclose = request.security(syminfo.tickerid,'D',close[1])
dTR = float(0)
for i = 0 to ATRperiod-1
dTR := dTR+math.max(math.abs(Dhigh[i]-Dlow[i]),math.max(math.abs(Dhigh[i]-Dclose[i+1]),math.abs(Dlow[i]-Dclose[i+1])))
avgRange = dTR/ATRperiod
float maValue = switch MAtype
'SMA' => ta.sma(MAsrc,MAperiod)
'EMA' => ta.ema(MAsrc,MAperiod)
'WMA' => ta.wma(MAsrc,MAperiod)
'RMA' => ta.rma(MAsrc,MAperiod)
=> ta.sma(MAsrc,MAperiod)
stochValue = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
signalValue = ta.sma(stochValue, periodD)
up_line = maValue+(avgRange*(up_level-50)/100)
dn_line = maValue-(avgRange*(50-dn_level)/100)
k_stoch = maValue+(stochValue-50)/100*avgRange
d_stoch = maValue+(signalValue-50)/100*avgRange
plot(showrange?up_line:na,title='High band')
plot(showrange?maValue:na,title='MA_center')
plot(showrange?dn_line:na,title='Low band')
plot(k_stoch,title='%K',color=color.new(#12b71a,0),linewidth=2)
plot(d_stoch,title='%D',color=color.new(#f41410,0),linewidth=2)
up = ta.crossover(k_stoch,d_stoch) and (k_stoch+d_stoch)/2<dn_line
dn = ta.crossunder(k_stoch,d_stoch) and (k_stoch+d_stoch)/2>up_line
plotshape(up and showcross, title='up cross', text='', textcolor=#08d510, style=shape.triangleup, size=size.tiny, location=location.belowbar, color=color.new(#12b71a,0))
plotshape(dn and showcross, title='dn cross', text='', textcolor=#da0a0a, style=shape.triangledown, size=size.tiny, location=location.abovebar, color=color.new(#f41410,0))
alertcondition(up, "UP cross", "Stochastic up-cross")
alertcondition(dn, "DN cross", "Stochastic dn-cross")
|
Session Levels | https://www.tradingview.com/script/0CyOYQdf-Session-Levels/ | ajithcpas | https://www.tradingview.com/u/ajithcpas/ | 251 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ajithcpas
//
// This indicator plots important session (intraday) levels for the day.
// It plots high and low of previous day, week, month, 52 week and all time.
// Also plots the vix range which shows the daily expected trading range of the instrument.
// These levels acts as important support/resistance for the day.
//
// For example, if price closes above previous day, week, or month high/low
// it indicates bullish sentiment and vice versa for bearish.
//
// Vix Range plots top and bottom line for expected trading range for the day.
// It is calculated based on the volatility index selected (NSE:India VIX is used by default).
// Checkout this link for vix range indicator: https://in.tradingview.com/script/DnCO9jly-VIX-Range/
//
// ATR Range plots high, low line for expected trading range for the day based on ATR.
// Percentage Range plots high, low line based on given percentage input from the previous day close.
//@version=5
indicator("Session Levels", overlay=true)
// Inputs
show_labels = input.bool(defval=true, title="Show Labels", group="General")
show_prices = input.bool(defval=true, title="Show Prices", group="General")
extend_option = input.string(defval="None", title="Extend Line", options=["None", "Left", "Right", "Both"], group="General")
show_day_open = input.bool(defval=true, title="Show Current Day", group="Session Open")
show_week_open = input.bool(defval=true, title="Show Current Week", group="Session Open")
show_month_open = input.bool(defval=true, title="Show Current Month", group="Session Open")
session_open_color = input.color(defval=color.purple, title="Line Color", group="Session Open")
session_open_line_style = input.string(defval="Dashed", title="Line Style", options=["Solid", "Dotted", "Dashed"], group="Session Open")
show_day = input.bool(true, title="Show Previous Day", group="Session High Low")
show_n_days = input.bool(true, title="Show Previous N Days", inline="N Days", group="Session High Low")
n_days_input = input.int(5, minval=2, step=1, title="", inline="N Days", group="Session High Low")
show_week = input.bool(true, title="Show Previous Week", group="Session High Low")
show_month = input.bool(true, title="Show Previous Month", group="Session High Low")
show_52_week = input.bool(true, title="Show 52 Week", group="Session High Low")
show_all_time = input.bool(true, title="Show All Time", group="Session High Low")
session_high_color = input.color(defval=color.green, title="High Line Color", group="Session High Low")
session_low_color = input.color(defval=color.red, title="Low Line Color", group="Session High Low")
session_hl_line_style = input.string(defval="Solid", title="Line Style", options=["Solid", "Dotted", "Dashed"], group="Session High Low")
show_vix = input.bool(true, title="Show Vix Range", group="Vix Range", tooltip="Vix Range plots top and bottom line for expected trading range for the day. It is calculated based on the volatility index selected.")
vol_symbol = input.symbol("NSE:INDIAVIX", "Volatility Index", group="Vix Range")
vix_color = input.color(defval=color.blue, title="Line Color", group="Vix Range")
vix_line_style = input.string(defval="Solid", title="Line Style", options=["Solid", "Dotted", "Dashed"], group="Vix Range")
show_atr = input.bool(true, title="Show ATR Range", group="ATR Range")
atr_len = input.int(14, minval=1, title="ATR Length", group="ATR Range")
atr_high_color = input.color(defval=color.green, title="High Line Color", group="ATR Range")
atr_low_color = input.color(defval=color.red, title="Low Line Color", group="ATR Range")
atr_hl_line_style = input.string(defval="Solid", title="Line Style", options=["Solid", "Dotted", "Dashed"], group="ATR Range")
show_percentage = input.bool(true, title="Show Percentage Range", group="Percentage Range", tooltip="Plots range based on given percentage from previous day close.")
percentage_input = input.float(1, minval=0.05, step=0.05, title="Percentage", group="Percentage Range")
percentage_high_color = input.color(defval=color.green, title="High Line Color", group="Percentage Range")
percentage_low_color = input.color(defval=color.red, title="Low Line Color", group="Percentage Range")
percentage_hl_line_style = input.string(defval="Solid", title="Line Style", options=["Solid", "Dotted", "Dashed"], group="Percentage Range")
// Functions
getAllTimeHigh() =>
h = 0.0
h := bar_index == 0 ? high : high > h[1] ? high : h[1]
getAllTimeLow() =>
l = 0.0
l := bar_index == 0 ? low : low < l[1] ? low : l[1]
get_resolution() =>
resolution = "M"
if timeframe.isintraday
resolution := timeframe.multiplier <= 15 ? "D" : "W"
else if timeframe.isweekly or timeframe.ismonthly
resolution := "12M"
resolution
drawLine(price, _text, lineColor, lineStyle, lineExtend, showLabels, showPrices) =>
fLineStyle = switch lineStyle
"Dotted" => line.style_dotted
"Dashed" => line.style_dashed
=> line.style_solid
fLineExtend = switch lineExtend
"Left" => extend.left
"Right" => extend.right
"Both" => extend.both
=> extend.none
endOfDay = time_tradingday + 105000000 // used for positioning line, labels
aLine = line.new(x1=time_tradingday, y1=price, x2=endOfDay, y2=price, xloc=xloc.bar_time, color=lineColor, style=fLineStyle, extend=fLineExtend)
line.delete(aLine[1])
fText = _text
if showLabels and showPrices
fText := str.format("{0} - {1}", _text, math.round_to_mintick(price))
else if showPrices
fText := str.format("{0}", math.round_to_mintick(price))
if showLabels or showPrices
aLabel = label.new(endOfDay, price, xloc=xloc.bar_time, text=str.format(" {0}", fText), textcolor=lineColor, style=label.style_none)
label.delete(aLabel[1])
drawOpen(show, resolution, labelText, lineColor, lineStyle, lineExtend, showLabels, showPrices) =>
_open = request.security(syminfo.tickerid, resolution, open)
if show
drawLine(_open, labelText, lineColor, lineStyle, lineExtend, showLabels, showPrices)
drawHighLow(show, resolution, labelTextHigh, labelTextLow, highColor, lowColor, lineStyle, lineExtend, showLabels, showPrices) =>
[_high, _low] = request.security(syminfo.tickerid, resolution, [high[1], low[1]])
if show and not na(_high)
drawLine(_high, labelTextHigh, highColor, lineStyle, lineExtend, showLabels, showPrices)
drawLine(_low, labelTextLow, lowColor, lineStyle, lineExtend, showLabels, showPrices)
drawVixRange(show, resolution, lineColor, lineStyle, lineExtend, showLabels, showPrices) =>
prevClose = request.security(syminfo.tickerid, resolution, close[1])
vixClose = request.security(vol_symbol, resolution, close[1])
if show
expectedRange = resolution == "D" ? (prevClose * (vixClose / 100) / 16) : resolution == "W" ? (prevClose * (vixClose / 100) * 0.1386) : (prevClose * (vixClose / 100) * 0.2773)
drawLine(prevClose + expectedRange, "Vix Top", lineColor, lineStyle, lineExtend, showLabels, showPrices)
drawLine(prevClose - expectedRange, "Vix Bottom", lineColor, lineStyle, lineExtend, showLabels, showPrices)
// Session Open
drawOpen(show_day_open, "D", " Day Open", session_open_color, session_open_line_style, extend_option, show_labels, show_prices)
drawOpen(show_week_open, "W", " Week Open", session_open_color, session_open_line_style, extend_option, show_labels, show_prices)
drawOpen(show_month_open, "M", " Month Open", session_open_color, session_open_line_style, extend_option, show_labels, show_prices)
// Session High Low
drawHighLow(show_day, "D", "PDH", "PDL", session_high_color, session_low_color, session_hl_line_style, extend_option, show_labels, show_prices)
drawHighLow(show_week, "W", "PWH", "PWL", session_high_color, session_low_color, session_hl_line_style, extend_option, show_labels, show_prices)
drawHighLow(show_month, "M", "PMH", "PML", session_high_color, session_low_color, session_hl_line_style, extend_option, show_labels, show_prices)
// N Days High Low
n_days_high = request.security(syminfo.tickerid, "D", ta.highest(high[1], n_days_input))
n_days_low = request.security(syminfo.tickerid, "D", ta.lowest(low[1], n_days_input))
if show_n_days and not na(n_days_high)
drawLine(n_days_high, "PnDH", session_high_color, session_hl_line_style, extend_option, show_labels, show_prices)
drawLine(n_days_low, "PnDL", session_low_color, session_hl_line_style, extend_option, show_labels, show_prices)
// 52 Week High Low
_52_week_high = request.security(syminfo.tickerid, "W", ta.highest(high[1], 52))
_52_week_low = request.security(syminfo.tickerid, "W", ta.lowest(low[1], 52))
if show_52_week and not na(_52_week_high)
drawLine(_52_week_high, "52WH", session_high_color, session_hl_line_style, extend_option, show_labels, show_prices)
drawLine(_52_week_low, "52WL", session_low_color, session_hl_line_style, extend_option, show_labels, show_prices)
// All Time High Low
ath = request.security(syminfo.tickerid, "M", getAllTimeHigh())
atl = request.security(syminfo.tickerid, "M", getAllTimeLow())
if show_all_time
drawLine(ath, "ATH", session_high_color, session_hl_line_style, extend_option, show_labels, show_prices)
drawLine(atl, "ATL", session_low_color, session_hl_line_style, extend_option, show_labels, show_prices)
resolution = get_resolution()
// Vix Range
drawVixRange(show_vix, resolution, vix_color, vix_line_style, extend_option, show_labels, show_prices)
// ATR Range
prevDayATR = request.security(syminfo.tickerid, resolution, ta.atr(atr_len)[1])
prevDayClose = request.security(syminfo.tickerid, resolution, close[1])
if show_atr
drawLine(prevDayClose + prevDayATR, "ATR High", atr_high_color, atr_hl_line_style, extend_option, show_labels, show_prices)
drawLine(prevDayClose - prevDayATR, "ATR Low", atr_low_color, atr_hl_line_style, extend_option, show_labels, show_prices)
// Percentage Range
if show_percentage
percentRange = prevDayClose * percentage_input / 100
drawLine(prevDayClose + percentRange, "Percentage High", percentage_high_color, percentage_hl_line_style, extend_option, show_labels, show_prices)
drawLine(prevDayClose - percentRange, "Percentage Low", percentage_low_color, percentage_hl_line_style, extend_option, show_labels, show_prices) |
baguette by multigrain | https://www.tradingview.com/script/fyt6Xv7T-baguette-by-multigrain/ | multigrain | https://www.tradingview.com/u/multigrain/ | 340 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © multigrain
//@version=5
indicator('baguette by multigrain', 'baguette', overlay = true)
//NAME TYPE DEFVAL TITLE MIN MAX GROUP
jmaSrc = input.source (hlc3, 'JMA Source', group='JMA')
jmaLen = input.int (144, 'JMA Length', group='JMA')
jmaPhs = input.int (34, 'JMA Phase', -100, 100, group='JMA')
atrLen = input.int (34, 'ATR Length', group='Envelope')
atrMul = input.float (4.5, 'ATR Multiplier', group='Envelope')
// Jurik Moving Average
// credit to @gorx1
f_jma(_src, _length, _phase) =>
lower_band = _src
upper_band = _src
del2 = math.abs(_src - lower_band[1])
del1 = math.abs(_src - upper_band[1])
vola = del1 == del2 ? 0 : math.max(del1, del2)
vola_sum = 0.0
vola_sum := nz(vola_sum[1]) + 0.1 * (vola - vola[10])
avg_len = 65
y = bar_index + 1
avg_vola = 0.0
avg_vola := if y <= avg_len + 1
nz(avg_vola[1]) + 2.0 * (vola_sum - nz(avg_vola[1])) / (avg_len + 1)
else
ta.sma(vola_sum, avg_len)
len = 0.5 * (_length - 1)
len1 = math.max(math.log(math.sqrt(len)) / math.log(2) + 2, 0)
pow1 = math.max(len1 - 2, 0.5)
r_vola = avg_vola > 0 ? vola / avg_vola : 0
r_vola := if r_vola > math.pow(len1, 1 / pow1)
math.pow(len1, 1 / pow1)
else if r_vola < 1
1
else
r_vola
pow2 = math.pow(r_vola, pow1)
len2 = math.sqrt(len) * len1
bet = len2 / (len2 + 1)
kv = math.pow(bet, math.sqrt(pow2))
lower_band := y == 1 ? _src : del2 < 0 ? _src : _src - kv * del2
upper_band := y == 1 ? _src : del1 < 0 ? _src : _src + kv * del1
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
pr = _phase < -100 ? 0.5 : _phase > 100 ? 2.5 : _phase / 100 + 1.5
alpha = math.pow(beta, pow2)
ma1 = 0.0
det0 = 0.0
jma = 0.0
det1 = 0.0
ma1 := (1 - alpha) * _src + alpha * nz(ma1[1])
det0 := (_src - ma1) * (1 - beta) + beta * nz(det0[1])
ma2 = ma1 + pr * det0
det1 := (ma2 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(det1[1])
jma := nz(jma[1]) + det1
jma
// Jurik Moving Average Envelope
// credit to @redktrader
f_atrEnv(_src, _length, _multiplier) =>
atr = ta.atr(_length) * _multiplier
atr_us = atr
atr_ls = atr
atr_us := ta.change(_src) != 0 ? atr : atr_us[1]
atr_ls := ta.change(_src) != 0 ? atr : atr_ls[1]
atr_upper = _src + atr_us
atr_lower = _src - atr_ls
[atr_upper, atr_lower]
// Calculations
j = f_jma(jmaSrc, jmaLen, jmaPhs)
[j_up, j_low] = f_atrEnv(j, atrLen, atrMul)
long = ta.crossover(hlc3, j_low) ? close : na
short = ta.crossunder(hlc3, j_up) ? close : na
// Colors
green = #0F7173
red = #F05D5E
tan = #D8A47F
white = #FFFFFF
// Plots
plot (j, 'JMA Centerline', tan, display=display.none)
plot (j_up, 'ATR Upper', green)
plot (j_low, 'ATR Lower', red)
plotshape (long, 'Long', shape.labelup, location.belowbar, green, 0, 'long', white, true, size.small)
plotshape (short, 'Short', shape.labeldown, location.abovebar, red, 0, 'short', white, true, size.small)
// Alerts
alertcondition (long, 'Long')
alertcondition (short, 'Short') |
Aggr. CDV / Delta Volume - InFinito | https://www.tradingview.com/script/Dasacvjb-Aggr-CDV-Delta-Volume-InFinito/ | In_Finito_ | https://www.tradingview.com/u/In_Finito_/ | 580 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © In_Finito_
// Based of
// Aggregation by Crypt0rus - https://www.tradingview.com/script/V3q0WkG6-Aggregated-Volume-Colored-Bitcoin-ETH-Altcoins-everything/
// Buy Sell Volume by Ricardo M Arjona @XeL_Arjona - https://www.tradingview.com/script/NHcilGl8-MARKET-VOLUME-by-BeloTrade-XeL-Arjona/
// Delta Calculations & Exchange Sorting & Exchange Data Normalization by InFinito
//@version=5
indicator("Aggregated CVD - Cumulative Volume Delta", shorttitle=" Aggregated CVD", format=format.volume, timeframe='')
////////////////////GENERAL INPUTS/////////////////////////////////////////
////////////////////MARKET TYPE INPUT/////////////////////////////////////
aggr = input.bool(defval=true, title='Use Aggregated Data', inline='1', group='Aggregation')
markettype = input.string(defval='Spot', title='Market Type Aggregation', options=['Spot', 'Futures' , 'Perp', 'Derivatives F+P', 'Spot+Derivs'], inline='2', group='Aggregation', tooltip='Disable to check by symbol OR if you want to use this indicator with any other pair than BTC')
//////////////////RESET BASIS INPUTS///////////////////////////
bres = input.bool(defval=false, title='', inline='1', group='Reset Basis')
brestf = input.timeframe(defval='12M', title='Reset CVD Basis Periodically', options=['12M', '6M', '3M', 'M', '2W', 'W', 'D', '240', '60' ], inline='1', group='Reset Basis', tooltip='Reset OBV to 0 every X amount of time')
/////////////////////////PLOT STYLE/////////////////////////////
linestyle = input.string(defval='Line', title='Style', options=['Candle', 'Line'], inline='1', group='Line / Candle')
hacandle = input.bool(defval=false, title='Heikin Ashi Candles', inline='1', group='Line / Candle')
////////////////INPUTS FOR CANDLES/////////////////////////////////
colorup = input.color(defval=color.green, title='Body', inline='bcol', group='Candle Coloring')
colordown = input.color(defval=color.red, title='', inline='bcol', group='Candle Coloring')
bcolup = input.color(defval=color.black, title='Border', inline='bocol', group='Candle Coloring')
bcoldown = input.color(defval=color.black, title='', inline='bocol', group='Candle Coloring')
wcolup = input.color(defval=color.black, title='Wicks', inline='wcol', group='Candle Coloring')
wcoldown = input.color(defval=color.black, title='', inline='wcol', group='Candle Coloring')
tw = high - math.max(open, close)
bw = math.min(open, close) - low
body = math.abs(close - open)
///////////////////////////////////////////////////////////////////
///////////////////////MA INPUTS///////////////////////////
addma = input.bool(defval=true, title='Add MA to CVD |',inline='1', group='Moving Average')
matype = input.string(defval='SMA', title='MA Type', options=['SMA', 'EMA', 'VWMA', 'WMA', 'SMMA (RMA)'], inline='2', group='Moving Average')
malen = input.int(defval=28, title='MA Lenght', inline='1', group='Moving Average')
//////////////////// Inputs FOR SPOT AGGREGATION///////////////////////////
i_sym1 = input.bool(true, '', inline='1', group='Spot Symbols')
i_sym2 = input.bool(true, '', inline='2', group='Spot Symbols')
i_sym3 = input.bool(true, '', inline='3', group='Spot Symbols')
i_sym4 = input.bool(true, '', inline='4', group='Spot Symbols')
i_sym5 = input.bool(true, '', inline='5', group='Spot Symbols')
i_sym6 = input.bool(true, '', inline='6', group='Spot Symbols')
i_sym7 = input.bool(true, '', inline='7', group='Spot Symbols')
i_sym8 = input.bool(true, '', inline='8', group='Spot Symbols')
i_sym9 = input.bool(true, '', inline='9', group='Spot Symbols')
i_sym10 = input.bool(false, '', inline='10', group='Spot Symbols')
i_sym11 = input.bool(false, '', inline='11', group='Spot Symbols')
i_sym12 = input.bool(true, '', inline='12', group='Spot Symbols')
i_sym13 = input.bool(true, '', inline='13', group='Spot Symbols')
i_sym14 = input.bool(false, '', inline='14', group='Spot Symbols')
i_sym15 = input.bool(false, '', inline='15', group='Spot Symbols')
i_sym16 = input.bool(false, '', inline='16', group='Spot Symbols')
i_sym1_ticker = input.symbol('BINANCE:BTCUSDT', '', inline='1', group='Spot Symbols')
i_sym2_ticker = input.symbol('BINANCE:BTCBUSD', '', inline='2', group='Spot Symbols')
i_sym3_ticker = input.symbol('BITSTAMP:BTCUSD', '', inline='3', group='Spot Symbols')
i_sym4_ticker = input.symbol('HUOBI:BTCUSDT', '', inline='4', group='Spot Symbols')
i_sym5_ticker = input.symbol('OKEX:BTCUSDT', '', inline='5', group='Spot Symbols')
i_sym6_ticker = input.symbol('COINBASE:BTCUSD', '', inline='6', group='Spot Symbols')
i_sym7_ticker = input.symbol('COINBASE:BTCUSDT', '', inline='7', group='Spot Symbols')
i_sym8_ticker = input.symbol('GEMINI:BTCUSD', '', inline='8', group='Spot Symbols')
i_sym9_ticker = input.symbol('KRAKEN:XBTUSD', '', inline='9', group='Spot Symbols')
i_sym10_ticker = input.symbol('FTX:BTCUSD', '', inline='10', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Spot Symbols')
i_sym11_ticker = input.symbol('FTX:BTCUSDT', '', inline='11', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Spot Symbols')
i_sym12_ticker = input.symbol('BITFINEX:BTCUSD', '', inline='12', group='Spot Symbols')
i_sym13_ticker = input.symbol('BINGX:BTCUSDT', '', inline='13', group='Spot Symbols')
i_sym14_ticker = input.symbol('GATEIO:BTCUSDT', '', inline='14', group='Spot Symbols')
i_sym15_ticker = input.symbol('PHEMEX:BTCUSDT', '', inline='15', group='Spot Symbols')
i_sym16_ticker = input.symbol('BITGET:BTCUSDT', '', inline='16', group='Spot Symbols')
sbase1 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Spot Symbols')
sbase2 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Spot Symbols')
sbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Spot Symbols')
sbase4 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Spot Symbols')
sbase5 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Spot Symbols')
sbase6 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Spot Symbols')
sbase7 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Spot Symbols')
sbase8 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Spot Symbols')
sbase9 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='9', group='Spot Symbols')
sbase10 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='10', group='Spot Symbols')
sbase11 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='11', group='Spot Symbols')
sbase12 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='12', group='Spot Symbols')
sbase13 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='13', group='Spot Symbols')
sbase14 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='14', group='Spot Symbols')
sbase15 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='15', group='Spot Symbols')
sbase16 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='16', group='Spot Symbols')
samount1 = input.float(defval=1, title='#', inline='1', group='Spot Symbols')
samount2 = input.float(defval=1, title='#', inline='2', group='Spot Symbols')
samount3 = input.float(defval=1, title='#', inline='3', group='Spot Symbols')
samount4 = input.float(defval=1, title='#', inline='4', group='Spot Symbols')
samount5 = input.float(defval=1, title='#', inline='5', group='Spot Symbols')
samount6 = input.float(defval=1, title='#', inline='6', group='Spot Symbols')
samount7 = input.float(defval=1, title='#', inline='7', group='Spot Symbols')
samount8 = input.float(defval=1, title='#', inline='8', group='Spot Symbols')
samount9 = input.float(defval=1, title='#', inline='9', group='Spot Symbols')
samount10 = input.float(defval=1, title='#', inline='10', group='Spot Symbols')
samount11 = input.float(defval=1, title='#', inline='11', group='Spot Symbols')
samount12 = input.float(defval=1, title='#', inline='12', group='Spot Symbols')
samount13 = input.float(defval=1, title='#', inline='13', group='Spot Symbols')
samount14 = input.float(defval=1, title='#', inline='14', group='Spot Symbols')
samount15 = input.float(defval=1, title='#', inline='15', group='Spot Symbols')
samount16 = input.float(defval=1, title='#', inline='16', group='Spot Symbols')
//////INPUTS FOR FUTURES AGGREGATION///////////////////
i_sym1b = input.bool(true, '', inline='1', group='Futures Symbols')
i_sym2b = input.bool(true, '', inline='2', group='Futures Symbols')
i_sym3b = input.bool(true, '', inline='3', group='Futures Symbols')
i_sym4b = input.bool(false, '', inline='4', group='Futures Symbols')
i_sym5b = input.bool(false, '', inline='5', group='Futures Symbols')
i_sym6b = input.bool(false, '', inline='6', group='Futures Symbols')
i_sym7b = input.bool(false, '', inline='7', group='Futures Symbols')
i_sym8b = input.bool(true, '', inline='8', group='Futures Symbols')
i_sym9b = input.bool(true, '', inline='9', group='Futures Symbols')
i_sym10b = input.bool(true, '', inline='10', group='Futures Symbols')
i_sym11b = input.bool(false, '', inline='11', group='Futures Symbols')
i_sym12b = input.bool(false, '', inline='12', group='Futures Symbols')
i_sym1b_ticker = input.symbol('BINANCE:BTCUSDTPERP', '', inline='1', group='Futures Symbols')
i_sym2b_ticker = input.symbol('BINANCE:BTCBUSDPERP', '', inline='2', group='Futures Symbols')
i_sym3b_ticker = input.symbol('BYBIT:BTCUSDT.P', '', inline='3', group='Futures Symbols')
i_sym4b_ticker = input.symbol('CME:BTC1!', '', inline='4', tooltip='This volume is reported in 5 BTC and it is recalculated to work properly, beware when changing this symbol',group='Futures Symbols')
i_sym5b_ticker = input.symbol('CME:BTC2!', '', inline='5', tooltip='This volume is reported in 5 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym6b_ticker = input.symbol('CME:MBT1!', '', inline='6', tooltip='This volume is reported in 0.10 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym7b_ticker = input.symbol('CME:MBT2!', '', inline='7', tooltip='This volume is reported in 0.10 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym8b_ticker = input.symbol('PHEMEX:BTCUSDPERP', '', inline='8', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym9b_ticker = input.symbol('OKEX:BTCUSDT.P', '', inline='9', tooltip='This volume is reported in 100x BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym10b_ticker = input.symbol('BITMEX:XBTUSDT', '', inline='10', tooltip='This volume is reported as 1 million per BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym11b_ticker = input.symbol('BITGET:BTCUSDT.P', '', inline='11', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol - THIS IS NOT REPORTED IN REAL TIME', group='Futures Symbols')
i_sym12b_ticker = input.symbol('OKEX:BTCUSDT.P', '', inline='12', group='Futures Symbols')
fbase1 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Futures Symbols')
fbase2 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Futures Symbols')
fbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Futures Symbols')
fbase4 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Futures Symbols')
fbase5 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Futures Symbols')
fbase6 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Futures Symbols')
fbase7 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Futures Symbols')
fbase8 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Futures Symbols')
fbase9 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='9', group='Futures Symbols')
fbase10 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='10', group='Futures Symbols')
fbase11 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='11', group='Futures Symbols')
fbase12 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='12', group='Futures Symbols')
famount1 = input.float(defval=1, title='#', inline='1', group='Futures Symbols')
famount2 = input.float(defval=1, title='#', inline='2', group='Futures Symbols')
famount3 = input.float(defval=1, title='#', inline='3', group='Futures Symbols')
famount4 = input.float(defval=5, title='#', inline='4', group='Futures Symbols')
famount5 = input.float(defval=5, title='#', inline='5', group='Futures Symbols')
famount6 = input.float(defval=0.1, title='#', inline='6', group='Futures Symbols')
famount7 = input.float(defval=0.1, title='#', inline='7', group='Futures Symbols')
famount8 = input.float(defval=1, title='#', inline='8', group='Futures Symbols')
famount9 = input.float(defval=0.01, title='#', inline='9', group='Futures Symbols')
famount10 = input.float(defval=0.000001, title='#', inline='10', group='Futures Symbols')
famount11 = input.float(defval=1, title='#', inline='11', group='Futures Symbols')
famount12 = input.float(defval=1, title='#', inline='12', group='Futures Symbols')
//, tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol'
////////////////////////////////////////////////////////////////////
//////INPUTS FOR PERP AGGREGATION///////////////////
i_sym1c = input.bool(true, '', inline='1', group='Perpetuals Symbols')
i_sym2c = input.bool(true, '', inline='2', group='Perpetuals Symbols')
i_sym3c = input.bool(true, '', inline='3', group='Perpetuals Symbols')
i_sym4c = input.bool(true, '', inline='4', group='Perpetuals Symbols')
i_sym5c = input.bool(false, '', inline='5', group='Perpetuals Symbols')
i_sym6c = input.bool(true, '', inline='6', group='Perpetuals Symbols')
i_sym7c = input.bool(true, '', inline='7', group='Perpetuals Symbols')
i_sym8c = input.bool(true, '', inline='8', group='Perpetuals Symbols')
i_sym1c_ticker = input.symbol('BINANCE:BTCPERP', '', inline='1', tooltip='This volume is reported in blocks of 100 USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym2c_ticker = input.symbol('OKEX:BTCUSD.P', '', inline='2', tooltip='This volume is reported in blocks of 100 USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym3c_ticker = input.symbol('HUOBI:BTCUSD.P', '', inline='3', group='Perpetuals Symbols')
i_sym4c_ticker = input.symbol('PHEMEX:BTCPERP', '', inline='4', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym5c_ticker = input.symbol('FTX:BTCPERP', '', inline='5', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol' ,group='Perpetuals Symbols')
i_sym6c_ticker = input.symbol('BYBIT:BTCUSD.P', '', inline='6', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym7c_ticker = input.symbol('DERIBIT:BTCUSD.P', '', inline='7', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym8c_ticker = input.symbol('BITMEX:XBTUSD.P', '', inline='8', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
pbase1 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Perpetuals Symbols')
pbase2 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Perpetuals Symbols')
pbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Perpetuals Symbols')
pbase4 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Perpetuals Symbols')
pbase5 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Perpetuals Symbols')
pbase6 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Perpetuals Symbols')
pbase7 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Perpetuals Symbols')
pbase8 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Perpetuals Symbols')
pamount1 = input.float(defval=100, title='#', inline='1', group='Perpetuals Symbols')
pamount2 = input.float(defval=100, title='#', inline='2', group='Perpetuals Symbols')
pamount3 = input.float(defval=1, title='#', inline='3', group='Perpetuals Symbols')
pamount4 = input.float(defval=1, title='#', inline='4', group='Perpetuals Symbols')
pamount5 = input.float(defval=1, title='#', inline='5', group='Perpetuals Symbols')
pamount6 = input.float(defval=1, title='#', inline='6', group='Perpetuals Symbols')
pamount7 = input.float(defval=1, title='#', inline='7', group='Perpetuals Symbols')
pamount8 = input.float(defval=1, title='#', inline='8', group='Perpetuals Symbols')
////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////AGGREGATED VOLUME CALCULATION///////////////////////
//// VOLUME REQUEST FUNCTION//////////////////////////
f_volume(_ticker) =>
request.security(_ticker, timeframe.period, volume)
//////////////////////////////////////////////////////////
var float finvol = 0
if aggr==true///////////SPOT////////////////////////////////////////////////////////////////////
v1x = (i_sym1 ? f_volume(i_sym1_ticker) : 0)
v1 = sbase1=='Coin' ? v1x*samount1 : sbase1=='USD' or sbase1=='Other' ? (v1x*samount1)/ohlc4 : v1x
v2x = (i_sym2 ? f_volume(i_sym2_ticker) : 0)
v2 = sbase2=='Coin' ? v2x*samount2 : sbase2=='USD' or sbase2=='Other' ? (v2x*samount2)/ohlc4 : v2x
v3x = (i_sym3 ? f_volume(i_sym3_ticker) : 0)
v3 = sbase2=='Coin' ? v3x*samount3 : sbase3=='USD' or sbase3=='Other' ? (v3x*samount4)/ohlc4 : v3x
v4x = (i_sym4 ? f_volume(i_sym4_ticker) : 0)
v4 = sbase4=='Coin' ? v4x*samount4 : sbase4=='USD' or sbase4=='Other' ? (v4x*samount4)/ohlc4 : v4x
v5x = (i_sym5 ? f_volume(i_sym5_ticker) : 0)
v5 = sbase5=='Coin' ? v5x*samount5 : sbase5=='USD' or sbase5=='Other' ? (v5x*samount5)/ohlc4 : v5x
v6x = (i_sym6 ? f_volume(i_sym6_ticker) : 0)
v6 = sbase6=='Coin' ? v6x*samount6 : sbase6=='USD' or sbase6=='Other' ? (v6x*samount6)/ohlc4 : v6x
v7x = (i_sym7 ? f_volume(i_sym7_ticker) : 0)
v7 = sbase7=='Coin' ? v7x*samount7 : sbase7=='USD' or sbase7=='Other' ? (v7x*samount7)/ohlc4 : v7x
v8x = (i_sym8 ? f_volume(i_sym8_ticker) : 0)
v8 = sbase8=='Coin' ? v8x*samount8 : sbase8=='USD' or sbase8=='Other' ? (v8x*samount8)/ohlc4 : v8x
v9x = (i_sym9 ? f_volume(i_sym9_ticker) : 0)
v9 = sbase9=='Coin' ? v9x*samount9 : sbase9=='USD' or sbase9=='Other' ? (v9x*samount9)/ohlc4 : v9x
v10x = (i_sym10 ? f_volume(i_sym10_ticker) : 0) //FTX reported in usd
v10 = sbase10=='Coin' ? v10x*samount10 : sbase10=='USD' or sbase10=='Other' ? (v10x*samount10)/ohlc4 : v10x
v11x = (i_sym11 ? f_volume(i_sym11_ticker) : 0) //FTX reported in usd
v11 = sbase11=='Coin' ? v11x*samount11 : sbase11=='USD' or sbase11=='Other' ? (v11x*samount11)/ohlc4 : v11x
v12x = (i_sym12 ? f_volume(i_sym12_ticker) : 0)
v12 = sbase12=='Coin' ? v12x*samount12 : sbase12=='USD' or sbase12=='Other' ? (v12x*samount10)/ohlc4 : v12x
v13x = (i_sym13 ? f_volume(i_sym13_ticker) : 0)
v13 = sbase13=='Coin' ? v13x*samount13 : sbase13=='USD' or sbase13=='Other' ? (v13x*samount13)/ohlc4 : v13x
v14x = (i_sym14 ? f_volume(i_sym14_ticker) : 0)
v14 = sbase14=='Coin' ? v14x*samount14 : sbase14=='USD' or sbase14=='Other' ? (v14x*samount14)/ohlc4 : v14x
v15x = (i_sym15 ? f_volume(i_sym15_ticker) : 0)
v15 = sbase15=='Coin' ? v15x*samount15 : sbase15=='USD' or sbase15=='Other' ? (v15x*samount15)/ohlc4 : v15x
v16x = (i_sym16 ? f_volume(i_sym16_ticker) : 0)
v16 = sbase16=='Coin' ? v16x*samount16 : sbase16=='USD' or sbase16=='Other' ? (v16x*samount16)/ohlc4 : v16x
vsf=v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16
///////////////////////////////////////////////////////////////////////////////////
///////////////////////FUTURES////////////////////////////////////////////////////
v1bx = (i_sym1b ? f_volume(i_sym1b_ticker) : 0)
v1b = fbase1=='Coin' ? v1bx*famount1 : fbase1=='USD' or fbase1=='Other' ? (v1bx*famount1)/ohlc4 : v1bx
v2bx = (i_sym2b ? f_volume(i_sym2b_ticker) : 0)
v2b = fbase2=='Coin' ? v2bx*famount2 : fbase2=='USD' or fbase2=='Other' ? (v2bx*famount2)/ohlc4 : v2bx
v3bx = (i_sym3b ? f_volume(i_sym3b_ticker) : 0)
v3b = fbase3=='Coin' ? v3bx*famount3 : fbase3=='USD' or fbase3=='Other' ? (v3bx*famount3)/ohlc4 : v3bx
v4bx =(i_sym4b ? f_volume(i_sym4b_ticker) : 0) //CME NORMAL (each contract reported equals 5btc)
v4b = fbase4=='Coin' ? v4bx*famount4 : fbase4=='USD' or fbase4=='Other' ? (v4bx*famount4)/ohlc4 : v4bx
v5bx = (i_sym5b ? f_volume(i_sym5b_ticker) : 0)//CME NORMAL (each contract reported equals 5btc)
v5b = fbase5=='Coin' ? v5bx*famount5 : fbase5=='USD' or fbase5=='Other' ? (v5bx*famount5)/ohlc4 : v5bx
v6bx = (i_sym6b ? f_volume(i_sym6b_ticker) : 0)//CME mini (each contract reported equals 0.60btc)
v6b = fbase6=='Coin' ? v6bx*famount6 : fbase6=='USD' or fbase6=='Other' ? (v6bx*famount6)/ohlc4 : v6bx
v7bx = (i_sym7b ? f_volume(i_sym7b_ticker) : 0)//CME mini (each contract reported equals 0.7btc)
v7b = fbase7=='Coin' ? v7bx*famount7 : fbase7=='USD' or fbase7=='Other' ? (v7bx*famount7)/ohlc4 : v7bx
v8bx = (i_sym8b ? f_volume(i_sym8b_ticker) : 0)// PHEMEX reported in usd
v8b = fbase8=='Coin' ? v8bx*famount8 : fbase8=='USD' or fbase8=='Other' ? (v8bx*famount8)/ohlc4 : v8bx
v9bx = (i_sym9b ? f_volume(i_sym9b_ticker) : 0)// OKEX reported in 900xBTC, meaning every 900 contracts is only one
v9b = fbase9=='Coin' ? v9bx*famount9 : fbase9=='USD' or fbase9=='Other' ? (v9bx*famount9)/ohlc4 : v9bx
v10bx = (i_sym10b ? f_volume(i_sym10b_ticker) : 0)// BITMEX REPORTED IN 1 MILLION BTC, MEANING EACH MILLION CONTRACTS ON TV REPRESENT 1 BTC
v10b = fbase10=='Coin' ? v1bx*famount10 : fbase10=='USD' or fbase10=='Other' ? (v10bx*famount10)/ohlc4 : v10bx
v11bx = (i_sym11b ? f_volume(i_sym11b_ticker) : 0)// BITGET REPORTED IN USD - TURNED OFF BECAUSE DOESNT PROVIDE REAL TIME DATA
v11b = fbase11=='Coin' ? v11bx*famount11 : fbase11=='USD' or fbase11=='Other' ? (v11bx*famount11)/ohlc4 : v11bx
v12bx = (i_sym12b ? f_volume(i_sym12b_ticker) : 0)
v12b = fbase12=='Coin' ? v12bx*famount12 : fbase12=='USD' or fbase12=='Other' ? (v12bx*famount12)/ohlc4 : v12bx
vff=v1b+v2b+v3b+v4b+v5b+v6b+v7b+v8b+v9b+v10b+v11b+v12b
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////PERPS///////////////////////////////////////////////////////////
v1cx = (i_sym1c ? f_volume(i_sym1c_ticker) : 0)//BINANCE REPORTED IN BLOCKS OF 100 USD, MEANING EACH CONTRACT REPORTED IS EQUAL TO 100 USD
v1c = pbase1=='Coin' ? v1cx*pamount1 : pbase1=='USD' or pbase1=='Other' ? (v1cx*pamount1)/ohlc4 : v1cx
v2cx = (i_sym2c ? f_volume(i_sym2c_ticker) : 0)//OKEX REPORTED IN BLOCKS OF 100 USD, MEANING EACH CONTRACT REPORTED IS EQUAL TO 100 USD
v2c = pbase2=='Coin' ? v2cx*pamount2 : pbase2=='USD' or pbase2=='Other' ? (v2cx*pamount2)/ohlc4 : v2cx
v3cx = (i_sym3c ? f_volume(i_sym3c_ticker) : 0)// HUOBI REPORTED IN BTC
v3c = pbase3=='Coin' ? v3cx*pamount3 : pbase3=='USD' or pbase3=='Other' ? (v3cx*pamount3)/ohlc4 : v3cx
v4cx =(i_sym4c ? f_volume(i_sym4c_ticker) : 0)// PHEMEX REPORTED IN USD
v4c = pbase4=='Coin' ? v4cx*pamount4 : pbase4=='USD' or pbase4=='Other' ? (v4cx*pamount4)/ohlc4 : v4cx
v5cx = (i_sym5c ? f_volume(i_sym5c_ticker) : 0)// FTX REPORTED IN USD
v5c = pbase5=='Coin' ? v5cx*pamount5 : pbase5=='USD' or pbase5=='Other' ? (v5cx*pamount5)/ohlc4 : v5cx
v6cx = (i_sym6c ? f_volume(i_sym6c_ticker) : 0)//BYBIT REPORTED IN USD
v6c = pbase6=='Coin' ? v6cx*pamount6 : pbase6=='USD' or pbase6=='Other' ? (v6cx*pamount6)/ohlc4 : v6cx
v7cx = (i_sym7c ? f_volume(i_sym7c_ticker) : 0)//DERIBIT REPORTED IN USD
v7c = pbase7=='Coin' ? v7cx*pamount7 : pbase7=='USD' or pbase7=='Other' ? (v7cx*pamount7)/ohlc4 : v7cx
v8cx = (i_sym8c ? f_volume(i_sym8c_ticker) : 0)//BITMEX REPORTED IN USD
v8c = pbase8=='Coin' ? v8cx*pamount8 : pbase8=='USD' or pbase8=='Other' ? (v8cx*pamount8)/ohlc4 : v8cx
vpf=v1c+v2c+v3c+v4c+v5c+v6c+v7c+v8c
///////////////////////////////////////////////////////////////////////////////////////
////////////////////ALL DERIV VOLUME//////////////////////////////////////////////////////////////////
alldvol = vff + vpf
/////////////////////////////////////////////////////////////////////////////////////////
////////////////////ALL VOLUME//////////////////////////////////////////////////////////////////
allvol = vsf + vff + vpf
/////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////FINAL AGGREGATION SELECTION/////////////////////////////////////////
if markettype == 'Spot'
finvol := vsf
finvol
else if markettype == 'Futures'
finvol := vff
finvol
else if markettype == 'Perp'
finvol := vpf
finvol
else if markettype == 'Derivatives F+P'
finvol := alldvol
finvol
else if markettype == 'Spot+Derivs'
finvol := allvol
finvol
else if aggr==false
finvol := volume
///////////////////////////////////AGGREGATED OR BY CHART////////////////////////////////////////////////
vol = finvol
//////////// RESET BASIS ///////////////////////////////////////////////////////
ftf = (time(timeframe.period) == time(brestf)) ? true : false
timo = time(brestf)
var float minus = 0
var bool sw = false
//////////////////////////////////BUY SELL VOLUME CALCS///////////////////////////////////////////////////////
// PRESSURE ALGORITHMS AND VARIABLES
TR = ta.atr(1)
// Bull And Bear "Power-Balance" by Vadim Gimelfarb Algorithm's
BP = close<open ? (close[1]<open ? math.max(high-close[1], close-low) : math.max(high-open, close-low)) : (close>open ? (close[1]>open ? high-low : math.max(open-close[1], high-low)) : (high-close>close-low ? (close[1]<open ? math.max(high-close[1],close-low) : high-open) : (high-close<close-low ? (close[1]>open ? high-low : math.max(open-close[1], high-low)) : (close[1]>open ? math.max(high-open, close-low) : (close[1]<open ? math.max(open-close[1], high-low) : high-low)))))
SP = close<open ? (close[1]>open ? math.max(close[1]-open, high-low): high-low) : (close>open ? (close[1]>open ? math.max(close[1]-low, high-close) : math.max(open-low, high-close)) : (high-close>close-low ? (close[1]>open ? math.max(close[1]-open, high-low) : high-low) : (high-close<close-low ? (close[1]>open ? math.max(close[1]-low, high-close) : open-low) : (close[1]>open ? math.max(close[1]-open, high-low) : (close[1]<open ? math.max(open-low, high-close) : high-low)))))
TP = BP+SP
// RAW Pressure Volume Calculations
BPV = (BP/TP)*vol
SPV = (SP/TP)*vol
TPV = BPV+SPV
/////////////BUY ALWAYS UO SELL ALWAYS DOWN//////////////////////
bpp = math.abs(BPV)
spp = -math.abs(SPV)
///////////////////DELTA///////////////////////////////////////////////////////
var float cvd = na
var float cvd1 = na
var float cvd2 = na
delt = bpp+spp
cvd1 := ta.cum(delt)
cvd2 := (ta.cum(delt) - minus)
////////////////////////CVD BASIS RESET////////////////////////////////////////
if ftf and bres
minus := cvd1[0]
sw := true
if bres == true
if sw==false
cvd := cvd2
else if sw==true
cvd2 := 0
cvd := cvd2
sw := false
else if bres == false
cvd := cvd1
plotshape(bres and ftf ? 0 : na ,title='Reset Marker', style=shape.xcross, location=location.absolute, color=color.black, size=size.small)
//////////////////PLOT CVD///////////////////////////////////////////////
//////////////////////////////////////////////////PLOTTING////////////////////////////////////////////
float ctl = na
float o = na
float h = na
float l = na
float c = na
if linestyle == 'Candle'
o := cvd[1]
h := math.max(cvd, cvd[1])
l := math.min(cvd, cvd[1])
c := cvd
ctl
else
ctl := cvd
ctl
///////////////////////CANDLES//////////////////////////////////////
float haclose = na
float haopen = na
float hahigh = na
float halow = na
haclose := (o + h + l + c) / 4
haopen := na(haopen[1]) ? (o + c) / 2 : (haopen[1] + haclose[1]) / 2
hahigh := math.max(h, math.max(haopen, haclose))
halow := math.min(l, math.min(haopen, haclose))
c_ = hacandle ? haclose : c
o_ = hacandle ? haopen : o
h_ = hacandle ? hahigh : h
l_ = hacandle ? halow : l
ohlcr = (o_ + h_ + l_ + c_)/4
///////////////////PLOT CANDLES/////////////////////////////
plotcandle(o_, h_, l_, c_, title='CVD Candles', color=o_ <= c_ ? colorup : colordown, bordercolor=o_ <= c_ ? bcolup : bcoldown, wickcolor=o_ <= c_ ? bcolup : bcoldown)
cvdp = plot(linestyle=='Line' ? cvd : na, title='Cumulative Delta Volume', color=color.blue, style=plot.style_line)
hl = plot(bres ? 0 : na , color=color.new(color.black,100), editable=false)
////////////////////PLOT MAs SWITCH ALTERNATIVE////////////////////////////////
masrc = linestyle=='Candle' ? ohlcr : cvd
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
maline = ma(masrc, malen, matype)
/////////////////////////////////////
maplot = plot(addma ? maline : na, title='Moving Average', color=color.purple)
////////MA FILL
var fillcol = color.green
finp = plot( linestyle=='Candle' ? ohlcr : cvd, color=color.new(color.black,100), editable=false)
if linestyle=='Line' and (maline > cvd)
fillcol := color.new(color.red, 65)
else if linestyle=='Line' and (maline < cvd)
fillcol := color.new(color.green, 65)
else if linestyle=='Candle' and (maline > ohlcr)
fillcol := color.new(color.red, 65)
else if linestyle=='Candle' and (maline < ohlcr)
fillcol := color.new(color.green, 65)
fill(finp , maplot , title='Moving Average Fill', color=fillcol, fillgaps=true)
////////////FILL WHEN RESET
var filcol = color.blue
if cvd > 0
filcol := color.new(color.green, 90)
else if cvd < 0
filcol := color.new(color.red, 90)
fill(finp, hl, title='Zero Line Fill', color=filcol, fillgaps=true )
|
K's Reversal Indicator I | https://www.tradingview.com/script/Olzkkwl2-K-s-Reversal-Indicator-I/ | Sofien-Kaabar | https://www.tradingview.com/u/Sofien-Kaabar/ | 950 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar
//@version = 5
indicator("K's Reversal Indicator I", overlay = true)
fast = input(defval = 12, title = 'Fast')
slow = input(defval = 26, title = 'Slow')
signal = input(defval = 9, title = 'Signal')
length = input(defval = 100, title = 'Bollinger Lookback')
multiplier = input(defval = 2, title = 'Multiplier')
// MACD
macd_line = ta.ema(close, fast) - ta.ema(close, slow)
signal_line = ta.ema(macd_line, signal)
// Bollinger
lower_boll = ta.sma(close, length) - (multiplier * ta.stdev(close, length))
upper_boll = ta.sma(close, length) + (multiplier * ta.stdev(close, length))
mid_line = ta.sma(close, length)
// Signal
buy_signal = math.min(open[1], close[1]) <= lower_boll[1] and math.max(open[1], close[1]) <= mid_line and macd_line[1] > signal_line[1] and macd_line[2] < signal_line[2]
sell_signal = math.max(open[1], close[1]) >= upper_boll[1] and math.min(open[1], close[1]) >= mid_line and macd_line[1] < signal_line[1] and macd_line[2] > signal_line[2]
// Plotting
plotshape(buy_signal, style = shape.triangleup, color = color.green, location = location.belowbar, size = size.small)
plotshape(sell_signal, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.small)
bar_size = timeframe.multiplier * (timeframe.isdaily?1440:timeframe.isweekly?7*1440:timeframe.ismonthly?30*1440:1) * 60*1000
if buy_signal == true
line.new(time, low[1] - (high[1] - low[1]) * 2, time + bar_size * 20, low[1] - (high[1] - low[1]) * 2, xloc.bar_time, color = color.green, width = 2)
line.new(time, open, time + bar_size * 20, open, xloc.bar_time, color = color.blue, width = 2)
if sell_signal == true
line.new(time, high[1] + (high[1] - low[1]) * 2, time + bar_size * 20, high[1] + (high[1] - low[1]) * 2, xloc.bar_time, color = color.red, width = 2)
line.new(time, open, time + bar_size * 20, open, xloc.bar_time, color = color.blue, width = 2)
|
Fair Value Gap | https://www.tradingview.com/script/erbzoVY8-Fair-Value-Gap/ | spacemanbtc | https://www.tradingview.com/u/spacemanbtc/ | 4,169 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © spacemanbtc
//@version=5
indicator("Fair Value Gap",shorttitle= "Fair Value Gap SpaceManBTC", overlay = true, max_boxes_count = 500, max_lines_count = 500, max_labels_count = 500)
//Fair Value Gap
//V1, 2022.4.12
//This indicator displays the fair value gap of the current timeframe AND an optional higher time frame.
//What the script does is take into account the values of the current bar high/low and compare with 2 bars previous
//The "gap" is generated from the lack of overlap between these bars
//Bearish or Bullish gaps determined via whether the gap is above or below price, as they tend to be filled gaps can be used as targets.
// ———————————————————— Inputs {
// Standard practice declared input variables with i_ easier to identify
i_tf = input.timeframe("D", "MTF Timeframe", group = "MTF Settings")
i_mtf = input.string(defval = "Current TF",group = "MTF Settings", title = "MTF Options", options = ["Current TF", "Current + HTF", "HTF"])
i_tfos = input.int(defval = 10,title = "Offset", minval = 0, maxval = 500 ,group = "MTF Settings", inline = "OS")
i_mtfos = input.int(defval = 20,title = "MTF Offset", minval = 0, maxval = 500 ,group = "MTF Settings", inline = "OS")
i_fillByMid = input.bool(false, "MidPoint Fill",group = "General Settings", tooltip = "When enabled FVG is filled when midpoint is tested")
i_deleteonfill = input.bool(true, "Delete Old On Fill",group = "General Settings")
i_labeltf = input.bool(true,"Label FVG Timeframe",group = "General Settings")
i_bullishfvgcolor = input.color(color.new(color.green,90), "Bullish FVG", group = "Coloring", inline = "BLFVG")
i_mtfbullishfvgcolor = input.color(color.new(color.lime,80), "MTF Bullish FVG", group = "Coloring", inline = "BLFVG")
i_bearishfvgcolor = input.color(color.new(color.red,90), "Bearish FVG", group = "Coloring", inline = "BRFVG")
i_mtfbearishfvgcolor = input.color(color.new(color.maroon,80), "MTF Bearish FVG", group = "Coloring", inline = "BRFVG")
i_midPointColor = input.color(color.new(color.white,85), "MidPoint Color", group = "Coloring")
i_textColor = input.color(color.white, "Text Color", group = "Coloring")
// }
// ———————————————————— Global data {
//Using current bar data for HTF highs and lows instead of security to prevent future leaking
var htfH = open
var htfL = open
if close > htfH
htfH:= close
if close < htfL
htfL := close
//Security Data, used for HTF Bar Data reference
sClose = request.security(syminfo.tickerid, i_tf, close[1], barmerge.gaps_off, barmerge.lookahead_on)
sHighP2 = request.security(syminfo.tickerid, i_tf, high[2], barmerge.gaps_off, barmerge.lookahead_on)
sLowP2 = request.security(syminfo.tickerid, i_tf, low[2], barmerge.gaps_off, barmerge.lookahead_on)
sOpen = request.security(syminfo.tickerid, i_tf, open[1], barmerge.gaps_off, barmerge.lookahead_on)
sBar = request.security(syminfo.tickerid, i_tf, bar_index, barmerge.gaps_off, barmerge.lookahead_on)
// }
//var keyword can be used to hold data in memory, with pinescript all data is lost including variables unless the var keyword is used to preserve this data
var bullishgapholder = array.new_box(0)
var bearishgapholder = array.new_box(0)
var bullishmidholder = array.new_line(0)
var bearishmidholder = array.new_line(0)
var bullishlabelholder = array.new_label(0)
var bearishlabelholder = array.new_label(0)
var transparentcolor = color.new(color.white,100)
// ———————————————————— Functions {
//function paramaters best declared with '_' this helps defer from variables in the function scope declaration and elsewhere e.g. close => _close
f_gapCreation(_upperlimit,_lowerlimit,_midlimit,_bar,_boxholder,_midholder,_labelholder,_boxcolor,_mtfboxcolor, _htf)=>
timeholder = str.tostring(i_tf)
offset = i_mtfos
boxbgcolor = _mtfboxcolor
if _htf == false
timeholder := str.tostring(timeframe.period)
offset := i_tfos
boxbgcolor := _boxcolor
array.push(_boxholder,box.new(_bar,_upperlimit,_bar+1,_lowerlimit,border_color=transparentcolor,bgcolor = boxbgcolor, extend = extend.right))
if i_fillByMid
array.push(_midholder,line.new(_bar,_midlimit,_bar+1,_midlimit,color = i_midPointColor, extend = extend.right))
if i_labeltf
array.push(_labelholder,label.new(_bar+ offset,_midlimit * 0.999, text = timeholder + " FVG", style =label.style_none, size = size.normal, textcolor = i_textColor))
//checks for gap between current candle and 2 previous candle e.g. low of current candle and high of the candle before last, this is the fair value gap.
f_gapLogic(_close,_high,_highp2,_low,_lowp2,_open,_bar,_htf)=>
if _open > _close
if _high - _lowp2 < 0
upperlimit = _close - (_close - _lowp2 )
lowerlimit = _close - (_close-_high)
midlimit = (upperlimit + lowerlimit) / 2
f_gapCreation(upperlimit,lowerlimit,midlimit,_bar,bullishgapholder,bullishmidholder,bullishlabelholder,i_bullishfvgcolor,i_mtfbullishfvgcolor,_htf)
else
if _low - _highp2 > 0
upperlimit = _close - (_close-_low)
lowerlimit = _close- (_close - _highp2),
midlimit = (upperlimit + lowerlimit) / 2
f_gapCreation(upperlimit,lowerlimit,midlimit,_bar,bearishgapholder,bearishmidholder,bearishlabelholder,i_bearishfvgcolor,i_mtfbearishfvgcolor,_htf)
//Used to remove the gap from its relevant array as a result of it being filled.
f_gapDeletion(_currentgap,_i,_boxholder,_midholder,_labelholder)=>
array.remove(_boxholder,_i)
if i_fillByMid
currentmid=array.get(_midholder,_i)
array.remove(_midholder,_i)
if i_deleteonfill
line.delete(currentmid)
else
line.set_extend(currentmid, extend.none)
line.set_x2(currentmid,bar_index)
if i_deleteonfill
box.delete(_currentgap)
else
box.set_extend(_currentgap,extend.none)
box.set_right(_currentgap,bar_index)
if i_labeltf
currentlabel=array.get(_labelholder,_i)
array.remove(_labelholder,_i)
if i_deleteonfill
label.delete(currentlabel)
//checks if gap has been filled either by 0.5 fill (i_fillByMid) or SHRINKS the gap to reflect the true value gap left.
f_gapCheck(_high,_low)=>
if array.size(bullishgapholder) > 0
for i = array.size(bullishgapholder)-1 to 0
currentgap = array.get(bullishgapholder,i)
currenttop = box.get_top(currentgap)
if i_fillByMid
currentmid = array.get(bullishmidholder,i)
currenttop := line.get_y1(currentmid)
if _high >= currenttop
f_gapDeletion(currentgap,i,bullishgapholder,bullishmidholder,bullishlabelholder)
if _high > box.get_bottom(currentgap) and _high < box.get_top(currentgap)
box.set_bottom(currentgap,_high)
if array.size(bearishgapholder) > 0
for i = array.size(bearishgapholder)-1 to 0
currentgap = array.get(bearishgapholder,i)
currentbottom = box.get_bottom(currentgap)
if i_fillByMid
currentmid = array.get(bearishmidholder,i)
currentbottom := line.get_y1(currentmid)
if _low <= currentbottom
f_gapDeletion(currentgap,i,bearishgapholder,bearishmidholder,bearishlabelholder)
if _low < box.get_top(currentgap) and _low > box.get_bottom(currentgap)
box.set_top(currentgap,_low)
// pine provided function to determine a new bar
is_newbar(res) =>
t = time(res)
not na(t) and (na(t[1]) or t > t[1])
if is_newbar(i_tf)
htfH := open
htfL := open
// }
// User Input, allow MTF data calculations
if is_newbar(i_tf) and (i_mtf == "Current + HTF" or i_mtf == "HTF")
f_gapLogic(sClose,htfH,sHighP2,htfL,sLowP2,sOpen,bar_index,true)
// Use current Timeframe data to provide gap logic
if (i_mtf == "Current + HTF" or i_mtf == "Current TF")
f_gapLogic(close[1],high,high[2],low,low[2],open[1],bar_index,false)
f_gapCheck(high,low)
|
Bart Pattern [LuxAlgo] | https://www.tradingview.com/script/CQScywKe-Bart-Pattern-LuxAlgo/ | LuxAlgo | https://www.tradingview.com/u/LuxAlgo/ | 1,075 | study | 5 | CC-BY-NC-SA-4.0 | // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("Bart Pattern Detector [LuxAlgo]",overlay=true,max_boxes_count=500,max_lines_count=500)
length = input(25,'Median Lookback')
mult = input(1.,'Edge Detection Sensitivity')
threshold = input(2.,'Range To Edges Threshold')
invert = input(false,'Show Inverted Barts')
mode = input.string('Bartify',options=['Simple','Bartify'])
//------------------------------------------------------------------------------
var y = array.new_float(0)
var x = array.new_int(0)
var ds = array.new_float(0)
var os = 0
//------------------------------------------------------------------------------
n = bar_index
src = close
atr = ta.atr(100)*mult
med = ta.percentile_linear_interpolation(src,length,50)
d = med-med[1]
os := d > atr ? 1 : d < -atr ? 0 : os[1]
if d > atr or d < -atr
array.unshift(ds,math.abs(d))
condition = invert ? os != os[1] : os < os[1]
if condition
dist = array.range(y)/(array.get(ds,0)+array.get(ds,1))
if dist < threshold
if (os == 0 and src[length/2] < array.min(y)) or (os == 1 and src[length/2] > array.max(y))
if mode == 'Bartify'
base = os == 1 ? array.max(y)+array.range(y) : array.min(y)-array.range(y)
prev_x = array.get(x,0)
prev_y = array.get(y,0)
t = 0
Y = 0.
for i = 0 to array.size(x)-1 by math.max(int(array.size(x)/10),1)
if os == 1
Y := array.min(y) + t%2*array.range(y)
else
Y := array.max(y) - t%2*array.range(y)
l1 = line.new(prev_x,prev_y,array.get(x,i),Y,color=color.black)
l2 = line.new(prev_x,base,array.get(x,i),base,color=na)
t += 1
linefill.new(l1,l2,color=color.yellow)
prev_x := array.get(x,i)
prev_y := Y
else
box.new(array.get(x,0),array.max(y),int(n-length/2),array.min(y)
,border_color= os == 1 ? #0cb51a : #ff1100
,bgcolor=color.new(os == 1 ? #0cb51a : #ff1100,50))
if d > atr or d < -atr
array.clear(y)
array.clear(x)
array.push(y,src[length/2])
array.push(x,n[length/2])
//------------------------------------------------------------------------------
var upper_dash = table.new(position.top_right,1,1)
var lower_dash = table.new(position.bottom_right,1,1)
if mode == 'Bartify'
if os == 0
table.cell(upper_dash,0,0,'EAT MY',text_color=color.red,text_size=size.huge,bgcolor=color.new(color.red,50))
table.cell(lower_dash,0,0,'SHORTS 🩳 !!',text_color=color.red,text_size=size.huge,bgcolor=color.new(color.red,50))
else
table.cell(upper_dash,0,0,'EAT MY',text_color=color.green,text_size=size.huge,bgcolor=color.new(color.green,50))
table.cell(lower_dash,0,0,'LONGS 🌕 !!',text_color=color.green,text_size=size.huge,bgcolor=color.new(color.green,50))
else
if os == 0
table.cell(upper_dash,0,0,'Down Trend',text_color=color.red,text_size=size.normal,bgcolor=color.new(color.red,50))
else
table.cell(upper_dash,0,0,'Up Trend',text_color=color.green,text_size=size.normal,bgcolor=color.new(color.green,50))
|
Buy/Sell Aggregated Delta Pressure - InFinito | https://www.tradingview.com/script/d1mLOLIJ-Buy-Sell-Aggregated-Delta-Pressure-InFinito/ | In_Finito_ | https://www.tradingview.com/u/In_Finito_/ | 122 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © In_Finito_
// Based of
// Aggregation by Crypt0rus - https://www.tradingview.com/script/V3q0WkG6-Aggregated-Volume-Colored-Bitcoin-ETH-Altcoins-everything/
// Buy Sell Pressure by Ricardo M Arjona @XeL_Arjona - https://www.tradingview.com/script/NHcilGl8-MARKET-VOLUME-by-BeloTrade-XeL-Arjona/
// Delta Calculations & Exchange Sorting & Exchange Data Normalization by InFinito
//@version=5
indicator("Buy/Sell Delta Pressure", shorttitle=" B/S Delta Pressure", format=format.volume, timeframe='')
////////////////////GENERAL INPUTS/////////////////////////////////////////
////////////////////MARKET TYPE INPUT/////////////////////////////////////
aggr = input.bool(defval=true, title='Use Aggregated Data', inline='1', group='Aggregation', tooltip='Disable to check by symbol OR if you want to use this indicator with any other pair than BTC')
markettype = input.string(defval='Spot', title='Market Type Aggregation', options=['Spot', 'Futures' , 'Perp', 'Derivatives F+P', 'Spot+Derivs'], inline='2', group='Aggregation')
//////////////////////////Display INPUTS//////////////////////////////////
disp = input.string(defval='Delta', title='Display:', options=['Delta', 'Buy/Sell Pressure', 'Buy/Sell Pressure + Delta'], inline='1', group='Display Options')
signal = input.int(defval=3, title='Signal Lenght', inline='1', group='Display Options', tooltip='This is an EMA based of the BUY/SELL volume respectively')
///////////////////////MA INPUTS///////////////////////////
addma = input.bool(defval=true, title='Add MA to Delta |',inline='1', group='Moving Average')
matype = input.string(defval='EMA', title='MA Type', options=['SMA', 'EMA', 'VWMA', 'WMA', 'SMMA (RMA)'], inline='2', group='Moving Average')
malen = input.int(defval=7, title='MA Lenght', inline='1', group='Moving Average')
//////////////////// Inputs FOR SPOT AGGREGATION///////////////////////////
i_sym1 = input.bool(true, '', inline='1', group='Spot Symbols')
i_sym2 = input.bool(true, '', inline='2', group='Spot Symbols')
i_sym3 = input.bool(true, '', inline='3', group='Spot Symbols')
i_sym4 = input.bool(true, '', inline='4', group='Spot Symbols')
i_sym5 = input.bool(true, '', inline='5', group='Spot Symbols')
i_sym6 = input.bool(true, '', inline='6', group='Spot Symbols')
i_sym7 = input.bool(true, '', inline='7', group='Spot Symbols')
i_sym8 = input.bool(true, '', inline='8', group='Spot Symbols')
i_sym9 = input.bool(true, '', inline='9', group='Spot Symbols')
i_sym10 = input.bool(false, '', inline='10', group='Spot Symbols')
i_sym11 = input.bool(false, '', inline='11', group='Spot Symbols')
i_sym12 = input.bool(true, '', inline='12', group='Spot Symbols')
i_sym13 = input.bool(true, '', inline='13', group='Spot Symbols')
i_sym14 = input.bool(false, '', inline='14', group='Spot Symbols')
i_sym15 = input.bool(false, '', inline='15', group='Spot Symbols')
i_sym16 = input.bool(false, '', inline='16', group='Spot Symbols')
i_sym1_ticker = input.symbol('BINANCE:BTCUSDT', '', inline='1', group='Spot Symbols')
i_sym2_ticker = input.symbol('BINANCE:BTCBUSD', '', inline='2', group='Spot Symbols')
i_sym3_ticker = input.symbol('BITSTAMP:BTCUSD', '', inline='3', group='Spot Symbols')
i_sym4_ticker = input.symbol('HUOBI:BTCUSDT', '', inline='4', group='Spot Symbols')
i_sym5_ticker = input.symbol('OKEX:BTCUSDT', '', inline='5', group='Spot Symbols')
i_sym6_ticker = input.symbol('COINBASE:BTCUSD', '', inline='6', group='Spot Symbols')
i_sym7_ticker = input.symbol('COINBASE:BTCUSDT', '', inline='7', group='Spot Symbols')
i_sym8_ticker = input.symbol('GEMINI:BTCUSD', '', inline='8', group='Spot Symbols')
i_sym9_ticker = input.symbol('KRAKEN:XBTUSD', '', inline='9', group='Spot Symbols')
i_sym10_ticker = input.symbol('FTX:BTCUSD', '', inline='10', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Spot Symbols')
i_sym11_ticker = input.symbol('FTX:BTCUSDT', '', inline='11', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Spot Symbols')
i_sym12_ticker = input.symbol('BITFINEX:BTCUSD', '', inline='12', group='Spot Symbols')
i_sym13_ticker = input.symbol('BINGX:BTCUSDT', '', inline='13', group='Spot Symbols')
i_sym14_ticker = input.symbol('GATEIO:BTCUSDT', '', inline='14', group='Spot Symbols')
i_sym15_ticker = input.symbol('PHEMEX:BTCUSDT', '', inline='15', group='Spot Symbols')
i_sym16_ticker = input.symbol('BITGET:BTCUSDT', '', inline='16', group='Spot Symbols')
sbase1 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Spot Symbols')
sbase2 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Spot Symbols')
sbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Spot Symbols')
sbase4 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Spot Symbols')
sbase5 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Spot Symbols')
sbase6 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Spot Symbols')
sbase7 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Spot Symbols')
sbase8 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Spot Symbols')
sbase9 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='9', group='Spot Symbols')
sbase10 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='10', group='Spot Symbols')
sbase11 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='11', group='Spot Symbols')
sbase12 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='12', group='Spot Symbols')
sbase13 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='13', group='Spot Symbols')
sbase14 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='14', group='Spot Symbols')
sbase15 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='15', group='Spot Symbols')
sbase16 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='16', group='Spot Symbols')
samount1 = input.float(defval=1, title='#', inline='1', group='Spot Symbols')
samount2 = input.float(defval=1, title='#', inline='2', group='Spot Symbols')
samount3 = input.float(defval=1, title='#', inline='3', group='Spot Symbols')
samount4 = input.float(defval=1, title='#', inline='4', group='Spot Symbols')
samount5 = input.float(defval=1, title='#', inline='5', group='Spot Symbols')
samount6 = input.float(defval=1, title='#', inline='6', group='Spot Symbols')
samount7 = input.float(defval=1, title='#', inline='7', group='Spot Symbols')
samount8 = input.float(defval=1, title='#', inline='8', group='Spot Symbols')
samount9 = input.float(defval=1, title='#', inline='9', group='Spot Symbols')
samount10 = input.float(defval=1, title='#', inline='10', group='Spot Symbols')
samount11 = input.float(defval=1, title='#', inline='11', group='Spot Symbols')
samount12 = input.float(defval=1, title='#', inline='12', group='Spot Symbols')
samount13 = input.float(defval=1, title='#', inline='13', group='Spot Symbols')
samount14 = input.float(defval=1, title='#', inline='14', group='Spot Symbols')
samount15 = input.float(defval=1, title='#', inline='15', group='Spot Symbols')
samount16 = input.float(defval=1, title='#', inline='16', group='Spot Symbols')
//////INPUTS FOR FUTURES AGGREGATION///////////////////
i_sym1b = input.bool(true, '', inline='1', group='Futures Symbols')
i_sym2b = input.bool(true, '', inline='2', group='Futures Symbols')
i_sym3b = input.bool(true, '', inline='3', group='Futures Symbols')
i_sym4b = input.bool(false, '', inline='4', group='Futures Symbols')
i_sym5b = input.bool(false, '', inline='5', group='Futures Symbols')
i_sym6b = input.bool(false, '', inline='6', group='Futures Symbols')
i_sym7b = input.bool(false, '', inline='7', group='Futures Symbols')
i_sym8b = input.bool(true, '', inline='8', group='Futures Symbols')
i_sym9b = input.bool(true, '', inline='9', group='Futures Symbols')
i_sym10b = input.bool(true, '', inline='10', group='Futures Symbols')
i_sym11b = input.bool(false, '', inline='11', group='Futures Symbols')
i_sym12b = input.bool(false, '', inline='12', group='Futures Symbols')
i_sym1b_ticker = input.symbol('BINANCE:BTCUSDTPERP', '', inline='1', group='Futures Symbols')
i_sym2b_ticker = input.symbol('BINANCE:BTCBUSDPERP', '', inline='2', group='Futures Symbols')
i_sym3b_ticker = input.symbol('BYBIT:BTCUSDT.P', '', inline='3', group='Futures Symbols')
i_sym4b_ticker = input.symbol('CME:BTC1!', '', inline='4', tooltip='This volume is reported in 5 BTC and it is recalculated to work properly, beware when changing this symbol',group='Futures Symbols')
i_sym5b_ticker = input.symbol('CME:BTC2!', '', inline='5', tooltip='This volume is reported in 5 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym6b_ticker = input.symbol('CME:MBT1!', '', inline='6', tooltip='This volume is reported in 0.10 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym7b_ticker = input.symbol('CME:MBT2!', '', inline='7', tooltip='This volume is reported in 0.10 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym8b_ticker = input.symbol('PHEMEX:BTCUSDPERP', '', inline='8', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym9b_ticker = input.symbol('OKEX:BTCUSDT.P', '', inline='9', tooltip='This volume is reported in 100x BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym10b_ticker = input.symbol('BITMEX:XBTUSDT', '', inline='10', tooltip='This volume is reported as 1 million per BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym11b_ticker = input.symbol('BITGET:BTCUSDT.P', '', inline='11', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol - THIS IS NOT REPORTED IN REAL TIME', group='Futures Symbols')
i_sym12b_ticker = input.symbol('OKEX:BTCUSDT.P', '', inline='12', group='Futures Symbols')
fbase1 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Futures Symbols')
fbase2 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Futures Symbols')
fbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Futures Symbols')
fbase4 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Futures Symbols')
fbase5 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Futures Symbols')
fbase6 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Futures Symbols')
fbase7 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Futures Symbols')
fbase8 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Futures Symbols')
fbase9 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='9', group='Futures Symbols')
fbase10 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='10', group='Futures Symbols')
fbase11 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='11', group='Futures Symbols')
fbase12 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='12', group='Futures Symbols')
famount1 = input.float(defval=1, title='#', inline='1', group='Futures Symbols')
famount2 = input.float(defval=1, title='#', inline='2', group='Futures Symbols')
famount3 = input.float(defval=1, title='#', inline='3', group='Futures Symbols')
famount4 = input.float(defval=5, title='#', inline='4', group='Futures Symbols')
famount5 = input.float(defval=5, title='#', inline='5', group='Futures Symbols')
famount6 = input.float(defval=0.1, title='#', inline='6', group='Futures Symbols')
famount7 = input.float(defval=0.1, title='#', inline='7', group='Futures Symbols')
famount8 = input.float(defval=1, title='#', inline='8', group='Futures Symbols')
famount9 = input.float(defval=0.01, title='#', inline='9', group='Futures Symbols')
famount10 = input.float(defval=0.000001, title='#', inline='10', group='Futures Symbols')
famount11 = input.float(defval=1, title='#', inline='11', group='Futures Symbols')
famount12 = input.float(defval=1, title='#', inline='12', group='Futures Symbols')
//, tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol'
////////////////////////////////////////////////////////////////////
//////INPUTS FOR PERP AGGREGATION///////////////////
i_sym1c = input.bool(true, '', inline='1', group='Perpetuals Symbols')
i_sym2c = input.bool(true, '', inline='2', group='Perpetuals Symbols')
i_sym3c = input.bool(true, '', inline='3', group='Perpetuals Symbols')
i_sym4c = input.bool(true, '', inline='4', group='Perpetuals Symbols')
i_sym5c = input.bool(false, '', inline='5', group='Perpetuals Symbols')
i_sym6c = input.bool(true, '', inline='6', group='Perpetuals Symbols')
i_sym7c = input.bool(true, '', inline='7', group='Perpetuals Symbols')
i_sym8c = input.bool(true, '', inline='8', group='Perpetuals Symbols')
i_sym1c_ticker = input.symbol('BINANCE:BTCPERP', '', inline='1', tooltip='This volume is reported in blocks of 100 USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym2c_ticker = input.symbol('OKEX:BTCUSD.P', '', inline='2', tooltip='This volume is reported in blocks of 100 USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym3c_ticker = input.symbol('HUOBI:BTCUSD.P', '', inline='3', group='Perpetuals Symbols')
i_sym4c_ticker = input.symbol('PHEMEX:BTCPERP', '', inline='4', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym5c_ticker = input.symbol('FTX:BTCPERP', '', inline='5', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol' ,group='Perpetuals Symbols')
i_sym6c_ticker = input.symbol('BYBIT:BTCUSD.P', '', inline='6', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym7c_ticker = input.symbol('DERIBIT:BTCUSD.P', '', inline='7', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym8c_ticker = input.symbol('BITMEX:XBTUSD.P', '', inline='8', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
pbase1 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Perpetuals Symbols')
pbase2 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Perpetuals Symbols')
pbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Perpetuals Symbols')
pbase4 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Perpetuals Symbols')
pbase5 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Perpetuals Symbols')
pbase6 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Perpetuals Symbols')
pbase7 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Perpetuals Symbols')
pbase8 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Perpetuals Symbols')
pamount1 = input.float(defval=100, title='#', inline='1', group='Perpetuals Symbols')
pamount2 = input.float(defval=100, title='#', inline='2', group='Perpetuals Symbols')
pamount3 = input.float(defval=1, title='#', inline='3', group='Perpetuals Symbols')
pamount4 = input.float(defval=1, title='#', inline='4', group='Perpetuals Symbols')
pamount5 = input.float(defval=1, title='#', inline='5', group='Perpetuals Symbols')
pamount6 = input.float(defval=1, title='#', inline='6', group='Perpetuals Symbols')
pamount7 = input.float(defval=1, title='#', inline='7', group='Perpetuals Symbols')
pamount8 = input.float(defval=1, title='#', inline='8', group='Perpetuals Symbols')
////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////AGGREGATED VOLUME CALCULATION///////////////////////
//// VOLUME REQUEST FUNCTION//////////////////////////
f_volume(_ticker) =>
request.security(_ticker, timeframe.period, volume)
//////////////////////////////////////////////////////////
var float finvol = 0
if aggr==true///////////SPOT////////////////////////////////////////////////////////////////////
v1x = (i_sym1 ? f_volume(i_sym1_ticker) : 0)
v1 = sbase1=='Coin' ? v1x*samount1 : sbase1=='USD' or sbase1=='Other' ? (v1x*samount1)/ohlc4 : v1x
v2x = (i_sym2 ? f_volume(i_sym2_ticker) : 0)
v2 = sbase2=='Coin' ? v2x*samount2 : sbase2=='USD' or sbase2=='Other' ? (v2x*samount2)/ohlc4 : v2x
v3x = (i_sym3 ? f_volume(i_sym3_ticker) : 0)
v3 = sbase2=='Coin' ? v3x*samount3 : sbase3=='USD' or sbase3=='Other' ? (v3x*samount4)/ohlc4 : v3x
v4x = (i_sym4 ? f_volume(i_sym4_ticker) : 0)
v4 = sbase4=='Coin' ? v4x*samount4 : sbase4=='USD' or sbase4=='Other' ? (v4x*samount4)/ohlc4 : v4x
v5x = (i_sym5 ? f_volume(i_sym5_ticker) : 0)
v5 = sbase5=='Coin' ? v5x*samount5 : sbase5=='USD' or sbase5=='Other' ? (v5x*samount5)/ohlc4 : v5x
v6x = (i_sym6 ? f_volume(i_sym6_ticker) : 0)
v6 = sbase6=='Coin' ? v6x*samount6 : sbase6=='USD' or sbase6=='Other' ? (v6x*samount6)/ohlc4 : v6x
v7x = (i_sym7 ? f_volume(i_sym7_ticker) : 0)
v7 = sbase7=='Coin' ? v7x*samount7 : sbase7=='USD' or sbase7=='Other' ? (v7x*samount7)/ohlc4 : v7x
v8x = (i_sym8 ? f_volume(i_sym8_ticker) : 0)
v8 = sbase8=='Coin' ? v8x*samount8 : sbase8=='USD' or sbase8=='Other' ? (v8x*samount8)/ohlc4 : v8x
v9x = (i_sym9 ? f_volume(i_sym9_ticker) : 0)
v9 = sbase9=='Coin' ? v9x*samount9 : sbase9=='USD' or sbase9=='Other' ? (v9x*samount9)/ohlc4 : v9x
v10x = (i_sym10 ? f_volume(i_sym10_ticker) : 0) //FTX reported in usd
v10 = sbase10=='Coin' ? v10x*samount10 : sbase10=='USD' or sbase10=='Other' ? (v10x*samount10)/ohlc4 : v10x
v11x = (i_sym11 ? f_volume(i_sym11_ticker) : 0) //FTX reported in usd
v11 = sbase11=='Coin' ? v11x*samount11 : sbase11=='USD' or sbase11=='Other' ? (v11x*samount11)/ohlc4 : v11x
v12x = (i_sym12 ? f_volume(i_sym12_ticker) : 0)
v12 = sbase12=='Coin' ? v12x*samount12 : sbase12=='USD' or sbase12=='Other' ? (v12x*samount10)/ohlc4 : v12x
v13x = (i_sym13 ? f_volume(i_sym13_ticker) : 0)
v13 = sbase13=='Coin' ? v13x*samount13 : sbase13=='USD' or sbase13=='Other' ? (v13x*samount13)/ohlc4 : v13x
v14x = (i_sym14 ? f_volume(i_sym14_ticker) : 0)
v14 = sbase14=='Coin' ? v14x*samount14 : sbase14=='USD' or sbase14=='Other' ? (v14x*samount14)/ohlc4 : v14x
v15x = (i_sym15 ? f_volume(i_sym15_ticker) : 0)
v15 = sbase15=='Coin' ? v15x*samount15 : sbase15=='USD' or sbase15=='Other' ? (v15x*samount15)/ohlc4 : v15x
v16x = (i_sym16 ? f_volume(i_sym16_ticker) : 0)
v16 = sbase16=='Coin' ? v16x*samount16 : sbase16=='USD' or sbase16=='Other' ? (v16x*samount16)/ohlc4 : v16x
vsf=v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16
///////////////////////////////////////////////////////////////////////////////////
///////////////////////FUTURES////////////////////////////////////////////////////
v1bx = (i_sym1b ? f_volume(i_sym1b_ticker) : 0)
v1b = fbase1=='Coin' ? v1bx*famount1 : fbase1=='USD' or fbase1=='Other' ? (v1bx*famount1)/ohlc4 : v1bx
v2bx = (i_sym2b ? f_volume(i_sym2b_ticker) : 0)
v2b = fbase2=='Coin' ? v2bx*famount2 : fbase2=='USD' or fbase2=='Other' ? (v2bx*famount2)/ohlc4 : v2bx
v3bx = (i_sym3b ? f_volume(i_sym3b_ticker) : 0)
v3b = fbase3=='Coin' ? v3bx*famount3 : fbase3=='USD' or fbase3=='Other' ? (v3bx*famount3)/ohlc4 : v3bx
v4bx =(i_sym4b ? f_volume(i_sym4b_ticker) : 0) //CME NORMAL (each contract reported equals 5btc)
v4b = fbase4=='Coin' ? v4bx*famount4 : fbase4=='USD' or fbase4=='Other' ? (v4bx*famount4)/ohlc4 : v4bx
v5bx = (i_sym5b ? f_volume(i_sym5b_ticker) : 0)//CME NORMAL (each contract reported equals 5btc)
v5b = fbase5=='Coin' ? v5bx*famount5 : fbase5=='USD' or fbase5=='Other' ? (v5bx*famount5)/ohlc4 : v5bx
v6bx = (i_sym6b ? f_volume(i_sym6b_ticker) : 0)//CME mini (each contract reported equals 0.60btc)
v6b = fbase6=='Coin' ? v6bx*famount6 : fbase6=='USD' or fbase6=='Other' ? (v6bx*famount6)/ohlc4 : v6bx
v7bx = (i_sym7b ? f_volume(i_sym7b_ticker) : 0)//CME mini (each contract reported equals 0.7btc)
v7b = fbase7=='Coin' ? v7bx*famount7 : fbase7=='USD' or fbase7=='Other' ? (v7bx*famount7)/ohlc4 : v7bx
v8bx = (i_sym8b ? f_volume(i_sym8b_ticker) : 0)// PHEMEX reported in usd
v8b = fbase8=='Coin' ? v8bx*famount8 : fbase8=='USD' or fbase8=='Other' ? (v8bx*famount8)/ohlc4 : v8bx
v9bx = (i_sym9b ? f_volume(i_sym9b_ticker) : 0)// OKEX reported in 900xBTC, meaning every 900 contracts is only one
v9b = fbase9=='Coin' ? v9bx*famount9 : fbase9=='USD' or fbase9=='Other' ? (v9bx*famount9)/ohlc4 : v9bx
v10bx = (i_sym10b ? f_volume(i_sym10b_ticker) : 0)// BITMEX REPORTED IN 1 MILLION BTC, MEANING EACH MILLION CONTRACTS ON TV REPRESENT 1 BTC
v10b = fbase10=='Coin' ? v1bx*famount10 : fbase10=='USD' or fbase10=='Other' ? (v10bx*famount10)/ohlc4 : v10bx
v11bx = (i_sym11b ? f_volume(i_sym11b_ticker) : 0)// BITGET REPORTED IN USD - TURNED OFF BECAUSE DOESNT PROVIDE REAL TIME DATA
v11b = fbase11=='Coin' ? v11bx*famount11 : fbase11=='USD' or fbase11=='Other' ? (v11bx*famount11)/ohlc4 : v11bx
v12bx = (i_sym12b ? f_volume(i_sym12b_ticker) : 0)
v12b = fbase12=='Coin' ? v12bx*famount12 : fbase12=='USD' or fbase12=='Other' ? (v12bx*famount12)/ohlc4 : v12bx
vff=v1b+v2b+v3b+v4b+v5b+v6b+v7b+v8b+v9b+v10b+v11b+v12b
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////PERPS///////////////////////////////////////////////////////////
v1cx = (i_sym1c ? f_volume(i_sym1c_ticker) : 0)//BINANCE REPORTED IN BLOCKS OF 100 USD, MEANING EACH CONTRACT REPORTED IS EQUAL TO 100 USD
v1c = pbase1=='Coin' ? v1cx*pamount1 : pbase1=='USD' or pbase1=='Other' ? (v1cx*pamount1)/ohlc4 : v1cx
v2cx = (i_sym2c ? f_volume(i_sym2c_ticker) : 0)//OKEX REPORTED IN BLOCKS OF 100 USD, MEANING EACH CONTRACT REPORTED IS EQUAL TO 100 USD
v2c = pbase2=='Coin' ? v2cx*pamount2 : pbase2=='USD' or pbase2=='Other' ? (v2cx*pamount2)/ohlc4 : v2cx
v3cx = (i_sym3c ? f_volume(i_sym3c_ticker) : 0)// HUOBI REPORTED IN BTC
v3c = pbase3=='Coin' ? v3cx*pamount3 : pbase3=='USD' or pbase3=='Other' ? (v3cx*pamount3)/ohlc4 : v3cx
v4cx =(i_sym4c ? f_volume(i_sym4c_ticker) : 0)// PHEMEX REPORTED IN USD
v4c = pbase4=='Coin' ? v4cx*pamount4 : pbase4=='USD' or pbase4=='Other' ? (v4cx*pamount4)/ohlc4 : v4cx
v5cx = (i_sym5c ? f_volume(i_sym5c_ticker) : 0)// FTX REPORTED IN USD
v5c = pbase5=='Coin' ? v5cx*pamount5 : pbase5=='USD' or pbase5=='Other' ? (v5cx*pamount5)/ohlc4 : v5cx
v6cx = (i_sym6c ? f_volume(i_sym6c_ticker) : 0)//BYBIT REPORTED IN USD
v6c = pbase6=='Coin' ? v6cx*pamount6 : pbase6=='USD' or pbase6=='Other' ? (v6cx*pamount6)/ohlc4 : v6cx
v7cx = (i_sym7c ? f_volume(i_sym7c_ticker) : 0)//DERIBIT REPORTED IN USD
v7c = pbase7=='Coin' ? v7cx*pamount7 : pbase7=='USD' or pbase7=='Other' ? (v7cx*pamount7)/ohlc4 : v7cx
v8cx = (i_sym8c ? f_volume(i_sym8c_ticker) : 0)//BITMEX REPORTED IN USD
v8c = pbase8=='Coin' ? v8cx*pamount8 : pbase8=='USD' or pbase8=='Other' ? (v8cx*pamount8)/ohlc4 : v8cx
vpf=v1c+v2c+v3c+v4c+v5c+v6c+v7c+v8c
///////////////////////////////////////////////////////////////////////////////////////
////////////////////ALL DERIV VOLUME//////////////////////////////////////////////////////////////////
alldvol = vff + vpf
/////////////////////////////////////////////////////////////////////////////////////////
////////////////////ALL VOLUME//////////////////////////////////////////////////////////////////
allvol = vsf + vff + vpf
/////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////FINAL AGGREGATION SELECTION/////////////////////////////////////////
if markettype == 'Spot'
finvol := vsf
finvol
else if markettype == 'Futures'
finvol := vff
finvol
else if markettype == 'Perp'
finvol := vpf
finvol
else if markettype == 'Derivatives F+P'
finvol := alldvol
finvol
else if markettype == 'Spot+Derivs'
finvol := allvol
finvol
else if aggr==false
finvol := volume
///////////////////////////////////AGGREGATED OR BY CHART////////////////////////////////////////////////
vol = finvol
// PRESSURE ALGORITHMS AND VARIABLES
TR = ta.atr(1)
// Bull And Bear "Power-Balance" by Vadim Gimelfarb Algorithm's
BP = close<open ? (close[1]<open ? math.max(high-close[1], close-low) : math.max(high-open, close-low)) : (close>open ? (close[1]>open ? high-low : math.max(open-close[1], high-low)) : (high-close>close-low ? (close[1]<open ? math.max(high-close[1],close-low) : high-open) : (high-close<close-low ? (close[1]>open ? high-low : math.max(open-close[1], high-low)) : (close[1]>open ? math.max(high-open, close-low) : (close[1]<open ? math.max(open-close[1], high-low) : high-low)))))
SP = close<open ? (close[1]>open ? math.max(close[1]-open, high-low): high-low) : (close>open ? (close[1]>open ? math.max(close[1]-low, high-close) : math.max(open-low, high-close)) : (high-close>close-low ? (close[1]>open ? math.max(close[1]-open, high-low) : high-low) : (high-close<close-low ? (close[1]>open ? math.max(close[1]-low, high-close) : open-low) : (close[1]>open ? math.max(close[1]-open, high-low) : (close[1]<open ? math.max(open-low, high-close) : high-low)))))
TP = BP+SP
// RAW Pressure Volume Calculations
BPV = (BP/TP)*vol
SPV = (SP/TP)*vol
TPV = BPV+SPV
BPVavg = ta.ema(ta.ema(BPV,signal),signal)
SPVavg = ta.ema(ta.ema(SPV,signal),signal)
TPVavg = ta.ema(ta.wma(TPV,signal),signal)
/////////////////////BUY SELL PRESSURE SIGNAL//////////////////////////////////
rSPAcon = -math.abs(SPVavg)
deltbsp = BPVavg + rSPAcon
///////////////BuySell Pressure///////////////////
plot(disp=='Buy/Sell Pressure' or disp=='Buy/Sell Pressure + Delta' ? rSPAcon: na, color=color.maroon, title="Sell Vol Pressure", style=plot.style_line, linewidth=2)
plot(disp=='Buy/Sell Pressure' or disp=='Buy/Sell Pressure + Delta' ? BPVavg : na, color=color.olive, title="Buy Vol Pressure", style=plot.style_line, linewidth=2)
//plot(TPVavg, color=color.red, title="TOTAL Vol Pressure", style=plot.style_line, linewidth=2)
////////////////////Delta plot///////////////////////////
dp = plot(disp=='Delta' or disp=='Buy/Sell Pressure + Delta' ? deltbsp : na , title='Delta Buy Sell Pressure', color=color.blue, style=plot.style_line, linewidth=2)
/////////////////////////HORIZONTAL 0 LINE////////////////////////////
hline(0, title='Zero Line', color=color.black, linestyle=hline.style_dashed, linewidth=1)
hl = plot(disp=='Delta' or disp=='Buy/Sell Pressure + Delta' ? 0 : na , color=color.new(color.black,100), editable=false)
////////////FILL ACCORDING TO SIDE
var filcol = color.blue
if deltbsp > 0
filcol := color.new(color.green, 75)
else if deltbsp < 0
filcol := color.new(color.red, 75)
fill(dp, hl, color=filcol, fillgaps=true )
////////////////////PLOT MAs SWITCH ALTERNATIVE////////////////////////////////
masrc = deltbsp
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
maline = ma(masrc, malen, matype)
/////////////////////////////////////
maplot = plot(addma and (disp=='Delta' or disp=='Buy/Sell Pressure + Delta') ? maline : na, title='Moving Average', color=color.purple)
////////MA FILL
var fillcol = color.green
if (maline > deltbsp)
fillcol := color.new(color.red, 65)
else if (maline < deltbsp)
fillcol := color.new(color.green, 65)
fill(dp , maplot , title='Moving Average Fill', color=fillcol, fillgaps=true)
|
Hotch DMI+OBV+RSI Confluence | https://www.tradingview.com/script/asHrEz8N-Hotch-DMI-OBV-RSI-Confluence/ | Hotchachachaaa | https://www.tradingview.com/u/Hotchachachaaa/ | 169 | study | 5 | MPL-2.0 | /// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©Hotchachachaaa, requested creation by @AceJeff37---Discord @PheonixAlgo(RIP) for at least an approximation of his code for RSI divergence tags.
//@version=5
//
indicator("DMI+OBV+RSI", overlay=false)
//////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------Code Insert----------------------------------------------------------
normalize(_src, _min, _max) =>
var _historicMin = 10e10
var _historicMax = -10e10
_historicMin := math.min(nz(_src, _historicMin), _historicMin)
_historicMax := math.max(nz(_src, _historicMax), _historicMax)
_min + (_max - _min) * (_src - _historicMin) / math.max(_historicMax - _historicMin, 10e-10)
normalisedObv = normalize(ta.obv, 0, 50)
smaLength = input(title="OBV SMA length", defval=55)
normalisedOBVsma = ta.sma(normalisedObv, smaLength)
//plot(normalisedObv, color=color.gray, linewidth=2, title="OBV")
//plot(normalisedOBVsma, color=color.orange, linewidth=1, title="OBV SMA")
col_grow_above = input(#26A69A, "Above Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
scaling= input.int(title="Scaling factor for OBV",minval=1,defval=1)
hist=(normalisedObv-normalisedOBVsma)*scaling
plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
adxLength = input.int(14, minval=1, title="DI length")
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
[diplus, diminus, adx] = ta.dmi(adxLength, lensig)
adxSma = input.int(2, minval=1, title="ADX SMA length")
normalisedAdx = normalize(ta.sma(adx, adxSma), 0, 100)
normalisedDirPlus = normalize(ta.sma(diplus, adxSma), 0, 100)
normalisedDirMinus = normalize(ta.sma(diminus, adxSma), 0, 100)
//plot(normalisedAdx, color=normalisedDirPlus[1] > normalisedDirMinus and normalisedDirPlus > normalisedDirMinus ? color.green : color.red, linewidth=2)
//plot(normalisedDirPlus, color=color.green, title="+DI")
//plot(normalisedDirMinus, color=color.red, title="-DI")
secondEdge = hline(70, title="secondEdge")
thirdEdge = hline(50, title="thirdEdge")
fourthEdge = hline(30, title="fourthEdge")
bullColor = color.new(color.lime,25)
bearColor = color.new(color.fuchsia,25)
// Generate a bull gradient when position is 50-100%, bear gradient when position is 0-50%.
bColor = if normalisedDirPlus > normalisedDirMinus
color.from_gradient(normalisedAdx,0, 100, color.new(bullColor, 100), bullColor)
else
color.from_gradient(100-normalisedAdx,0, 100, bearColor, color.new(bearColor, 100))
//bgcolor(bColor)
fill(secondEdge, fourthEdge, color=bColor)
////////////////////////////////////RSI Divergence////////////////////////////////////////////////
lenrsidiv = input.int(title="RSI Period", minval=1, defval=14)
srcrsidiv = input(title="RSI Source", defval=close)
lbR = 5
//input(title="Pivot Lookback Right", defval=5)
lbL = 5
//input(title="Pivot Lookback Left", defval=5)
rangeUpper = 60
//input(title="Max of Lookback Range", defval=60)
rangeLower = 5
//input(title="Min of Lookback Range", defval=5)
plotBull = input.bool(title="Plot Bullish", defval=true)
plotHiddenBull = input.bool(title="Plot Hidden Bullish", defval=true)
plotBear = input.bool(title="Plot Bearish", defval=true)
plotHiddenBear = input.bool(title="Plot Hidden Bearish", defval=true)
bearColorrsidiv = color.red
bullColorrsidiv = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
osc = ta.rsi(srcrsidiv, lenrsidiv)
// ### Smoothed MA
showSmma = input.bool(title="Show Moving Average", defval=true, group = "Smoothed MA")
smmaLen = 50
//input(50, minval=1, title="SMMA Length", group = "Smoothed MA")
smmaSrc = osc
smma = 0.0
smma := na(smma[1]) ? ta.sma(smmaSrc, smmaLen) : (smma[1] * (smmaLen - 1) + smmaSrc) / smmaLen
plot(showSmma ? smma : na, linewidth=2, color=color.white)
// End ###
lineColor = (osc > smma) ?color.yellow : color.yellow
plot(osc, title="RSI", linewidth=2, color=lineColor)
hline(50, title="Middle Line", linestyle=hline.style_solid)
// obLevel = hline(70, title="Overbought", linestyle=hline.style_dotted)
// osLevel = hline(30, title="Oversold", linestyle=hline.style_dotted)
//fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)
plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
//------------------------------------------------------------------------------
// Regular Bullish
// Osc: Higher Low
oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
// Price: Lower Low
priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1)
bullCond = plotBull and priceLL and oscHL and plFound
plot(plFound ? osc[lbR] : na,offset=-lbR,title="Regular Bullish",linewidth=2,color=(bullCond ? bullColorrsidiv : noneColor))
plotshape(bullCond ? osc[lbR] : na,offset=-lbR,title="Regular Bullish Label",text=" Bull ",style=shape.labelup,location=location.absolute,color=bullColorrsidiv,textcolor=textColor)
//------------------------------------------------------------------------------
// Hidden Bullish
// Osc: Lower Low
oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
// Price: Higher Low
priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1)
hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound
plot(plFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond ? hiddenBullColor : noneColor))
plotshape( hiddenBullCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish Label", text=" H Bull ", style=shape.labelup, location=location.absolute, color=bullColorrsidiv, textcolor=textColor)
//------------------------------------------------------------------------------
// Regular Bearish
// Osc: Lower High
oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
// Price: Higher High
priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1)
bearCond = plotBear and priceHH and oscLH and phFound
plot(phFound ? osc[lbR] : na, offset=-lbR, title="Regular Bearish", linewidth=2, color=(bearCond ? bearColorrsidiv : noneColor))
plotshape(bearCond ? osc[lbR] : na, offset=-lbR, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=bearColorrsidiv, textcolor=textColor)
//------------------------------------------------------------------------------
// Hidden Bearish
// Osc: Higher High
oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
// Price: Lower High
priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1)
hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound
plot(phFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond ? hiddenBearColor : noneColor))
plotshape(hiddenBearCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=bearColorrsidiv, textcolor=textColor)
// ### Alerts
if bearCond
alert("Bearish Divergence")
else if hiddenBearCond
alert("Hidden Bearish Divergence")
else if bullCond
alert("Bullish Divergence")
else if hiddenBullCond
alert("Hidden Bullish Divergence")
obvcrossup = ta.crossover(normalisedObv,normalisedOBVsma)
obvcrossdown = ta.crossunder(normalisedObv,normalisedOBVsma)
plotshape(obvcrossup, location=location.bottom, color=color.green, style=shape.triangleup, size = size.small )
plotshape(obvcrossdown, location=location.top, color=color.red, style=shape.triangledown, size = size.small )
|
MACD of Aggregated Buy/Sell Pressure - InFinito | https://www.tradingview.com/script/0xTkWBmr-MACD-of-Aggregated-Buy-Sell-Pressure-InFinito/ | In_Finito_ | https://www.tradingview.com/u/In_Finito_/ | 139 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © In_Finito_
// Based of:
// Aggregation by Crypt0rus - https://www.tradingview.com/script/V3q0WkG6-Aggregated-Volume-Colored-Bitcoin-ETH-Altcoins-everything/
// Buy Sell Pressure Convergence/Divergence by Ricardo M Arjona @XeL_Arjona - https://www.tradingview.com/script/NHcilGl8-MARKET-VOLUME-by-BeloTrade-XeL-Arjona/
//Version Update & Exchange Sorting & Exchange Data Normalization by InFinito
//@version=5
indicator("MACD of Aggregated Buy/Sell Pressure", shorttitle="A-B/SCD", format=format.volume, timeframe='')
////////////////////GENERAL INPUTS/////////////////////////////////////////
////////////////////MARKET TYPE INPUT/////////////////////////////////////
aggr = input.bool(defval=true, title='Use Aggregated Data', inline='1', group='Aggregation', tooltip='Disable to check by symbol OR if you want to use this indicator with any other pair than BTC')
markettype = input.string(defval='Spot', title='Market Type Aggregation', options=['Spot', 'Futures' , 'Perp', 'Derivatives F+P', 'Spot+Derivs'], inline='2', group='Aggregation')
////////////////////B/S P MACD INPUTS//////////////////////////////////
signal = input(title="Base for FastMA Periods:", defval=3)
long = input(title="Buy to Sell Conv/Div Lookback:", defval=28)
//////////////////// Inputs FOR SPOT AGGREGATION///////////////////////////
i_sym1 = input.bool(true, '', inline='1', group='Spot Symbols')
i_sym2 = input.bool(true, '', inline='2', group='Spot Symbols')
i_sym3 = input.bool(true, '', inline='3', group='Spot Symbols')
i_sym4 = input.bool(true, '', inline='4', group='Spot Symbols')
i_sym5 = input.bool(true, '', inline='5', group='Spot Symbols')
i_sym6 = input.bool(true, '', inline='6', group='Spot Symbols')
i_sym7 = input.bool(true, '', inline='7', group='Spot Symbols')
i_sym8 = input.bool(true, '', inline='8', group='Spot Symbols')
i_sym9 = input.bool(true, '', inline='9', group='Spot Symbols')
i_sym10 = input.bool(false, '', inline='10', group='Spot Symbols')
i_sym11 = input.bool(false, '', inline='11', group='Spot Symbols')
i_sym12 = input.bool(true, '', inline='12', group='Spot Symbols')
i_sym13 = input.bool(true, '', inline='13', group='Spot Symbols')
i_sym14 = input.bool(false, '', inline='14', group='Spot Symbols')
i_sym15 = input.bool(false, '', inline='15', group='Spot Symbols')
i_sym16 = input.bool(false, '', inline='16', group='Spot Symbols')
i_sym1_ticker = input.symbol('BINANCE:BTCUSDT', '', inline='1', group='Spot Symbols')
i_sym2_ticker = input.symbol('BINANCE:BTCBUSD', '', inline='2', group='Spot Symbols')
i_sym3_ticker = input.symbol('BITSTAMP:BTCUSD', '', inline='3', group='Spot Symbols')
i_sym4_ticker = input.symbol('HUOBI:BTCUSDT', '', inline='4', group='Spot Symbols')
i_sym5_ticker = input.symbol('OKEX:BTCUSDT', '', inline='5', group='Spot Symbols')
i_sym6_ticker = input.symbol('COINBASE:BTCUSD', '', inline='6', group='Spot Symbols')
i_sym7_ticker = input.symbol('COINBASE:BTCUSDT', '', inline='7', group='Spot Symbols')
i_sym8_ticker = input.symbol('GEMINI:BTCUSD', '', inline='8', group='Spot Symbols')
i_sym9_ticker = input.symbol('KRAKEN:XBTUSD', '', inline='9', group='Spot Symbols')
i_sym10_ticker = input.symbol('FTX:BTCUSD', '', inline='10', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Spot Symbols')
i_sym11_ticker = input.symbol('FTX:BTCUSDT', '', inline='11', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Spot Symbols')
i_sym12_ticker = input.symbol('BITFINEX:BTCUSD', '', inline='12', group='Spot Symbols')
i_sym13_ticker = input.symbol('BINGX:BTCUSDT', '', inline='13', group='Spot Symbols')
i_sym14_ticker = input.symbol('GATEIO:BTCUSDT', '', inline='14', group='Spot Symbols')
i_sym15_ticker = input.symbol('PHEMEX:BTCUSDT', '', inline='15', group='Spot Symbols')
i_sym16_ticker = input.symbol('BITGET:BTCUSDT', '', inline='16', group='Spot Symbols')
sbase1 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Spot Symbols')
sbase2 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Spot Symbols')
sbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Spot Symbols')
sbase4 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Spot Symbols')
sbase5 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Spot Symbols')
sbase6 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Spot Symbols')
sbase7 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Spot Symbols')
sbase8 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Spot Symbols')
sbase9 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='9', group='Spot Symbols')
sbase10 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='10', group='Spot Symbols')
sbase11 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='11', group='Spot Symbols')
sbase12 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='12', group='Spot Symbols')
sbase13 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='13', group='Spot Symbols')
sbase14 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='14', group='Spot Symbols')
sbase15 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='15', group='Spot Symbols')
sbase16 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='16', group='Spot Symbols')
samount1 = input.float(defval=1, title='#', inline='1', group='Spot Symbols')
samount2 = input.float(defval=1, title='#', inline='2', group='Spot Symbols')
samount3 = input.float(defval=1, title='#', inline='3', group='Spot Symbols')
samount4 = input.float(defval=1, title='#', inline='4', group='Spot Symbols')
samount5 = input.float(defval=1, title='#', inline='5', group='Spot Symbols')
samount6 = input.float(defval=1, title='#', inline='6', group='Spot Symbols')
samount7 = input.float(defval=1, title='#', inline='7', group='Spot Symbols')
samount8 = input.float(defval=1, title='#', inline='8', group='Spot Symbols')
samount9 = input.float(defval=1, title='#', inline='9', group='Spot Symbols')
samount10 = input.float(defval=1, title='#', inline='10', group='Spot Symbols')
samount11 = input.float(defval=1, title='#', inline='11', group='Spot Symbols')
samount12 = input.float(defval=1, title='#', inline='12', group='Spot Symbols')
samount13 = input.float(defval=1, title='#', inline='13', group='Spot Symbols')
samount14 = input.float(defval=1, title='#', inline='14', group='Spot Symbols')
samount15 = input.float(defval=1, title='#', inline='15', group='Spot Symbols')
samount16 = input.float(defval=1, title='#', inline='16', group='Spot Symbols')
//////INPUTS FOR FUTURES AGGREGATION///////////////////
i_sym1b = input.bool(true, '', inline='1', group='Futures Symbols')
i_sym2b = input.bool(true, '', inline='2', group='Futures Symbols')
i_sym3b = input.bool(true, '', inline='3', group='Futures Symbols')
i_sym4b = input.bool(false, '', inline='4', group='Futures Symbols')
i_sym5b = input.bool(false, '', inline='5', group='Futures Symbols')
i_sym6b = input.bool(false, '', inline='6', group='Futures Symbols')
i_sym7b = input.bool(false, '', inline='7', group='Futures Symbols')
i_sym8b = input.bool(true, '', inline='8', group='Futures Symbols')
i_sym9b = input.bool(true, '', inline='9', group='Futures Symbols')
i_sym10b = input.bool(true, '', inline='10', group='Futures Symbols')
i_sym11b = input.bool(false, '', inline='11', group='Futures Symbols')
i_sym12b = input.bool(false, '', inline='12', group='Futures Symbols')
i_sym1b_ticker = input.symbol('BINANCE:BTCUSDTPERP', '', inline='1', group='Futures Symbols')
i_sym2b_ticker = input.symbol('BINANCE:BTCBUSDPERP', '', inline='2', group='Futures Symbols')
i_sym3b_ticker = input.symbol('BYBIT:BTCUSDT.P', '', inline='3', group='Futures Symbols')
i_sym4b_ticker = input.symbol('CME:BTC1!', '', inline='4', tooltip='This volume is reported in 5 BTC and it is recalculated to work properly, beware when changing this symbol',group='Futures Symbols')
i_sym5b_ticker = input.symbol('CME:BTC2!', '', inline='5', tooltip='This volume is reported in 5 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym6b_ticker = input.symbol('CME:MBT1!', '', inline='6', tooltip='This volume is reported in 0.10 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym7b_ticker = input.symbol('CME:MBT2!', '', inline='7', tooltip='This volume is reported in 0.10 BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym8b_ticker = input.symbol('PHEMEX:BTCUSDPERP', '', inline='8', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym9b_ticker = input.symbol('OKEX:BTCUSDT.P', '', inline='9', tooltip='This volume is reported in 100x BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym10b_ticker = input.symbol('BITMEX:XBTUSDT', '', inline='10', tooltip='This volume is reported as 1 million per BTC and it is recalculated to work properly, beware when changing this symbol', group='Futures Symbols')
i_sym11b_ticker = input.symbol('BITGET:BTCUSDT.P', '', inline='11', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol - THIS IS NOT REPORTED IN REAL TIME', group='Futures Symbols')
i_sym12b_ticker = input.symbol('OKEX:BTCUSDT.P', '', inline='12', group='Futures Symbols')
fbase1 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Futures Symbols')
fbase2 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Futures Symbols')
fbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Futures Symbols')
fbase4 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Futures Symbols')
fbase5 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Futures Symbols')
fbase6 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Futures Symbols')
fbase7 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Futures Symbols')
fbase8 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Futures Symbols')
fbase9 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='9', group='Futures Symbols')
fbase10 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='10', group='Futures Symbols')
fbase11 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='11', group='Futures Symbols')
fbase12 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='12', group='Futures Symbols')
famount1 = input.float(defval=1, title='#', inline='1', group='Futures Symbols')
famount2 = input.float(defval=1, title='#', inline='2', group='Futures Symbols')
famount3 = input.float(defval=1, title='#', inline='3', group='Futures Symbols')
famount4 = input.float(defval=5, title='#', inline='4', group='Futures Symbols')
famount5 = input.float(defval=5, title='#', inline='5', group='Futures Symbols')
famount6 = input.float(defval=0.1, title='#', inline='6', group='Futures Symbols')
famount7 = input.float(defval=0.1, title='#', inline='7', group='Futures Symbols')
famount8 = input.float(defval=1, title='#', inline='8', group='Futures Symbols')
famount9 = input.float(defval=0.01, title='#', inline='9', group='Futures Symbols')
famount10 = input.float(defval=0.000001, title='#', inline='10', group='Futures Symbols')
famount11 = input.float(defval=1, title='#', inline='11', group='Futures Symbols')
famount12 = input.float(defval=1, title='#', inline='12', group='Futures Symbols')
//, tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol'
////////////////////////////////////////////////////////////////////
//////INPUTS FOR PERP AGGREGATION///////////////////
i_sym1c = input.bool(true, '', inline='1', group='Perpetuals Symbols')
i_sym2c = input.bool(true, '', inline='2', group='Perpetuals Symbols')
i_sym3c = input.bool(true, '', inline='3', group='Perpetuals Symbols')
i_sym4c = input.bool(true, '', inline='4', group='Perpetuals Symbols')
i_sym5c = input.bool(false, '', inline='5', group='Perpetuals Symbols')
i_sym6c = input.bool(true, '', inline='6', group='Perpetuals Symbols')
i_sym7c = input.bool(true, '', inline='7', group='Perpetuals Symbols')
i_sym8c = input.bool(true, '', inline='8', group='Perpetuals Symbols')
i_sym1c_ticker = input.symbol('BINANCE:BTCPERP', '', inline='1', tooltip='This volume is reported in blocks of 100 USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym2c_ticker = input.symbol('OKEX:BTCUSD.P', '', inline='2', tooltip='This volume is reported in blocks of 100 USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym3c_ticker = input.symbol('HUOBI:BTCUSD.P', '', inline='3', group='Perpetuals Symbols')
i_sym4c_ticker = input.symbol('PHEMEX:BTCPERP', '', inline='4', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym5c_ticker = input.symbol('FTX:BTCPERP', '', inline='5', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol' ,group='Perpetuals Symbols')
i_sym6c_ticker = input.symbol('BYBIT:BTCUSD.P', '', inline='6', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym7c_ticker = input.symbol('DERIBIT:BTCUSD.P', '', inline='7', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
i_sym8c_ticker = input.symbol('BITMEX:XBTUSD.P', '', inline='8', tooltip='This volume is reported in USD instead of BTC and it is recalculated to work properly, beware when changing this symbol', group='Perpetuals Symbols')
pbase1 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='1', group='Perpetuals Symbols')
pbase2 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='2', group='Perpetuals Symbols')
pbase3 = input.string(defval='Coin', title='', options=['Coin', 'USD', 'Other'], inline='3', group='Perpetuals Symbols')
pbase4 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='4', group='Perpetuals Symbols')
pbase5 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='5', group='Perpetuals Symbols')
pbase6 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='6', group='Perpetuals Symbols')
pbase7 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='7', group='Perpetuals Symbols')
pbase8 = input.string(defval='USD', title='', options=['Coin', 'USD', 'Other'], inline='8', group='Perpetuals Symbols')
pamount1 = input.float(defval=100, title='#', inline='1', group='Perpetuals Symbols')
pamount2 = input.float(defval=100, title='#', inline='2', group='Perpetuals Symbols')
pamount3 = input.float(defval=1, title='#', inline='3', group='Perpetuals Symbols')
pamount4 = input.float(defval=1, title='#', inline='4', group='Perpetuals Symbols')
pamount5 = input.float(defval=1, title='#', inline='5', group='Perpetuals Symbols')
pamount6 = input.float(defval=1, title='#', inline='6', group='Perpetuals Symbols')
pamount7 = input.float(defval=1, title='#', inline='7', group='Perpetuals Symbols')
pamount8 = input.float(defval=1, title='#', inline='8', group='Perpetuals Symbols')
////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////AGGREGATED VOLUME CALCULATION///////////////////////
//// VOLUME REQUEST FUNCTION//////////////////////////
f_volume(_ticker) =>
request.security(_ticker, timeframe.period, volume)
//////////////////////////////////////////////////////////
var float finvol = 0
if aggr==true///////////SPOT////////////////////////////////////////////////////////////////////
v1x = (i_sym1 ? f_volume(i_sym1_ticker) : 0)
v1 = sbase1=='Coin' ? v1x*samount1 : sbase1=='USD' or sbase1=='Other' ? (v1x*samount1)/ohlc4 : v1x
v2x = (i_sym2 ? f_volume(i_sym2_ticker) : 0)
v2 = sbase2=='Coin' ? v2x*samount2 : sbase2=='USD' or sbase2=='Other' ? (v2x*samount2)/ohlc4 : v2x
v3x = (i_sym3 ? f_volume(i_sym3_ticker) : 0)
v3 = sbase2=='Coin' ? v3x*samount3 : sbase3=='USD' or sbase3=='Other' ? (v3x*samount4)/ohlc4 : v3x
v4x = (i_sym4 ? f_volume(i_sym4_ticker) : 0)
v4 = sbase4=='Coin' ? v4x*samount4 : sbase4=='USD' or sbase4=='Other' ? (v4x*samount4)/ohlc4 : v4x
v5x = (i_sym5 ? f_volume(i_sym5_ticker) : 0)
v5 = sbase5=='Coin' ? v5x*samount5 : sbase5=='USD' or sbase5=='Other' ? (v5x*samount5)/ohlc4 : v5x
v6x = (i_sym6 ? f_volume(i_sym6_ticker) : 0)
v6 = sbase6=='Coin' ? v6x*samount6 : sbase6=='USD' or sbase6=='Other' ? (v6x*samount6)/ohlc4 : v6x
v7x = (i_sym7 ? f_volume(i_sym7_ticker) : 0)
v7 = sbase7=='Coin' ? v7x*samount7 : sbase7=='USD' or sbase7=='Other' ? (v7x*samount7)/ohlc4 : v7x
v8x = (i_sym8 ? f_volume(i_sym8_ticker) : 0)
v8 = sbase8=='Coin' ? v8x*samount8 : sbase8=='USD' or sbase8=='Other' ? (v8x*samount8)/ohlc4 : v8x
v9x = (i_sym9 ? f_volume(i_sym9_ticker) : 0)
v9 = sbase9=='Coin' ? v9x*samount9 : sbase9=='USD' or sbase9=='Other' ? (v9x*samount9)/ohlc4 : v9x
v10x = (i_sym10 ? f_volume(i_sym10_ticker) : 0) //FTX reported in usd
v10 = sbase10=='Coin' ? v10x*samount10 : sbase10=='USD' or sbase10=='Other' ? (v10x*samount10)/ohlc4 : v10x
v11x = (i_sym11 ? f_volume(i_sym11_ticker) : 0) //FTX reported in usd
v11 = sbase11=='Coin' ? v11x*samount11 : sbase11=='USD' or sbase11=='Other' ? (v11x*samount11)/ohlc4 : v11x
v12x = (i_sym12 ? f_volume(i_sym12_ticker) : 0)
v12 = sbase12=='Coin' ? v12x*samount12 : sbase12=='USD' or sbase12=='Other' ? (v12x*samount10)/ohlc4 : v12x
v13x = (i_sym13 ? f_volume(i_sym13_ticker) : 0)
v13 = sbase13=='Coin' ? v13x*samount13 : sbase13=='USD' or sbase13=='Other' ? (v13x*samount13)/ohlc4 : v13x
v14x = (i_sym14 ? f_volume(i_sym14_ticker) : 0)
v14 = sbase14=='Coin' ? v14x*samount14 : sbase14=='USD' or sbase14=='Other' ? (v14x*samount14)/ohlc4 : v14x
v15x = (i_sym15 ? f_volume(i_sym15_ticker) : 0)
v15 = sbase15=='Coin' ? v15x*samount15 : sbase15=='USD' or sbase15=='Other' ? (v15x*samount15)/ohlc4 : v15x
v16x = (i_sym16 ? f_volume(i_sym16_ticker) : 0)
v16 = sbase16=='Coin' ? v16x*samount16 : sbase16=='USD' or sbase16=='Other' ? (v16x*samount16)/ohlc4 : v16x
vsf=v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16
///////////////////////////////////////////////////////////////////////////////////
///////////////////////FUTURES////////////////////////////////////////////////////
v1bx = (i_sym1b ? f_volume(i_sym1b_ticker) : 0)
v1b = fbase1=='Coin' ? v1bx*famount1 : fbase1=='USD' or fbase1=='Other' ? (v1bx*famount1)/ohlc4 : v1bx
v2bx = (i_sym2b ? f_volume(i_sym2b_ticker) : 0)
v2b = fbase2=='Coin' ? v2bx*famount2 : fbase2=='USD' or fbase2=='Other' ? (v2bx*famount2)/ohlc4 : v2bx
v3bx = (i_sym3b ? f_volume(i_sym3b_ticker) : 0)
v3b = fbase3=='Coin' ? v3bx*famount3 : fbase3=='USD' or fbase3=='Other' ? (v3bx*famount3)/ohlc4 : v3bx
v4bx =(i_sym4b ? f_volume(i_sym4b_ticker) : 0) //CME NORMAL (each contract reported equals 5btc)
v4b = fbase4=='Coin' ? v4bx*famount4 : fbase4=='USD' or fbase4=='Other' ? (v4bx*famount4)/ohlc4 : v4bx
v5bx = (i_sym5b ? f_volume(i_sym5b_ticker) : 0)//CME NORMAL (each contract reported equals 5btc)
v5b = fbase5=='Coin' ? v5bx*famount5 : fbase5=='USD' or fbase5=='Other' ? (v5bx*famount5)/ohlc4 : v5bx
v6bx = (i_sym6b ? f_volume(i_sym6b_ticker) : 0)//CME mini (each contract reported equals 0.60btc)
v6b = fbase6=='Coin' ? v6bx*famount6 : fbase6=='USD' or fbase6=='Other' ? (v6bx*famount6)/ohlc4 : v6bx
v7bx = (i_sym7b ? f_volume(i_sym7b_ticker) : 0)//CME mini (each contract reported equals 0.7btc)
v7b = fbase7=='Coin' ? v7bx*famount7 : fbase7=='USD' or fbase7=='Other' ? (v7bx*famount7)/ohlc4 : v7bx
v8bx = (i_sym8b ? f_volume(i_sym8b_ticker) : 0)// PHEMEX reported in usd
v8b = fbase8=='Coin' ? v8bx*famount8 : fbase8=='USD' or fbase8=='Other' ? (v8bx*famount8)/ohlc4 : v8bx
v9bx = (i_sym9b ? f_volume(i_sym9b_ticker) : 0)// OKEX reported in 900xBTC, meaning every 900 contracts is only one
v9b = fbase9=='Coin' ? v9bx*famount9 : fbase9=='USD' or fbase9=='Other' ? (v9bx*famount9)/ohlc4 : v9bx
v10bx = (i_sym10b ? f_volume(i_sym10b_ticker) : 0)// BITMEX REPORTED IN 1 MILLION BTC, MEANING EACH MILLION CONTRACTS ON TV REPRESENT 1 BTC
v10b = fbase10=='Coin' ? v1bx*famount10 : fbase10=='USD' or fbase10=='Other' ? (v10bx*famount10)/ohlc4 : v10bx
v11bx = (i_sym11b ? f_volume(i_sym11b_ticker) : 0)// BITGET REPORTED IN USD - TURNED OFF BECAUSE DOESNT PROVIDE REAL TIME DATA
v11b = fbase11=='Coin' ? v11bx*famount11 : fbase11=='USD' or fbase11=='Other' ? (v11bx*famount11)/ohlc4 : v11bx
v12bx = (i_sym12b ? f_volume(i_sym12b_ticker) : 0)
v12b = fbase12=='Coin' ? v12bx*famount12 : fbase12=='USD' or fbase12=='Other' ? (v12bx*famount12)/ohlc4 : v12bx
vff=v1b+v2b+v3b+v4b+v5b+v6b+v7b+v8b+v9b+v10b+v11b+v12b
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////PERPS///////////////////////////////////////////////////////////
v1cx = (i_sym1c ? f_volume(i_sym1c_ticker) : 0)//BINANCE REPORTED IN BLOCKS OF 100 USD, MEANING EACH CONTRACT REPORTED IS EQUAL TO 100 USD
v1c = pbase1=='Coin' ? v1cx*pamount1 : pbase1=='USD' or pbase1=='Other' ? (v1cx*pamount1)/ohlc4 : v1cx
v2cx = (i_sym2c ? f_volume(i_sym2c_ticker) : 0)//OKEX REPORTED IN BLOCKS OF 100 USD, MEANING EACH CONTRACT REPORTED IS EQUAL TO 100 USD
v2c = pbase2=='Coin' ? v2cx*pamount2 : pbase2=='USD' or pbase2=='Other' ? (v2cx*pamount2)/ohlc4 : v2cx
v3cx = (i_sym3c ? f_volume(i_sym3c_ticker) : 0)// HUOBI REPORTED IN BTC
v3c = pbase3=='Coin' ? v3cx*pamount3 : pbase3=='USD' or pbase3=='Other' ? (v3cx*pamount3)/ohlc4 : v3cx
v4cx =(i_sym4c ? f_volume(i_sym4c_ticker) : 0)// PHEMEX REPORTED IN USD
v4c = pbase4=='Coin' ? v4cx*pamount4 : pbase4=='USD' or pbase4=='Other' ? (v4cx*pamount4)/ohlc4 : v4cx
v5cx = (i_sym5c ? f_volume(i_sym5c_ticker) : 0)// FTX REPORTED IN USD
v5c = pbase5=='Coin' ? v5cx*pamount5 : pbase5=='USD' or pbase5=='Other' ? (v5cx*pamount5)/ohlc4 : v5cx
v6cx = (i_sym6c ? f_volume(i_sym6c_ticker) : 0)//BYBIT REPORTED IN USD
v6c = pbase6=='Coin' ? v6cx*pamount6 : pbase6=='USD' or pbase6=='Other' ? (v6cx*pamount6)/ohlc4 : v6cx
v7cx = (i_sym7c ? f_volume(i_sym7c_ticker) : 0)//DERIBIT REPORTED IN USD
v7c = pbase7=='Coin' ? v7cx*pamount7 : pbase7=='USD' or pbase7=='Other' ? (v7cx*pamount7)/ohlc4 : v7cx
v8cx = (i_sym8c ? f_volume(i_sym8c_ticker) : 0)//BITMEX REPORTED IN USD
v8c = pbase8=='Coin' ? v8cx*pamount8 : pbase8=='USD' or pbase8=='Other' ? (v8cx*pamount8)/ohlc4 : v8cx
vpf=v1c+v2c+v3c+v4c+v5c+v6c+v7c+v8c
///////////////////////////////////////////////////////////////////////////////////////
////////////////////ALL DERIV VOLUME//////////////////////////////////////////////////////////////////
alldvol = vff + vpf
/////////////////////////////////////////////////////////////////////////////////////////
////////////////////ALL VOLUME//////////////////////////////////////////////////////////////////
allvol = vsf + vff + vpf
/////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////FINAL AGGREGATION SELECTION/////////////////////////////////////////
if markettype == 'Spot'
finvol := vsf
finvol
else if markettype == 'Futures'
finvol := vff
finvol
else if markettype == 'Perp'
finvol := vpf
finvol
else if markettype == 'Derivatives F+P'
finvol := alldvol
finvol
else if markettype == 'Spot+Derivs'
finvol := allvol
finvol
else if aggr==false
finvol := volume
///////////////////////////////////AGGREGATED OR BY CHART////////////////////////////////////////////////
vol = finvol
// PRESSURE ALGORITHMS AND VARIABLES
TR = ta.atr(1)
// Bull And Bear "Power-Balance" by Vadim Gimelfarb Algorithm's
BP = close<open ? (close[1]<open ? math.max(high-close[1], close-low) : math.max(high-open, close-low)) : (close>open ? (close[1]>open ? high-low : math.max(open-close[1], high-low)) : (high-close>close-low ? (close[1]<open ? math.max(high-close[1],close-low) : high-open) : (high-close<close-low ? (close[1]>open ? high-low : math.max(open-close[1], high-low)) : (close[1]>open ? math.max(high-open, close-low) : (close[1]<open ? math.max(open-close[1], high-low) : high-low)))))
SP = close<open ? (close[1]>open ? math.max(close[1]-open, high-low): high-low) : (close>open ? (close[1]>open ? math.max(close[1]-low, high-close) : math.max(open-low, high-close)) : (high-close>close-low ? (close[1]>open ? math.max(close[1]-open, high-low) : high-low) : (high-close<close-low ? (close[1]>open ? math.max(close[1]-low, high-close) : open-low) : (close[1]>open ? math.max(close[1]-open, high-low) : (close[1]<open ? math.max(open-low, high-close) : high-low)))))
TP = BP+SP
// RAW Pressure Volume Calculations
BPV = (BP/TP)*vol
SPV = (SP/TP)*vol
TPV = BPV+SPV
BPVavg = ta.ema(ta.ema(BPV,signal),signal)
SPVavg = ta.ema(ta.ema(SPV,signal),signal)
TPVavg = ta.ema(ta.wma(TPV,signal),signal)
// Karthik Marar's Pressure Volume Normalized Version (XeL-MOD.)
VN = vol/ta.ema(vol,long)
BPN = ((BP/ta.ema(BP,long))*VN)*100
SPN = ((SP/ta.ema(SP,long))*VN)*100
TPN = BPN+SPN
nbf = ta.ema(ta.wma(BPN,signal),signal)
nsf = ta.ema(ta.wma(SPN,signal),signal)
tpf = ta.ema(ta.wma(TPN,signal),signal)
ndif = nbf-nsf
/////////////////////////VWMACD CALCS//////////////////////
// Volume Pressure Convergence Divergence by XeL_Arjona
vpo1 = (( math.sum(BPVavg,long)-math.sum(SPVavg,long))/math.sum(TPVavg,long))*100
vpo2 = (( math.sum(nbf,long)-math.sum(nsf,long))/math.sum(tpf,long))*100 //ema(wma(vmcdt,signal),signal)
vph = nz((vpo1 - vpo2),0)
// Plot Indicator
histC = vph > vph[1] ? color.blue : #BA00AA
Vpo1C = vpo1 > 0 ? color.green : color.red
Vpo2C = vpo2 > 0 ? color.green : color.red
///////////////////////VWMACD PLOT
plot(vpo1, color=Vpo1C,title="VPO1", style=plot.style_line, linewidth=2)
plot(vpo2, color=Vpo2C,title="VPO2", style=plot.style_line, linewidth=1)
plot(vph, color=histC, title="VPH", style=plot.style_columns, linewidth=3)
|
Squeeze Detector 3000 | https://www.tradingview.com/script/hm7mHoBC-Squeeze-Detector-3000/ | barnabygraham | https://www.tradingview.com/u/barnabygraham/ | 36 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © barnabygraham
//@version=5
indicator("Squeeze Detector 3000", overlay=true)
daysBack = input.int(5,'Pre/Post Market Volume Lookback Days #')
//WORKS FOR CURRENT DAY PREMARKET (LIVE)
//1.1 and 2.1 - Pre-market volume and RVOL
var tf1m = timeframe.isminutes and timeframe.period=='1'
var tf2m = timeframe.isminutes and timeframe.period=='2'
var tf5m = timeframe.isminutes and timeframe.period=='5'
var tf15m = timeframe.isminutes and timeframe.period=='15'
var tf30m = timeframe.isminutes and timeframe.period=='30'
tfTrigger = tf1m?not na(time('1', '1559-1959')):tf2m?not na(time('1', '1558-1959')):tf5m?not na(time('1', '1555-1959')):tf15m?not na(time('1', '1545-1959')):tf30m?not na(time('1', '1530-1959')):not na(time('1', '1500-1959'))
trigger = tfTrigger // WAS PREVIOUSLY >>>>> trigger = not na(time('1', '0930-1959'))
reset = trigger and not trigger[1]
preMarket = not na(time('1', '0400-0930'))
var preMarketVolume = 0.
preMarketVolume := reset ? 0. : preMarket ? preMarketVolume + volume : preMarketVolume
float totalPreMarketVolume = na
totalPreMarketVolume := time('1', '0400-0929') ? preMarketVolume : na
fin = totalPreMarketVolume>-1 and na(totalPreMarketVolume[1]) ? totalPreMarketVolume : 0
var temp = 0.
currentDayPMV = math.max(fin,preMarketVolume)
var a = array.new_float(daysBack+1)
// if (hour == 04) and (hour[1] != 04)
if not na(preMarket)
temp := currentDayPMV
next = (temp != temp[1]) ? temp : na
if not na(next)
array.push(a, next)
array.shift(a)
var PMSMA = 0.
var avg = 0.
if barstate.islast
avg:=0
for i = 1 to daysBack
PMSMA:=array.get(a,i)
avg:=avg+PMSMA
// labell=label.new(bar_index[i],close,str.tostring(array.get(a,i))) // for testing and to see how the arrays work
avgFin=avg/daysBack
// plot(array.get(a,daysBack),color=color.purple) // for testing and to see how the arrays work
// label6=label.new(bar_index[7],close,str.tostring(avgFin)) // for testing and to see how the arrays work
// CURRENT SETUP WORKS PERFECTLY DURING PREMARKET (POSTMARKET WORKS WHEN PREMARKET) - DOESN'T WORK DURING INTRADY
//1.2 and 2.2 - Post-market volume and RVOL
trigger2 = not na(time('1', '0400-1559'))
reset2 = trigger and not trigger[1]
postMarket = not na(time('1', '1559-0400'))
var postMarketVolume = 0.
postMarketVolume := reset2 ? 0. : postMarket ? postMarketVolume + volume : postMarketVolume
float totalPostMarketVolume = na
totalPostMarketVolume := time('1', '1559-1959') ? postMarketVolume : na
fin2 = totalPostMarketVolume>-1 and na(totalPostMarketVolume[1]) ? totalPostMarketVolume : 0
var temp2 = 0.
currentDayPMV2 = math.max(fin2,postMarketVolume)
// plot(currentDayPMV2,color=color.silver)
var b = array.new_float(daysBack+1)
if (hour == 04) and (hour[1] != 04)
temp2 := currentDayPMV2
next2 = (temp2 != temp2[1]) ? temp2 : na
if not na(next2)
array.push(b, next2)
array.shift(b)
var PMSMA2 = 0.
var avg2 = 0.
if barstate.islast
avg2:=0
for i = 1 to daysBack
PMSMA2:=array.get(b,i)
avg2:=avg2+PMSMA2
avgFin2=avg2/daysBack
ETHchoice=input.string('Premarket',title='ETH Volume', options=['Premarket','Postmarket','Both'])
ETHvolume=ETHchoice=='Premarket'?array.get(a,daysBack):ETHchoice=='Postmarket'?postMarketVolume:array.get(a,daysBack)+postMarketVolume
ETHvolumeAvg=ETHchoice=='Premarket'?avgFin:ETHchoice=='Postmarket'?avgFin2:avgFin2+avgFin
//3. Range of day
// Range of the day. (high of day - low of day) (can change value int $, % or ATR) (if value is smaller than 1 ATR, display in green, if between 1-2 orange, 2+ red)
rangeTrigger = not na(time('1', '0400-0701')) //'1959-0701'))
rangeReset = rangeTrigger and not rangeTrigger[1]
oneDay = not na(time('1', '0400-2000'))
var HOD = open
var LOD = open
if oneDay and (high>HOD)
HOD:=high
if oneDay and (low<LOD)
LOD:=low
if rangeReset
HOD:=open
LOD:=open
var HODarray=array.new_float(1)
var LODarray=array.new_float(1)
var closeArray=array.new_float(1)
if (hour == 19) and (hour[1] != 19)//
array.push(HODarray,HOD)
array.push(LODarray,LOD)
array.push(closeArray,close)
array.shift(HODarray)
array.shift(LODarray)
array.shift(closeArray)
HOD2=(array.get(HODarray,0))
LOD2=(array.get(LODarray,0))
close2=(array.get(closeArray,0))
HOD3=HOD2==HOD2[1]?na:HOD2
LOD3=LOD2==LOD2[1]?na:LOD2
close3=close2==close2[1]?na:close2
daysBackRange=input.int(5,title="Range Lookback Days")
var HODarray2=array.new_float(daysBackRange+1)//
var LODarray2=array.new_float(daysBackRange+1)//
var closeArray2=array.new_float(daysBackRange+1)//
if (not na(HOD3)) and (not na(LOD3))
array.push(HODarray2,HOD3)
array.push(LODarray2,LOD3)
array.push(closeArray2,close3)
array.insert(HODarray2,daysBackRange+1,HOD)
array.insert(LODarray2,daysBackRange+1,LOD)
array.insert(closeArray2,daysBackRange+1,close)
if (not na(HOD3)) and (not na(LOD3))
array.shift(HODarray2)
array.shift(LODarray2)
array.shift(closeArray2)
var extRange = 0.
var extRangeAvg = 0.
var extRangeAvgFinal = 0.
var extRangeAvgPercent=0.
var extRangeAvgPercentFinal=0.
//4. Calculate the stocks ATR, then display the amount of times the ATR has turned over from yesterday's close price.
// = not na(time('1', '1600-0400'))
// reset = trigger and not trigger[1]
dayRange = request.security(syminfo.tickerid,'D',high)-request.security(syminfo.tickerid,'D',low)
dayRangePercent=(request.security(syminfo.tickerid,'D',high)/request.security(syminfo.tickerid,'D',low)-1)*100
// plot(dayRangePercent)
// plot(dayRange,color=color.red)
//ATR
atrLen=(input.int(14,title='ATR Length'))
atr=request.security(syminfo.tickerid,'D',ta.atr(atrLen))
atrToday=request.security(syminfo.tickerid,'D',ta.atr(1))
yDayClose=request.security(syminfo.tickerid,'D',math.abs(close-close[1]))
atrTurnover2=atrToday/atr
atrTurnover=yDayClose/atr
atrColor=color.from_gradient(atrTurnover,0.75,2.25,color.new(color.green,0),color.new(color.red,0)) // colored by gradient
//atrColor=atrTurnover<1?color.new(color.green,0):atrTurnover>2?color.new(color.red,0):color.new(color.orange,0) // Your way
//5. Short Float
shs_out = request.financial(syminfo.tickerid, 'TOTAL_SHARES_OUTSTANDING', 'FQ', barmerge.gaps_off)
shortTickerVol = request.security(str.tostring(syminfo.ticker) + "_SHORT_VOLUME", 'D', close)
quandl_ticker = 'QUANDL:FINRA/FNSQ_' + str.replace_all(syminfo.ticker, '.', '_')
shortFloat = (request.security(quandl_ticker, 'D', close))*10
daily_vol = request.security(syminfo.tickerid, 'D', volume)
float sh_vol_ratio = shortTickerVol / daily_vol //daily
dailyShortVolume=(hour==04) and (hour[1] != 04) ? shortFloat : na
var dailyShortVolumeTable=0.
var dailyShortVolumeRatio=0.
var test = array.new_float(11)
if not na(dailyShortVolume)
dailyShortVolumeTable := dailyShortVolume
dailyShortVolumeRatio := sh_vol_ratio
array.push(test, dailyShortVolumeTable)
array.shift(test)
shortFloatPercent=shortFloat/shs_out
// Plot variable on the chart
// plot(series=dailyShortVolume, linewidth=1, title='Selection', style=plot.style_histogram)
// ShortVolAvgLen = input.int(50,title='Short Volume Average Length')
// plot(ta.sma(dailyShortVolume,ShortVolAvgLen),color=color.green)
shortChoice=input.string('Volume', title='Short Volume or Float', options=['Volume','Float'])
shortChoice2=shortChoice=="Volume"?'Vol':'Float'
volOrFloat=shortChoice=="Volume"?shortTickerVol:shortFloat
volOrFloatPercent=shortChoice=='Volume'?math.round((shortTickerVol/(daily_vol[1]/100)),3):math.round(shortFloatPercent*100,1)
formatChoice=input.string('$',title='Range Format', options=['$','%','ATR'])
percentRange=math.round((HOD-LOD)/(close/100),3) //Day % Range
dollarRange=math.round(HOD-LOD,3) //day $ range
var averageRangeVar=0.
var averagePerRangeVar=0.
if barstate.islast
for i = 0 to daysBackRange
averageRangeVar := averageRangeVar + dayRange
averagePerRangeVar := averagePerRangeVar + percentRange
averageRangeVar:=averageRangeVar/daysBackRange
averagePerRangeVar:=averagePerRangeVar/daysBackRange
RangeVar=formatChoice=='$'?dollarRange:formatChoice=='%'?percentRange:atrToday
RangeVarAvg=formatChoice=='$'?averageRangeVar:formatChoice=='%'?averagePerRangeVar:math.round(atr,3)
RTHVol=request.security(ticker.new(syminfo.prefix,syminfo.ticker,session.regular,adjustment.none),'D',volume)
ETHVol=request.security(ticker.new(syminfo.prefix,syminfo.ticker,session.extended,adjustment.none),'D',volume)
RTHandETH=RTHVol+ETHVol
dayVolumeChoice=input.string('RTH',title="Float Turnover Volume",options=['RTH','ETH','Both'])
dayVolume=dayVolumeChoice=='RTH'?RTHVol:dayVolumeChoice=='ETH'?ETHVol:RTHandETH
shareType=input.string('Total Shares Outstanding',title='Share Type', options=['Total Shares Outstanding', 'Float Shares Outstanding'])
float_shs_out = request.financial(syminfo.tickerid, 'FLOAT_SHARES_OUTSTANDING', 'FY', barmerge.gaps_off)
shareType2=shareType=='Total Shares Outstanding'?shs_out:float_shs_out
floatTurnover=dayVolume/shareType2
// RTH RVOL
int period = input.int(3, 'RVOL Lookback Period in Days',minval=1)
pastVolume = request.security(syminfo.tickerid, 'D', ta.sma(volume,period))
RVOLratio = daily_vol/pastVolume
RVOLcolor=color.from_gradient(RVOLratio,0.75,2.25,color.new(color.green,0),color.new(color.red,0)) // colored by gradient
// Table
sr1 = input.bool(true,'Show Row 1')
sr2 = input.bool(true,'Show Row 2')
sr3 = input.bool(true,'Show Row 3')
sr4 = input.bool(true,'Show Row 4')
sr5 = input.bool(true,'Show Row 5')
sr6 = input.bool(true,'Show Row 6')
tableTextColor=input.color(color.new(color.white,20),title='Table Text Color')
tableTitleTextColor=input.color(color.new(color.blue,20), title='Table Title Text Color')
var theTable = table.new(position.top_right, 17, 17, color.new(#ffffff, 100), frame_color=color.new(#ff0000, 75), frame_width = -3, border_color=color.new(#aaee55, 0), border_width = -3)
if barstate.islast and timeframe.period != "W" and timeframe.period != "M"
table.cell(theTable, 0, 0, "", text_color=tableTextColor)
if sr1
table.cell(theTable, 1, 1, str.tostring(ETHvolume, '#,###,###.#'), text_color=tableTextColor)
table.cell(theTable, 1, 0, ETHchoice, text_color=tableTitleTextColor)
table.cell(theTable, 2, 1, str.tostring(ETHvolumeAvg, '#,###,###.#'), text_color=tableTextColor)
table.cell(theTable, 2, 0, str.tostring(daysBack) + " Day Avg", text_color=tableTitleTextColor)
if sr2
table.cell(theTable, 0, 3, "", text_color=tableTextColor)
table.cell(theTable, 1, 3, "Short " + str.tostring(shortChoice2), text_color=tableTitleTextColor)
table.cell(theTable, 1, 4, str.tostring(volOrFloat, '#,###,###.#'), text_color=tableTextColor)
table.cell(theTable, 2, 3, "Short " + str.tostring(shortChoice2) + " %", text_color=tableTitleTextColor)
table.cell(theTable, 2, 4, str.tostring(volOrFloatPercent) + "%", text_color=tableTextColor)
if sr3
table.cell(theTable, 1, 5, "RTH RVOL", text_color=tableTitleTextColor)
table.cell(theTable, 1, 6, str.tostring(RVOLratio,'#,###,###.##'), text_color=RVOLcolor)
table.cell(theTable, 2, 5, str.tostring(period)+" Day RVOL", text_color=tableTitleTextColor)
table.cell(theTable, 2, 6, str.tostring(pastVolume,'#,###,###'), text_color=tableTextColor)
if sr4
table.cell(theTable, 0, 7, "", text_color=tableTextColor)
table.cell(theTable, 1, 7, "Day's "+formatChoice+" Range", text_color=tableTitleTextColor)
table.cell(theTable, 1, 8, str.tostring(RangeVar), text_color=tableTextColor)
table.cell(theTable, 2, 7, str.tostring(daysBackRange)+" Day Avg", text_color=tableTitleTextColor)
table.cell(theTable, 2, 8, str.tostring(RangeVarAvg), text_color=tableTextColor)
if sr5
table.cell(theTable, 0, 9, "", text_color=tableTextColor)
table.cell(theTable, 1, 9, str.tostring(atrLen)+" Day ATR", text_color=tableTitleTextColor)
table.cell(theTable, 1, 10, str.tostring(math.round(atr,4)), text_color=tableTextColor)
table.cell(theTable, 2, 9, "ATR T/O", text_color=tableTitleTextColor)
table.cell(theTable, 2, 10, str.tostring(math.round(atrTurnover,2)), text_color=atrColor)
if sr6
table.cell(theTable, 1, 11, "Today "+str.tostring(dayVolumeChoice)+" Vol", text_color=tableTitleTextColor)
table.cell(theTable, 1, 12, str.tostring(dayVolume,'#,###,###.#'), text_color=tableTextColor)
table.cell(theTable, 2, 11, "Float T/O", text_color=tableTitleTextColor)
table.cell(theTable, 2, 12, str.tostring(math.round(floatTurnover,3)), text_color=tableTextColor)
// table.cell(theTable, 3, 5, "Days To Cover", text_color=tableTextColor)
// table.cell(theTable, 3, 6, str.tostring(math.round(shortFloat/daily_vol,2)), text_color=tableTextColor)
// table.cell(theTable, 3, 8, "$"+str.tostring(math.round(extRangeAvgFinal,2)), text_color=tableTextColor)
// table.cell(theTable, 4, 8, str.tostring(math.round(extRangeAvgPercentFinal,3))+"%", text_color=tableTextColor)
//extRangeAvgFinal
//table.cell(theTable, 0, 0, preMarketVolume, text_color=XLUvol>0?color.new(color.green,0):color.new(color.red,0))
// + str.tostring(ShortVolAvgLen) |
Make Your Own Index! | https://www.tradingview.com/script/zvI4wFIE-Make-Your-Own-Index/ | scheplick | https://www.tradingview.com/u/scheplick/ | 1,101 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Made by Stef @Scheplick
// Release April 9 2022
//@version=5
indicator(title = "Make An Index", shorttitle = "Index", overlay = false)
// Inputs
weightType = input.string("Custom Weighted", "Index Type", options=["Custom Weighted"])
symbol_1 = input.bool(title='Symbol 1', defval=true, inline='1')
ticker_1 = input.symbol(title='', defval='LZ', inline='1')
weighting_1 = input.float(title='Weight', defval=10, inline='1') / 100.0
symbol_2 = input.bool(title='Symbol 2', defval=true, inline='2')
ticker_2 = input.symbol(title='', defval='BAND', inline='2')
weighting_2 = input.float(title='Weight', defval=10, inline='2') / 100.0
symbol_3 = input.bool(title='Symbol 3', defval=true, inline='3')
ticker_3 = input.symbol(title='', defval='GPS', inline='3')
weighting_3 = input.float(title='Weight', defval=10, inline='3') / 100.0
symbol_4 = input.bool(title='Symbol 4', defval=true, inline='4')
ticker_4 = input.symbol(title='', defval='PENN', inline='4')
weighting_4 = input.float(title='Weight', defval=10, inline='4') / 100.0
symbol_5 = input.bool(title='Symbol 5', defval=true, inline='5')
ticker_5 = input.symbol(title='', defval='EXFY', inline='5')
weighting_5 = input.float(title='Weight', defval=10, inline='5') / 100.0
symbol_6 = input.bool(title='Symbol 6', defval=true, inline='6')
ticker_6 = input.symbol(title='', defval='NRDS', inline='6')
weighting_6 = input.float(title='Weight', defval=10, inline='6') / 100.0
symbol_7 = input.bool(title='Symbol 7', defval=true, inline='7')
ticker_7 = input.symbol(title='', defval='RDFN', inline='7')
weighting_7 = input.float(title='Weight', defval=10, inline='7') / 100.0
symbol_8 = input.bool(title='Symbol 8', defval=true, inline='8')
ticker_8 = input.symbol(title='', defval='ME', inline='8')
weighting_8 = input.float(title='Weight', defval=10, inline='8') / 100.0
symbol_9 = input.bool(title='Symbol 9', defval=true, inline='9')
ticker_9 = input.symbol(title='', defval='STNE', inline='9')
weighting_9 = input.float(title='Weight', defval=10, inline='9') / 100.0
symbol_10 = input.bool(title='Symbol 10', defval=true, inline='10')
ticker_10 = input.symbol(title='', defval='KLR', inline='10')
weighting_10 = input.float(title='Weight', defval=10, inline='10') / 100.0
// Security
symcalc01 = symbol_1 ? request.security(ticker_2, timeframe.period, close) : 0
symcalc02 = symbol_2 ? request.security(ticker_2, timeframe.period, close) : 0
symcalc03 = symbol_3 ? request.security(ticker_3, timeframe.period, close) : 0
symcalc04 = symbol_4 ? request.security(ticker_4, timeframe.period, close) : 0
symcalc05 = symbol_5 ? request.security(ticker_5, timeframe.period, close) : 0
symcalc06 = symbol_6 ? request.security(ticker_6, timeframe.period, close) : 0
symcalc07 = symbol_7 ? request.security(ticker_7, timeframe.period, close) : 0
symcalc08 = symbol_8 ? request.security(ticker_8, timeframe.period, close) : 0
symcalc09 = symbol_9 ? request.security(ticker_9, timeframe.period, close) : 0
symcalc10 = symbol_10 ? request.security(ticker_10, timeframe.period, close) : 0
// Plot
plot(symcalc01*weighting_1+symcalc02*weighting_2+symcalc03*weighting_3+symcalc04*weighting_4+symcalc05*weighting_5+symcalc06*weighting_6+symcalc07*weighting_7+symcalc08*weighting_8+symcalc09*weighting_9+symcalc10*weighting_10)
|
Round Number Zones | https://www.tradingview.com/script/63Usibql-Round-Number-Zones/ | trading-guide | https://www.tradingview.com/u/trading-guide/ | 420 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © trading-guide
//@version=5
indicator("Round Number Zones", overlay=true)
line_col = input(color.gray, title ="Line color")
line_width = input.int(2, title = "Line width", minval = 1, maxval = 5)
line_count = input.int(title="Line count", defval=10)
line_count_2 = math.floor(line_count / 2)
// Symbol 1 : EURUSD default
show_sym_1 = input.bool(title="Show", defval=true, inline="2")
sym_1 = input.symbol("EURUSD",title=" ", inline="2")
sym_1_steps = input.float(title="+/-", defval=0.001, inline="2")
sym_1_sec = request.security(sym_1,timeframe.period, close)
sym_1_use_custom_price = input.bool(title="Custom Price", defval=false, inline="3")
sym_1_custom_price = input.float(title="", defval=1.08, inline="3")
// Symbol 2 : GOLD default
show_sym_2 = input.bool(title="Show", defval=true, inline="4")
sym_2 = input.symbol("GOLD",title=" ", inline="4")
sym_2_steps = input.float(title="+/-", defval=5, inline="4")
sym_2_sec = request.security(sym_2,timeframe.period, close)
sym_2_use_custom_price = input.bool(title="Custom Price", defval=false, inline="5")
sym_2_custom_price = input.float(title="", defval=1900, inline="5")
// Symbol 3 : US30 default
show_sym_3 = input.bool(title="Show", defval=true, inline="6")
sym_3 = input.symbol("US30",title=" ", inline="6")
sym_3_steps = input.float(title="+/-", defval=50, inline="6")
sym_3_sec = request.security(sym_3,timeframe.period, close)
sym_3_use_custom_price = input.bool(title="Custom Price", defval=false, inline="7")
sym_3_custom_price = input.float(title="", defval=3500, inline="7")
draw_line(sym, show, steps, custom, custom_price) =>
if sym == syminfo.prefix + ":" +syminfo.ticker and show
for i = 0 to line_count - 1
price = custom ? custom_price : close
step = math.ceil(price / steps) * steps + (i * steps) - (line_count_2 * steps)
line.new(bar_index, step, bar_index - 1, step, xloc=xloc.bar_index, extend=extend.both, color=line_col, width=line_width, style=line.style_dotted)
draw_line(sym_1, show_sym_1, sym_1_steps, sym_1_use_custom_price, sym_1_custom_price)
draw_line(sym_2, show_sym_2, sym_2_steps, sym_2_use_custom_price, sym_2_custom_price)
draw_line(sym_3, show_sym_3, sym_3_steps, sym_3_use_custom_price, sym_3_custom_price) |
PB's ESSMA | https://www.tradingview.com/script/w1R34hN5-PB-s-ESSMA/ | bhavishya1312 | https://www.tradingview.com/u/bhavishya1312/ | 19 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bhavishya
//@version=5
indicator("ESSMA", overlay=true)
//inputs
source = input(close, "Source", group="Source")
length1 = input(50, "Length1", group = "Length")
w1 = input.float(2.0, "SMA Weight", group="Weights")
w2 = input.float(2.0, "EMA Weight", group="Weights")
w3 = input.float(2.0, "WMA Weight", group="Weights")
w4 = input.float(2.0, "SMMA Weight", group="Weights")
w5 = input.float(2.0, "RMA Weight", group="Weights")
useatr = input.bool(false, "Use ATR", group="ATR")
atrLen = input.int(title="ATR Length", defval=14, group="ATR")
// functions
smma(src, length) =>
smma = 0.0
smma := na(smma[2]) ? ta.sma(src, length) : (smma[2] * (length - 1) + src) / length
smma
essma(src,length) =>
essma = 0.0
smma = smma(src * w4,length)
ema = ta.ema(src * w2, length)
sma = ta.sma(src * w1, length)
wma = ta.wma(src * w3, length)
rma = ta.rma(src * w5, length)
essma := (smma/w4+ema/w2+sma/w1 - wma/w3 - rma/w5 + open + close)/(3)
essma
// calucations
// atr and MAs
atr = ta.atr(atrLen)
usesource = useatr ? atr : source
essma1 = essma(usesource, length1)
sessma1 = ta.wma(essma1, length1)
// plots
p1 = plot(essma1, "ESSMA", color.green)
ps1 = plot(sessma1, "ESSMA Smooth", color.red)
bool up = na
bool down = na
if (ta.crossover(essma1,sessma1))
up := true
if (ta.crossunder(essma1, sessma1))
down := true
plotshape(up, style=shape.labelup, location = location.belowbar, color=color.lime, text="B", textcolor=color.black)
plotshape(down, style=shape.labeldown, location = location.abovebar, color=color.orange, text="S", textcolor=color.black)
// alerts
alertcondition(up, "ESSMA UP", '{"content":"ESSMA BUY @ {{close}}" : "{{ticker}} int : {{interval}} - essma : {{plot_0}} / sessma {{plot_1}}"}')
alertcondition(down, "ESSMA DOWN", '{"content":"ESSMA SELL @ {{close}}" : "{{ticker}} int : {{interval}} - essma :{{plot_0}} /sessma : {{plot_1}}"}') |
ICT index correlated market indicator | https://www.tradingview.com/script/CidARBPN-ICT-index-correlated-market-indicator/ | SimoneMicucci00 | https://www.tradingview.com/u/SimoneMicucci00/ | 256 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SimoneMicucci00
//@version=5
indicator("Correlation indicator", "Correlation Analisys")
//input data
sel = input.string("S&P500", "main source", ["S&P500", "Nasdaq", "Dow Jon IA", "DXY", "EURUSD", "GBPUSD"])
other = input.bool(false, "", "", "1")
sel2 = input.symbol("ES1!", "other source", "", "1")
//input customization
BullBodyColor = input.color(#00bc08, "body", "", "x", "color")
BearBodyColor = input.color(#000000, "", "", "x", "color")
BullBorderColor = input.color(#000000, "border", "", "y", "color")
BearBorderColor = input.color(#000000, "", "", "y", "color")
BullWickColor = input.color(#000000, "wick", "", "z", "color")
BearWickColor = input.color(#000000, "", "", "z", "color")
//data selector
data = other ? sel2 : sel == "S&P500" ? "ES1!" : sel == "Nasdaq" ? "NQ1!" : sel == "Dow Jon IA" ? "YM1!" : sel == "DXY" ? "TVC:DXY" :
sel == "EURUSD" ? "FX:EURUSD" : sel == "GBPUSD" ? "FX:GBPUSD" : na
//data request
open_ = request.security(data,"",open)
high_ = request.security(data,"",high)
low_ = request.security(data,"",low)
close_ = request.security(data,"",close)
//plot
plotcandle(open_, high_, low_, close_, "Data selected", open_<close_ ? BullBodyColor : BearBodyColor, open_<close_ ? BullWickColor : BearBodyColor, bordercolor = open_<close_ ? BullBorderColor : BearBorderColor)
|
Bogdan Ciocoiu - Makaveli | https://www.tradingview.com/script/JIIMQdYb-Bogdan-Ciocoiu-Makaveli/ | BogdanCiocoiu | https://www.tradingview.com/u/BogdanCiocoiu/ | 39 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BogdanCiocoiu
//@version=5
indicator("Bogdan Ciocoiu - Makaveli", shorttitle="BC - Makaveli", format=format.price, precision=2, timeframe="", timeframe_gaps=true, explicit_plot_zorder=true)
// Description
// This indicator integrates the functionality of multiple volume price analysis algorithms whilst aligning their scales to fit in a single chart.
// Having such indicators loaded enables traders to take advantage of potential divergences between the price action and volume related volatility.
// Users will have to enable or disable alternative algorithms depending on their choice.
//
// Uniqueness
// This indicator is unique because it combines multiple algorithm-specific two-volume analyses with price volatility.
// This indicator is also unique because it amends different algorithms to show output on a similar scale enabling traders to observe various volume-analysis tools simultaneously whilst allocating different colour codes.
//
// Open source re-use
// This indicator utilises the following open-source scripts:
// https://www.tradingview.com/script/TsSXNt1o-Volume-Spread-Analysis/
// https://www.tradingview.com/script/7H00I0MG-Volume-Price-Spread-Analysis-2/
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Method 1
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_O1_enable = input(true, "", inline="Method 1", group="Method 1")
_O1_colors_up = input(color.green, "", inline="Method 1", group="Method 1")
_O1_colors_down = input(color.red, "", inline="Method 1", group="Method 1")
_O1_fact_1 = input(80000, "Factor 1 (+)", inline="Method 1", group="Method 1")
_O1_fact_2 = input(0.001, "2 (*)", inline="Method 1", group="Method 1")
_O1_V = volume
_O1_close = close * _O1_V
_O1_open = _O1_close[1]
_O1_high = math.max(math.max(high * _O1_V, _O1_close), _O1_open)
_O1_low = math.min(math.min(low * _O1_V, _O1_open), _O1_close)
_O1_HL2 = (_O1_high + _O1_low) / 2
_O1_color = open < close ? _O1_colors_up : _O1_colors_down
plotcandle (
_O1_low * _O1_fact_2 + _O1_fact_1,
_O1_high * _O1_fact_2 + _O1_fact_1,
_O1_low * _O1_fact_2 + _O1_fact_1,
_O1_close * _O1_fact_2 + _O1_fact_1,
color=(_O1_enable) ? _O1_color : na,
wickcolor=(_O1_enable) ? _O1_color : na,
bordercolor=(_O1_enable) ? _O1_color : na)
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Method 2
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_O2_enable = input(true, "", inline="Method 2", group="Method 2")
_O2_colors_up = input(color.blue, "", inline="Method 2", group="Method 2")
_O2_colors_down = input(color.fuchsia, "", inline="Method 2", group="Method 2")
_O2_fact_1 = input(0, "Factor 1 (+)", inline="Method 2", group="Method 2")
_O2_fact_2 = input(1, "2 (*)", inline="Method 2", group="Method 2")
_O2_V = math.log(volume)
_O2_close = 0.0
_O2_close := _O2_close[1] > 1 ? ( (close*_O2_V) + (high*_O2_V) + (low*_O2_V) + _O2_close[1] )*0.25 : ( (close*_O2_V) + (high*_O2_V) + (low*_O2_V) + (((close[1]*_O2_V[1])+(open*_O2_V))*0.5))*0.25
_O2_open = (_O2_close[1]+(open*_O2_V))*0.5
_O2_high = math.max(math.max(high*_O2_V,_O2_close),_O2_open)
_O2_low = math.min(math.min(low*_O2_V,_O2_open),_O2_close)
_O2_HL2 = ( _O2_high + _O2_low ) / 2
_O2_color = open < close ? _O2_colors_up : _O2_colors_down
_O2_se = input.string("HL2", "", options=["HL2", "High", "Low", "Open", "Close"], inline="Method 2", group="Method 2")
_O2_wid = input(2, "", inline="Method 2", group="Method 2")
_O2_cl_col = input(color.white, "", inline="Method 2", group="Method 2")
plotcandle(
_O2_open * _O2_fact_2 + _O2_fact_1,
_O2_high * _O2_fact_2 + _O2_fact_1,
_O2_low * _O2_fact_2 + _O2_fact_1,
_O2_close * _O2_fact_2 + _O2_fact_1,
color=(_O2_enable) ? _O2_color : na,
wickcolor=(_O2_enable) ? _O2_color : na,
bordercolor=(_O2_enable) ? _O2_color : na)
_O2_ploter = (_O2_se == "Close") ? _O2_close : ( _O2_se == "Open" ) ? _O2_open : ( _O2_se == "HL2" ) ? _O2_HL2 : ( _O2_se == "High" ) ? _O2_high : ( _O2_se == "Low" ) ? _O2_low : 0
_O2_signal = plot(_O2_ploter, color=(_O2_enable) ? _O2_cl_col : na, style=plot.style_circles, linewidth=_O2_wid)
|
MTF Ichimoku Analysis[tanayroy] | https://www.tradingview.com/script/SB2I9PBy-MTF-Ichimoku-Analysis-tanayroy/ | tanayroy | https://www.tradingview.com/u/tanayroy/ | 234 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tanayroy
//@version=5
indicator("MTF Ichimoku Analysis[tanayroy]", shorttitle="MTF ICHIMOKU",overlay=true)
TRANSP=60
SUBTRANSP=80
var string GP1 = "Ichimoku Settings"
tenkanSenPeriod = input.int(9, minval=1, title="Tenkan Sen Length",group = GP1)
kijunSenPeriod = input.int(26, minval=1, title="Kijun Sen Length",group = GP1)
senkouBLen = input.int(52, minval=1, title="Senkou B Length",group = GP1)
displacement = input.int(26, minval=1, title="Displacement",group = GP1)
chikuspanConsolidationBar=input.int(5, minval=1, title="Chikou Consolidation Bar",group = GP1)
kumoShadowPeriod=input.int(252, minval=1, title="Kumo Shadow Analyzing Period",group = GP1)
var string GP2 = "Resolution"
resolution1= input.timeframe('5', "Resolution 1",group=GP2,inline = "21")
resolution2= input.timeframe('30', "Resolution 2",group=GP2,inline = "21")
resolution3= input.timeframe('60', "Resolution 3",group=GP2,inline = "22")
resolution4= input.timeframe('D', "Resolution 4",group=GP2,inline = "22")
resolution5= input.timeframe('W', "Resolution 5",group=GP2,inline = "23")
resolution6= input.timeframe('M', "Resolution 6",group=GP2,inline = "23")
var string GP3 = "Display"
tableYpos= input.string("top", "Panel position", inline = "31", options = ["top", "middle", "bottom"], group = GP3)
tableXpos = input.string("right", "", inline = "31", options = ["left", "center", "right"], group = GP3)
c_bull = input.color(color.new(color.green, 30), "Bull", inline = "32", group = GP3)
c_bear = input.color(color.new(color.red, 30), "Bear", inline = "32", group = GP3)
c_neutral = input.color(color.new(color.blue, 30), "Neutral", inline = "32", group = GP3)
useShortNotation = input.bool(false,"Use Shorthand Notations", group = GP3)
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
GetPipSize() =>
if syminfo.type == "forex"
syminfo.mintick * 10
else
1
pip()=>
syminfo.type == "forex"?"(Pips)":na
f_MTFIchi() =>
tenkanSen = donchian(tenkanSenPeriod)
kijunSen = donchian(kijunSenPeriod )
senkouA = (tenkanSen+kijunSen)/2
senkouB = donchian(senkouBLen )
kumoUpLine = senkouA[displacement]>=senkouB[displacement]?senkouA[displacement]:senkouB[displacement]
kumoDownLine = senkouA[displacement]>=senkouB[displacement]?senkouB[displacement]:senkouA[displacement]
highestSenkouA = ta.highest(senkouA[displacement],kumoShadowPeriod)
lowestSenkouA = ta.lowest(senkouA[displacement],kumoShadowPeriod)
highestSenkouB = ta.highest(senkouB[displacement],kumoShadowPeriod)
lowestSenkouB = ta.lowest(senkouB[displacement],kumoShadowPeriod)
highestCloud = highestSenkouA>=highestSenkouB?highestSenkouA:highestSenkouB
lowestCloud = lowestSenkouA<=lowestSenkouB?lowestSenkouA:lowestSenkouB
kijunSlp = (ta.change(kijunSen)/kijunSen)
senkouASlp = (ta.change(senkouA)/senkouA)
senkouBSlp = (ta.change(senkouB)/senkouB)
tenkanSlp = (ta.change(tenkanSen)/tenkanSen)
kumoUpLinechiku = senkouA[displacement+displacement]>=senkouB[displacement+
displacement]?senkouA[displacement+displacement]:senkouB[displacement+displacement]
kumoDownLinechiku = senkouA[displacement+displacement]>=senkouB[displacement+
displacement]?senkouB[displacement+displacement]:senkouA[displacement+displacement]
chikuHigh = 0.0
chikuLow = low[displacement-1]
for i = displacement-1 to displacement-chikuspanConsolidationBar
chikuHigh:=math.max(high[i],chikuHigh)
for i = displacement-1 to displacement-chikuspanConsolidationBar
chikuLow:=math.min(low[i],chikuLow)
float score = 0.0
tenkanCrossover = ta.barssince(ta.crossover(close,tenkanSen) or ta.crossunder(close,tenkanSen))
kijunSenCrossover = ta.barssince(ta.crossover(close,kijunSen) or ta.crossunder(close,kijunSen))
tsCrossover = ta.barssince(ta.crossover(tenkanSen,kijunSen) or ta.crossunder(tenkanSen,kijunSen))
kumoCrossover = ta.barssince(ta.crossover(close,kumoUpLine) or ta.crossunder(close,kumoDownLine))
senkouCrossover = ta.barssince(ta.crossover(senkouA,senkouB) or ta.crossunder(senkouA,senkouB))
distanceBetweenTenkanAndPrice = math.abs(close-tenkanSen)/GetPipSize()
distanceBetweenKijunAndPrice = math.abs(close-kijunSen)/GetPipSize()
//Price Vs Kumo (Score +-2)
priceKumo = 0
if close > kumoUpLine
priceKumo := 1
score := score + 2.0
else if close<kumoDownLine
priceKumo := 2
score := score - 2.0
//Price Vs TenkanSen (Score +-0.5)
priceTenkanSen = 0
if close >= tenkanSen
priceTenkanSen := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else if close < tenkanSen
priceTenkanSen := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Price Vs KijunSen (Score +-0.5)
priceKijunSen = 0
if close >= kijunSen
priceKijunSen := 1
if priceKumo ==1
score := score + 0.5
else
score := score - 0.5
else if close < kijunSen
priceKijunSen := 2
score := score - 0.5
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Price Vs. Chikou
priceChiku = 0
if close >= close[26]
priceChiku := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else if close < close[26]
priceChiku := 2
score := score - 0.5
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Tenkan Sen Vs Kijun Sen
tkCross = 0
if tenkanSen >= kijunSen
tkCross := 1
if priceKumo==1
score := score + 2.0
else
score := score - 2.0
else if tenkanSen < kijunSen
tkCross := 2
if priceKumo == 2
score := score - 2.0
else
score := score + 2.0
//Slope of Tenkan Sen
tDirection = 0
if tenkanSlp > 0
tDirection := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else if tenkanSlp < 0
tDirection := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Slope of Kijun Sen
kDirection = 0
if kijunSlp > 0
kDirection := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else if kijunSlp < 0
kDirection := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Kumo Vs. Tenkansen
kumoTenkanSen = 0
if tenkanSen <= kumoUpLine and tenkanSen>=kumoDownLine
kumoTenkanSen := 0
if priceKumo==1
score := score - 0.5
else if priceKumo == 2
score := score + 0.5
else if tenkanSen > kumoUpLine
kumoTenkanSen := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else
kumoTenkanSen := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Kumo Vs. Kijun Sen
kumoKijunSen = 0
if kijunSen <= kumoUpLine and kijunSen>=kumoDownLine
kumoKijunSen := 0
if priceKumo==1
score := score - 0.5
else if priceKumo == 2
score := score + 0.5
else if kijunSen > kumoUpLine
kumoKijunSen := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else
kumoKijunSen := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Kumo Vs Chikou
kumochiku = 0
if close <= kumoUpLinechiku and close >= kumoDownLinechiku
kumochiku := 0
if priceKumo==1
score := score - 0.5
else if priceKumo==2
score := score + 0.5
else if close>kumoUpLinechiku
kumochiku := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else
kumochiku := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
//Kumo Shadow Behind price
kumoShadow = 99
if close > kumoUpLine and close < highestCloud
kumoShadow := 11
score := score - 0.5
else if close<kumoDownLine and close>lowestCloud
kumoShadow := 11
score := score + 0.5
if kumoShadow == 99 and priceKumo ==1
score := score + 0.5
else if kumoShadow == 99 and priceKumo == 2
score := score - 0.5
senkouAB = 0
if senkouA >= senkouB
senkouAB := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else if senkouA < senkouB
senkouAB := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
ADirection = 0
if senkouASlp > 0
ADirection := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else if senkouASlp < 0
ADirection := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
BDirection = 0
if senkouBSlp > 0
BDirection := 1
if priceKumo==1
score := score + 0.5
else
score := score - 0.5
else if senkouBSlp < 0
BDirection := 2
if priceKumo == 2
score := score - 0.5
else
score := score + 0.5
chikuHorizontal = 99
if close > close[26] and close <= chikuHigh
chikuHorizontal := 11
if priceKumo == 1
score := score - 0.5
else if close < close[26] and close>=chikuLow
chikuHorizontal := 11
if priceKumo == 2
score := score + 0.5
chikuVertical = 99.0
if close > close[26] and not (close <= chikuHigh)
pct_ch = ((close-chikuHigh)/close)*100
chikuVertical := -pct_ch
// if priceKumo == 1
// score := score + 0.5
else if close < close[26] and not (close>=chikuLow)
pct_ch=((chikuLow-close)/close)*100
chikuVertical := +pct_ch
// if priceKumo == 2
// score := score - 0.5
[priceKumo, priceTenkanSen, priceKijunSen, priceChiku, tkCross, tDirection,
kDirection, kumoTenkanSen, kumoKijunSen, kumochiku, kumoShadow, senkouAB,
ADirection, BDirection, chikuHorizontal, chikuVertical, tenkanCrossover,
kijunSenCrossover, tsCrossover, kumoCrossover, senkouCrossover, score,
distanceBetweenTenkanAndPrice, distanceBetweenKijunAndPrice]
var table ichimokuTable = table.new(tableYpos + "_" + tableXpos, columns=7, rows=31,bgcolor=color.yellow,border_width=1,border_color=color.white)
[priceKumo1, priceTenkanSen1, priceKijunSen1, priceChiku1, tkCross1, tDirection1,
kDirection1, kumoTenkanSen1, kumoKijunSen1, kumochiku1, kumoShadow1, senkouAB1,
ADirection1, BDirection1, chikuHorizontal1, chikuVertical1, tenkanCrossover1,
kijunSenCrossover1, tsCrossover1, kumoCrossover1, senkouCrossover1, score1,
distanceBetweenTenkanAndPrice1,
distanceBetweenKijunAndPrice1]=request.security(syminfo.tickerid, resolution1, f_MTFIchi())
[priceKumo2, priceTenkanSen2, priceKijunSen2, priceChiku2, tkCross2, tDirection2,
kDirection2, kumoTenkanSen2, kumoKijunSen2, kumochiku2, kumoShadow2, senkouAB2,
ADirection2, BDirection2, chikuHorizontal2, chikuVertical2, tenkanCrossover2,
kijunSenCrossover2, tsCrossover2, kumoCrossover2, senkouCrossover2, score2,
distanceBetweenTenkanAndPrice2,
distanceBetweenKijunAndPrice2]=request.security(syminfo.tickerid, resolution2, f_MTFIchi())
[priceKumo3, priceTenkanSen3, priceKijunSen3, priceChiku3, tkCross3, tDirection3,
kDirection3, kumoTenkanSen3, kumoKijunSen3, kumochiku3, kumoShadow3, senkouAB3,
ADirection3, BDirection3, chikuHorizontal3, chikuVertical3, tenkanCrossover3,
kijunSenCrossover3, tsCrossover3, kumoCrossover3, senkouCrossover3, score3,
distanceBetweenTenkanAndPrice3,
distanceBetweenKijunAndPrice3]=request.security(syminfo.tickerid, resolution3, f_MTFIchi())
[priceKumo4, priceTenkanSen4, priceKijunSen4, priceChiku4, tkCross4, tDirection4,
kDirection4, kumoTenkanSen4, kumoKijunSen4, kumochiku4, kumoShadow4, senkouAB4,
ADirection4, BDirection4, chikuHorizontal4, chikuVertical4, tenkanCrossover4,
kijunSenCrossover4, tsCrossover4, kumoCrossover4, senkouCrossover4, score4,
distanceBetweenTenkanAndPrice4,
distanceBetweenKijunAndPrice4]=request.security(syminfo.tickerid, resolution4, f_MTFIchi())
[priceKumo5, priceTenkanSen5, priceKijunSen5, priceChiku5, tkCross5, tDirection5,
kDirection5, kumoTenkanSen5, kumoKijunSen5, kumochiku5, kumoShadow5, senkouAB5,
ADirection5, BDirection5, chikuHorizontal5, chikuVertical5, tenkanCrossover5,
kijunSenCrossover5, tsCrossover5, kumoCrossover5, senkouCrossover5, score5,
distanceBetweenTenkanAndPrice5,
distanceBetweenKijunAndPrice5]=request.security(syminfo.tickerid, resolution5, f_MTFIchi())
[priceKumo6, priceTenkanSen6, priceKijunSen6, priceChiku6, tkCross6, tDirection6,
kDirection6, kumoTenkanSen6, kumoKijunSen6, kumochiku6, kumoShadow6, senkouAB6,
ADirection6, BDirection6, chikuHorizontal6, chikuVertical6, tenkanCrossover6,
kijunSenCrossover6, tsCrossover6, kumoCrossover6, senkouCrossover6, score6,
distanceBetweenTenkanAndPrice6,
distanceBetweenKijunAndPrice6]=request.security(syminfo.tickerid, resolution6, f_MTFIchi())
f_change_to_symbol(num)=>
string symbol=na
if num==0
symbol:='↔'
else if num == 1
symbol := '↑'
else if num == 2
symbol := '↓'
else if num == 11
symbol := 'Ⓨ'
else if num == 99 or num == 99.0
symbol := 'Ⓝ'
else
symbol := str.tostring(num,format.percent)
f_color(num)=>
color symbolColor=na
if num==0
symbolColor:=color.blue
else if num == 1
symbolColor := color.green
else if num == 2
symbolColor := color.red
else if num == 11
symbolColor := color.blue
else if num == 99 or num == 99.0
symbolColor := color.blue
else
if num<=0.0
symbolColor := color.green
else
symbolColor := color.red
f_set_the_table(tableName,colNum,priceKumo, priceTenkanSen, priceKijunSen, priceChiku, tkCross, tDirection,
kDirection, kumoTenkanSen, kumoKijunSen, kumochiku, kumoShadow, senkouAB,
ADirection, BDirection, chikuHorizontal, chikuVertical, tenkanCrossover,
kijunSenCrossover, tsCrossover, kumoCrossover, senkouCrossover, score,
distanceBetweenTenkanAndPrice, distanceBetweenKijunAndPrice)=>
table.cell(tableName,colNum,2,f_change_to_symbol(priceKumo) ,text_halign=text.align_right,text_color=f_color(priceKumo))
table.cell(tableName,colNum,3,f_change_to_symbol(priceTenkanSen) ,text_halign=text.align_right,text_color=f_color(priceTenkanSen))
table.cell(tableName,colNum,4,f_change_to_symbol(priceKijunSen) ,text_halign=text.align_right,text_color=f_color(priceKijunSen))
table.cell(tableName,colNum,5,f_change_to_symbol(priceChiku),text_halign=text.align_right,text_color=f_color(priceChiku))
table.cell(tableName,colNum,6,f_change_to_symbol(tkCross),text_halign=text.align_right,text_color=f_color(tkCross))
table.cell(tableName,colNum,8,f_change_to_symbol(tDirection),text_halign=text.align_right,text_color=f_color(tDirection))
table.cell(tableName,colNum,9,f_change_to_symbol(kDirection),text_halign=text.align_right,text_color=f_color(kDirection))
table.cell(tableName,colNum,10,f_change_to_symbol(ADirection),text_halign=text.align_right,text_color=f_color(ADirection))
table.cell(tableName,colNum,11,f_change_to_symbol(BDirection),text_halign=text.align_right,text_color=f_color(BDirection))
table.cell(tableName,colNum,13,f_change_to_symbol(kumoTenkanSen),text_halign=text.align_right,text_color=f_color(kumoTenkanSen))
table.cell(tableName,colNum,14,f_change_to_symbol(kumoKijunSen),text_halign=text.align_right,text_color=f_color(kumoKijunSen))
table.cell(tableName,colNum,15,f_change_to_symbol(kumochiku),text_halign=text.align_right,text_color=f_color(kumochiku))
table.cell(tableName,colNum,16,f_change_to_symbol(kumoShadow),text_halign=text.align_right,text_color=f_color(kumoShadow))
table.cell(tableName,colNum,17,f_change_to_symbol(senkouAB),text_halign=text.align_right,text_color=f_color(senkouAB))
table.cell(tableName,colNum,19,f_change_to_symbol(chikuHorizontal),text_halign=text.align_right,text_color=f_color(chikuHorizontal))
table.cell(tableName,colNum,20,f_change_to_symbol(chikuVertical),text_halign=text.align_right,text_color=f_color(chikuVertical))
table.cell(tableName,colNum,22,str.tostring(tenkanCrossover),text_halign=text.align_right,text_color=color.blue)
table.cell(tableName,colNum,23,str.tostring(kijunSenCrossover),text_halign=text.align_right,text_color=color.blue)
table.cell(tableName,colNum,24,str.tostring(kumoCrossover),text_halign=text.align_right,text_color=color.blue)
table.cell(tableName,colNum,25,str.tostring(tsCrossover),text_halign=text.align_right,text_color=color.blue)
table.cell(tableName,colNum,26,str.tostring(senkouCrossover),text_halign=text.align_right,text_color=color.blue)
table.cell(tableName,colNum,27,str.tostring(score),text_halign=text.align_right,text_color=score>=0?color.green:color.red)
table.cell(tableName,colNum,29,str.tostring(distanceBetweenTenkanAndPrice),text_halign=text.align_right,text_color=color.blue)
table.cell(tableName,colNum,30,str.tostring(distanceBetweenKijunAndPrice),text_halign=text.align_right,text_color=color.blue)
if barstate.islast
headerColor = color.new(color.orange, TRANSP)
subHeaderColor = color.new(color.orange, SUBTRANSP)
table.cell(ichimokuTable,0,0,text=useShortNotation?'':'MTF Ichimoku', bgcolor = headerColor)
table.cell(ichimokuTable,1,0,resolution1, bgcolor = headerColor)
table.cell(ichimokuTable,2,0,resolution2, bgcolor = headerColor)
table.cell(ichimokuTable,3,0,resolution3, bgcolor = headerColor)
table.cell(ichimokuTable,4,0,resolution4, bgcolor = headerColor)
table.cell(ichimokuTable,5,0,resolution5, bgcolor = headerColor)
table.cell(ichimokuTable,6,0,resolution6, bgcolor = headerColor)
if not useShortNotation
table.cell(ichimokuTable,0,1,text='Current Price(P) and Ichimoku', bgcolor = subHeaderColor, tooltip =
'Here we are analyzing the current price and Ichimoku indicators.
The position of price with respect to Ichimoku indicators states the market condition clearly.')
table.merge_cells(ichimokuTable, 0, 1, 6, 1)
table.cell(ichimokuTable,0,2,text=useShortNotation?'P-C':'Kumo(C)',text_halign=text.align_right,
tooltip = 'Price(P) and Kumo(C): P > C = Bullish (↑). P < C = Bearish(↓). P <> C = consolidation or no trend(↔). Score: ±2 ')
table.cell(ichimokuTable,0,3,text=useShortNotation?'P-T':'Tenkan Sen(T)',text_halign=text.align_right,
tooltip = 'Price(P) and Tenkan Sen(T): P >= T = Bullish (↑). P < T = Bearish(↓). Score: ±0.5')
table.cell(ichimokuTable,0,4,text=useShortNotation?'P-K':'Kijun Sen(K)',text_halign=text.align_right,
tooltip = 'Price(P) and Kijun Sen(K): P >= K = Bullish (↑). P < T = Bearish(↓). Score: ±0.5')
table.cell(ichimokuTable,0,5,text=useShortNotation?'P-L':'Chikou(L)',text_halign=text.align_right,
tooltip = 'Price(26 bars ago) and Chiku(L): L >= P(26) = Bullish (↑). L < P(26) = Bearish(↓). Score: ±0.5')
table.cell(ichimokuTable,0,6,text=useShortNotation?'T-K':'Tenkan Sen(T) Vs. Kijun Sen(K)', bgcolor = useShortNotation?color.yellow:subHeaderColor,
tooltip = 'Tenkan Sen(T) and Kijun Sen(K): T >= K = Bullish (↑). T < K = Bearish(↓). Score: ±2')
if not useShortNotation
table.cell(ichimokuTable,0,7,text='Direction(D) of Ichimoku Indicators',bgcolor = subHeaderColor,
tooltip ='The direction of Ichimoku indicators helps us to understand the trend and its direction.')
table.merge_cells(ichimokuTable, 0, 7, 6, 7)
table.cell(ichimokuTable,0,8,text=useShortNotation?'D-T':'Tenkan Sen(T)',text_halign=text.align_right,
tooltip = "Tenkan Sen's(T) direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
table.cell(ichimokuTable,0,9,text=useShortNotation?'D-K':'Kijun Sen(K)',text_halign=text.align_right,
tooltip = "Kijun Sen's(K) direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
table.cell(ichimokuTable,0,10,text=useShortNotation?'D-A':'Senkou A(A)',text_halign=text.align_right,
tooltip = "Senkou A(A) direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
table.cell(ichimokuTable,0,11,text=useShortNotation?'D-B':'Senkou B(B)',text_halign=text.align_right,
tooltip = "Senkou B(A) direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
if not useShortNotation
table.cell(ichimokuTable,0,12,text='Kumo(C) Analysis',bgcolor = subHeaderColor,
tooltip = 'Kumo or Cloud is very important in the Ichimoku system. Analyzing its relation with other
indicators is important to detect the overall market condition.')
table.merge_cells(ichimokuTable, 0,12 , 6, 12)
table.cell(ichimokuTable,0,13,text=useShortNotation?'C-T':'Tenkan Sen(T)',text_halign=text.align_right,
tooltip = "Kumo(C) and Tenkan Sen(T): T >= C = Bullish (↑). T < C = Bearish(↓). T <> C = consolidation or no trend(↔). Score: ±0.5" )
table.cell(ichimokuTable,0,14,text=useShortNotation?'C-K':'Kijun Sen(K)',text_halign=text.align_right,
tooltip = 'Kumo(C) and Kijun Sen(K): K >= C = Bullish (↑). K < C = Bearish(↓). K <> C = consolidation or no trend(↔). Score: ±0.5')
table.cell(ichimokuTable,0,15,text=useShortNotation?'C-L':'Chikou(L)',text_halign=text.align_right,
tooltip = 'Kumo(C) and Chiku(L): L >= C = Bullish (↑). L < C = Bearish(↓). L <> C = consolidation or no trend(↔). Score: ±0.5')
table.cell(ichimokuTable,0,16,text=useShortNotation?'CS':'Shadow(S)',text_halign=text.align_right,
tooltip = 'Kumo(C) Shadow: If Kumo shadow is present behind the price, trend strength will be weakened. Score: ±0.5')
table.cell(ichimokuTable,0,17,text=useShortNotation?'CF':'Future(F)',text_halign=text.align_right,
tooltip = 'Kumo(C) Future (Senkou A(A) and Senkou B(B)): A >= B = Bullish (↑). A < B = Bearish(↓). Score: ±0.5')
if not useShortNotation
table.cell(ichimokuTable,0,18,text='Chikou(L) Analysis',bgcolor = subHeaderColor,
tooltip = 'Vertical and Horizontal Chiku analysis will tell us about the possible consolidation of the price.' )
table.merge_cells(ichimokuTable, 0, 18, 6, 18)
table.cell(ichimokuTable,0,19,text=useShortNotation?'LH':'Horizontal(H)',text_halign=text.align_right,
tooltip = 'Chiku Vertical: if the price consolidates for the next 5 bars(You can change this option)
will it run into the price. Please remember we are placing the current price 26 bars ago and we are
interested to see the current price in open space for a clear trend. Score: ±0.5')
table.cell(ichimokuTable,0,20,text=useShortNotation?'LV':'Vertical(V)',text_halign=text.align_right,
tooltip = 'Chikou Horizontal: If Chiku is in open space (Not running into the price),
we want to review Chiku vertically i.e how much percentage of fall or rise of
the current price can cause Chiku to run into the price. ')
if not useShortNotation
table.cell(ichimokuTable,0,21,text='Ichimoku Signal Analysis',bgcolor = subHeaderColor,
tooltip = 'Ichimoku signals: We know, that the crossover of Ichimoku indicators provides
important signals. In this section, you can see all the crossover i.e when they happened (Bars ago)')
table.merge_cells(ichimokuTable, 0, 21, 6, 21)
table.cell(ichimokuTable,0,22,text=useShortNotation?'PXT':'Price(P) Vs. Tenkan Sen(T)',text_halign=text.align_right,
tooltip = 'Price(P) and Tenkan Sen(T) crossover')
table.cell(ichimokuTable,0,23,text=useShortNotation?'PXK':'Price(P) Vs. Kijun Sen(K)',text_halign=text.align_right,
tooltip = 'Price(P) and Kijun Sen(K) crossover')
table.cell(ichimokuTable,0,24,text=useShortNotation?'PXC':'Price(P) Vs. Kumo(C)',text_halign=text.align_right,
tooltip = 'Price(P) and Kumo(C) crossover')
table.cell(ichimokuTable,0,25,text=useShortNotation?'TXK':'Tenkan Sen(T) Vs. Kijun Sen(K)',text_halign=text.align_right,
tooltip = 'Tenkan Sen(T) and Kijun Sen(K) crossover')
table.cell(ichimokuTable,0,26,text=useShortNotation?'AXB':'Senkou A(A) Vs. Senkou B(B)',text_halign=text.align_right,
tooltip = 'Senkou A(A) and Senkou B(B) Crossover')
table.cell(ichimokuTable,0,27,text=useShortNotation?'S':'Score',text_halign=text.align_right,bgcolor = useShortNotation?color.yellow:subHeaderColor,
tooltip = 'Trend Score: maximum trend score is ±10.5')
if not useShortNotation
table.cell(ichimokuTable,0,28,text='Current Price Distance',bgcolor = subHeaderColor,
tooltip = 'Distance between price and Tenkan Sen and Kijun Sen: We know, the price come
back to Tenkan/Kijun if it goes far away from Tenkan/Kijun. So it is important to note the distance between Tenkan and Price.')
table.merge_cells(ichimokuTable, 0, 28, 6, 28)
table.cell(ichimokuTable,0,29,text=useShortNotation?'P-T':'Price(P) and Tenkan Sen(T)'+pip(),text_halign=text.align_right,
tooltip = 'Distance between Price(P) and Tenkan Sen(T)')
table.cell(ichimokuTable,0,30,text=useShortNotation?'P-K':'Price(P) and Kijun Sen(K)'+pip(),text_halign=text.align_right,
tooltip = 'Distance between Price(P) and Kijun Sen(K)')
f_set_the_table(ichimokuTable,1,priceKumo1, priceTenkanSen1, priceKijunSen1, priceChiku1, tkCross1, tDirection1,
kDirection1, kumoTenkanSen1, kumoKijunSen1, kumochiku1, kumoShadow1, senkouAB1,
ADirection1, BDirection1, chikuHorizontal1, chikuVertical1, tenkanCrossover1,
kijunSenCrossover1, tsCrossover1, kumoCrossover1, senkouCrossover1, score1,
distanceBetweenTenkanAndPrice1,
distanceBetweenKijunAndPrice1)
f_set_the_table(ichimokuTable,2,priceKumo2, priceTenkanSen2, priceKijunSen2, priceChiku2, tkCross2, tDirection2,
kDirection2, kumoTenkanSen2, kumoKijunSen2, kumochiku2, kumoShadow2, senkouAB2,
ADirection2, BDirection2, chikuHorizontal2, chikuVertical2, tenkanCrossover2,
kijunSenCrossover2, tsCrossover2, kumoCrossover2, senkouCrossover2, score2,
distanceBetweenTenkanAndPrice2,
distanceBetweenKijunAndPrice2)
f_set_the_table(ichimokuTable,3,priceKumo3, priceTenkanSen3, priceKijunSen3, priceChiku3, tkCross3, tDirection3,
kDirection3, kumoTenkanSen3, kumoKijunSen3, kumochiku3, kumoShadow3, senkouAB3,
ADirection3, BDirection3, chikuHorizontal3, chikuVertical3, tenkanCrossover3,
kijunSenCrossover3, tsCrossover3, kumoCrossover3, senkouCrossover3, score3,
distanceBetweenTenkanAndPrice3,
distanceBetweenKijunAndPrice3)
f_set_the_table(ichimokuTable,4,priceKumo4, priceTenkanSen4, priceKijunSen4, priceChiku4, tkCross4, tDirection4,
kDirection4, kumoTenkanSen4, kumoKijunSen4, kumochiku4, kumoShadow4, senkouAB4,
ADirection4, BDirection4, chikuHorizontal4, chikuVertical4, tenkanCrossover4,
kijunSenCrossover4, tsCrossover4, kumoCrossover4, senkouCrossover4, score4,
distanceBetweenTenkanAndPrice4,
distanceBetweenKijunAndPrice4)
f_set_the_table(ichimokuTable,5,priceKumo5, priceTenkanSen5, priceKijunSen5, priceChiku5, tkCross5, tDirection5,
kDirection5, kumoTenkanSen5, kumoKijunSen5, kumochiku5, kumoShadow5, senkouAB5,
ADirection5, BDirection5, chikuHorizontal5, chikuVertical5, tenkanCrossover5,
kijunSenCrossover5, tsCrossover5, kumoCrossover5, senkouCrossover5, score5,
distanceBetweenTenkanAndPrice5,
distanceBetweenKijunAndPrice5)
f_set_the_table(ichimokuTable,6,priceKumo6, priceTenkanSen6, priceKijunSen6, priceChiku6, tkCross6, tDirection6,
kDirection6, kumoTenkanSen6, kumoKijunSen6, kumochiku6, kumoShadow6, senkouAB6,
ADirection6, BDirection6, chikuHorizontal6, chikuVertical6, tenkanCrossover6,
kijunSenCrossover6, tsCrossover6, kumoCrossover6, senkouCrossover6, score6,
distanceBetweenTenkanAndPrice6,
distanceBetweenKijunAndPrice6)
|
Frog in Pan Indicator | https://www.tradingview.com/script/cMzlj8mO-Frog-in-Pan-Indicator/ | jamiedubauskas | https://www.tradingview.com/u/jamiedubauskas/ | 16 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jamiedubauskas
//@version=5
indicator(title = "Frog in Pan Indicator", shorttitle = "FIP Indicator", format = format.percent, precision = 4)
// input variable for the lookback
lookback = input.int(title = "Lookback Period", defval = 365, minval = 1, tooltip = "Lookback period for assesing how many days are positive and negative used for indicator")
// input variables to see what to show
show_pos = input.bool(title = "Show Positive Days Count?", defval = false)
show_neg = input.bool(title = "Show Negative Days Count?", defval = false)
show_fip = input.bool(title = "Show FIP Indicator?", defval = true)
// looping through the lookback and counting the number of positive days and negative days
num_pos = 0
num_neg = 0
for i = 0 to lookback
if close[i] > open[i]
num_pos += 1
else if close[i] < open[i]
num_neg += 1
// fip indicator
percent_pos = (num_pos / lookback) * 100
percent_neg = (num_neg / lookback) * 100
generic_momentum_sign = (close[1] >= close[lookback]) ? 1 : -1
fip = (generic_momentum_sign) * (percent_neg - percent_pos)
// showing variables for plotting
plot_pos = show_pos ? num_pos : na
plot_neg = show_neg ? num_neg : na
plot_fip = show_fip ? fip : na
// plotting indicator
plot(plot_pos, color = color.new(color.green,0))
plot(plot_neg, color = color.new(color.red,0))
plot(plot_fip, color = color.new(color.white,0))
// input variable to plot horizontal 0 line or not
show_hline = input.bool(title = "Show Horizontal 0-Line?", defval = true)
hline_val = show_hline ? 0 : na
hline(price = hline_val, title = "Zero Line", color = color.new(color.white, 50), linestyle = hline.style_dashed)
|
Bogdan Ciocoiu - Greuceanu | https://www.tradingview.com/script/bpze1D8W-Bogdan-Ciocoiu-Greuceanu/ | BogdanCiocoiu | https://www.tradingview.com/u/BogdanCiocoiu/ | 57 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BogdanCiocoiu
//@version=5
indicator("Bogdan Ciocoiu - Greuceanu", shorttitle="BC - Greuceanu", format=format.price, precision=2, timeframe="", timeframe_gaps=true, explicit_plot_zorder=true)
// Description
// This indicator is an entry-level script that simplifies volume interpretation for beginning traders.
// It is a handy tool that removes all the noise and focuses traders on identifying potential smart money injections.
// Uniqueness
// This indicator is unique because it introduces the principle of a moving average in the context of volume and then compares it with tick-based volume.
// Its uniqueness is reflected in the ability to colour code each volume bar based on the intensity of each relevant (volume) unit whilst comparing it with the volume moving average.
// Another benefit of this indicator is the colour coding scheme that removes volume below a particular threshold (default set to 1) under the volume moving average.
// In addition to the above features, the indicator differentiates the colour of each bar by price direction.
// Open source re-use
// To achieve this functionality several open source indicators have been used an integrated within the current one.
// https://www.tradingview.com/script/PpjPs450-Neglected-Volume-by-DGT/
// https://www.tradingview.com/script/s4xadZFc/
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Volume MA
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_vol_MA_len_1 = input(20, 'Volume MA 1', inline='Volume MA', group='Volume MA')
_vol_MA_1 = 0.0
_vol_MA_1 := nz(_vol_MA_1[1]) + (volume-nz(_vol_MA_1[1])) / _vol_MA_len_1
_vol_ratio_1 = volume/_vol_MA_1
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Volume histogram
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
_vol_pos_strong = input(color.new(color.green, 0), '', inline='Volume positive', group='Volume colors (pos/neg v strong/weak/others)')
_vol_pos_weak = input(color.new(color.silver, 90), '', inline='Volume positive', group='Volume colors (pos/neg v strong/weak/others)')
_vol_pos_others = input(color.new(color.green, 80), '', inline='Volume positive', group='Volume colors (pos/neg v strong/weak/others)')
_vol_neg_strong = input(color.new(color.red, 0), '', inline='Volume positive', group='Volume colors (pos/neg v strong/weak/others)')
_vol_neg_weak = input(color.new(color.silver, 90), '', inline='Volume positive', group='Volume colors (pos/neg v strong/weak/others)')
_vol_neg_others = input(color.new(color.red, 80), '', inline='Volume positive', group='Volume colors (pos/neg v strong/weak/others)')
_vol_limit_1 = input(1, 'Threshold 1', inline='Threshold ratios', group='Threshold ratios')
_vol_limit_2 = input(2.2, '2', inline='Threshold ratios', group='Threshold ratios')
_vol_color = (close > open) ?
(_vol_ratio_1 < _vol_limit_1) ? _vol_pos_weak : (_vol_ratio_1 > _vol_limit_2) ? _vol_pos_strong : _vol_pos_others :
(_vol_ratio_1 < _vol_limit_1) ? _vol_neg_weak : (_vol_ratio_1 > _vol_limit_2) ? _vol_neg_strong : _vol_neg_others
plot(_vol_ratio_1, style=plot.style_columns, color=_vol_color, histbase=1)
|
JNSAR-DP | https://www.tradingview.com/script/lEuCw5DS-JNSAR-DP/ | deepphalke | https://www.tradingview.com/u/deepphalke/ | 63 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © deepphalke
//Plot JNSAR and 5 period High EMA and 5 period Low EMA.
//If close is abvoe high EMA, fill green color, if close is below low ema, fill red color. if price is between high and low ema, fill greay color.
//Plots the indicator in a Day and Week time period
//@version=5
indicator(title='JNSAR-DP', overlay=true)
h = high
l = low
c = close
ema1 = ta.ema(h, 5)
ema2 = ta.ema(l, 5)
ema3=ta.ema(c, 5)
avg = (ema1+ema2+ema3+ta.ema(h[1], 5)+ta.ema(l[1], 5)+ta.ema(c[1], 5)+ta.ema(h[2], 5)+ta.ema(l[2], 5)+ta.ema(c[2], 5)+ta.ema(h[3], 5)+ta.ema(l[3], 5)+ta.ema(c[3], 5)+ta.ema(h[4], 5)+ta.ema(l[4], 5)+ta.ema(c[4], 5))/15
plotJnsar = timeframe.period == 'D' or timeframe.period == 'W' or timeframe.period == '60'
plot(plotJnsar?avg:na, title="JNSAR",style=plot.style_line, linewidth=1, color = color.red, offset = 1)
trns=80
ploth=plot(plotJnsar?ema1:na, title="High EMA-5",style=plot.style_line, linewidth=1, color = color.new(#804000, trns), offset = 1)
plotl=plot(plotJnsar?ema2:na, title="Low EMA-5",style=plot.style_line, linewidth=1, color =color.new(color.green, trns), offset = 1)
diff=avg-ema3
colorStrength = (diff<diff[1])? true : false
trns60=60
clr=close>ema1[1] and close>avg[1]?(colorStrength?color.new(color.green,trns60):color.new(color.green,trns)):(close<ema2[1] and close<avg[1]?(colorStrength?color.new(color.red,trns):color.new(color.red, trns60)):color.new(color.black, trns))
fill(ploth, plotl, clr)
plot(plotJnsar?ema3:na, title="Close EMA-5",style=plot.style_line, linewidth=1, color = color.new(color.blue, 0), offset = 1)
//Volatality and Fibbonacci trade table
showTable=input(true, title="Show VF Table")
res = 'D'
test1=0
f_secureSecurity(_symbol, _res, _src) => request.security(_symbol, _res, _src, barmerge.gaps_off) // orignal code line
dc = f_secureSecurity(syminfo.tickerid, res, close[1+test1])
dc1 = f_secureSecurity(syminfo.tickerid, res, close[2+test1])
dc2 = f_secureSecurity(syminfo.tickerid, res, close[3+test1])
dc3 = f_secureSecurity(syminfo.tickerid, res, close[4+test1])
dc4 = f_secureSecurity(syminfo.tickerid, res, close[5+test1])
dc5 = f_secureSecurity(syminfo.tickerid, res, close[6+test1])
dc6 = f_secureSecurity(syminfo.tickerid, res, close[7+test1])
dc7 = f_secureSecurity(syminfo.tickerid, res, close[8+test1])
dc8 = f_secureSecurity(syminfo.tickerid, res, close[9+test1])
dc9 = f_secureSecurity(syminfo.tickerid, res, close[10+test1])
dc10 = f_secureSecurity(syminfo.tickerid, res, close[11+test1])
dop = f_secureSecurity(syminfo.tickerid, res, open)
logg00 = math.log(dc/dc1)
logg11 = math.log(dc1/dc2)
logg22 = math.log(dc2/dc3)
logg33 = math.log(dc3/dc4)
logg44 = math.log(dc4/dc5)
logg55 = math.log(dc5/dc6)
logg66 = math.log(dc6/dc7)
logg77 = math.log(dc7/dc8)
logg88 = math.log(dc8/dc9)
logg99 = math.log(dc9/dc10)
squrr00 = logg00*logg00
squrr11 = logg11*logg11
squrr22 = logg22*logg22
squrr33 = logg33*logg33
squrr44 = logg44*logg44
squrr55 = logg55*logg55
squrr66 = logg66*logg66
squrr77 = logg77*logg77
squrr88 = logg88*logg88
squrr99 = logg99*logg99
avg_logg0 = (logg00+logg11+logg22+logg33+logg44+logg55+logg66+logg77+logg88+logg99)/10
avg_squrr0 = (squrr00+squrr11+squrr22+squrr33+squrr44+squrr55+squrr66+squrr77+squrr88+squrr99)/10
variancee0 = avg_squrr0 - (avg_logg0*avg_logg0)
volatility0 = math.sqrt(variancee0)
round_preci=input.int(title="VF Decimal Scale", options=[0,1,2,3], defval=0)
range11=math.round(dc*volatility0,round_preci)
doKdc= math.abs(dop-dc)>(0.382*range11)? dop : dc
//re-do calc
logg = math.log(doKdc/dc1)
logg1 = math.log(dc1/dc2)
logg2 = math.log(dc2/dc3)
logg3 = math.log(dc3/dc4)
logg4 = math.log(dc4/dc5)
logg5 = math.log(dc5/dc6)
logg6 = math.log(dc6/dc7)
logg7 = math.log(dc7/dc8)
logg8 = math.log(dc8/dc9)
logg9 = math.log(dc9/dc10)
squrr = logg*logg
squrr1 = logg1*logg1
squrr2 = logg2*logg2
squrr3 = logg3*logg3
squrr4 = logg4*logg4
squrr5 = logg5*logg5
squrr6 = logg6*logg6
squrr7 = logg7*logg7
squrr8 = logg8*logg8
squrr9 = logg9*logg9
avg_logg = (logg+logg1+logg2+logg3+logg4+logg5+logg6+logg7+logg8+logg9)/10
avg_squrr = (squrr+squrr1+squrr2+squrr3+squrr4+squrr5+squrr6+squrr7+squrr8+squrr9)/10
variancee = avg_squrr - (avg_logg*avg_logg)
volatility = math.sqrt(variancee)
range1=math.round(doKdc*volatility,round_preci)
//doKdc=dc
buy_above=math.round(doKdc+(range1 * 0.236),round_preci)
buy_conf=math.round(doKdc+(range1 * 0.382),round_preci)
b_t1=math.round(doKdc+(range1 * 0.5),round_preci)
b_t2=math.round(doKdc+(range1 * 0.618),round_preci)
b_t3=math.round(doKdc+(range1 * 0.786),round_preci)
b_t4=math.round(doKdc+(range1 * 0.888),round_preci)
b_t5=math.round(doKdc+(range1 * 1.236),round_preci)
b_t6=math.round(doKdc+(range1 * 1.618),round_preci)
sell_below=math.round(doKdc-(range1 * 0.236),round_preci)
sell_conf=math.round(doKdc-(range1 * 0.382),round_preci)
s_t1=math.round(doKdc-(range1 * 0.5),round_preci)
s_t2=math.round(doKdc-(range1 * 0.618),round_preci)
s_t3=math.round(doKdc-(range1 * 0.786),round_preci)
s_t4=math.round(doKdc-(range1 * 0.888),round_preci)
s_t5=math.round(doKdc-(range1 * 1.236),round_preci)
s_t6=math.round(doKdc-(range1 * 1.618),round_preci)
color_g=#e6fce8
coor_r=#fce6ea
color_n=#bab8b8
color_rg=#ebe6ea
color_wh=color.white
txt_color_r=#f50a19
txt_color_g=#039458
sizeOption = input.string(title="VF Text Size",
options=["Normal", "Small"],
defval="Small")
txtSize= (sizeOption == "Small") ? size.small : size.normal
plotVF = timeframe.period == 'D' or timeframe.period == '120'or timeframe.period == '120' or timeframe.period == '60' or timeframe.period == '15' or timeframe.period == '30'
or timeframe.period == '5' or timeframe.period == '3' or timeframe.period == '180'or timeframe.period == '240'
trendingTimes="T4,T5,T6: On trending Times"
NormalTargets="T2,T3: Normal Targets"
tableToolTip="This table works well in a Trending Markets; in sideways market use it as Support and Resistance"
var testTable = table.new(position = position.bottom_right, columns = 9, rows = 3, bgcolor = color.yellow, border_width = 1, border_color=color.white)
if barstate.islast and plotVF and showTable
table.cell(table_id = testTable, column = 1, row = 0, text = "^/v " ,text_size=txtSize,tooltip="Above/Below")
table.cell(table_id = testTable, column = 2, row = 0, text = "Conf ", bgcolor=color.green,text_size=txtSize,tooltip="Confirmation")
table.cell(table_id = testTable, column = 3, row = 0, text = "T1 ", bgcolor=color_wh,text_size=txtSize)
table.cell(table_id = testTable, column = 4, row = 0, text = "T2 ", bgcolor=color.gray,text_size=txtSize,tooltip=NormalTargets)
table.cell(table_id = testTable, column = 5, row = 0, text = "T3 ", bgcolor=color.gray,text_size=txtSize,tooltip=NormalTargets)
table.cell(table_id = testTable, column = 6, row = 0, text = "T4 ", bgcolor=color.green,text_size=txtSize,tooltip=trendingTimes)
table.cell(table_id = testTable, column = 7, row = 0, text = "T5 ", bgcolor=color.green,text_size=txtSize,tooltip=trendingTimes)
table.cell(table_id = testTable, column = 8, row = 0, text = "T6 ", bgcolor=color.green,text_size=txtSize,tooltip=trendingTimes)
table.cell(table_id = testTable, column = 0, row = 0, text = "VF Table", bgcolor=color.white, text_size=txtSize,tooltip=tableToolTip)
table.cell(table_id = testTable, column = 0, row = 1, text = "For Buy Above ", bgcolor=color.green ,text_size=txtSize)
table.cell(table_id = testTable, column = 0, row = 2, text = "For Sell Below ", bgcolor=color.orange ,text_size=txtSize)
table.cell(table_id = testTable, column = 1, row = 1, text = str.tostring(buy_above), bgcolor=color_g ,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 2, row = 1, text = str.tostring(buy_conf), bgcolor=color_g,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 3, row = 1, text = str.tostring(b_t1), bgcolor=color_wh,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 4, row = 1, text = str.tostring(b_t2), bgcolor=color_n,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 5, row = 1, text = str.tostring(b_t3), bgcolor=color_n,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 6, row = 1, text = str.tostring(b_t4), bgcolor=color_g,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 7, row = 1, text = str.tostring(b_t5), bgcolor=color_g,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 8, row = 1, text = str.tostring(b_t6), bgcolor=color_g,text_size=txtSize, text_color=txt_color_r)
table.cell(table_id = testTable, column = 1, row = 2, text = str.tostring(sell_below) , bgcolor=coor_r,text_size=txtSize,text_color=txt_color_g)
table.cell(table_id = testTable, column = 2, row = 2, text = str.tostring(sell_conf), bgcolor=coor_r,text_size=txtSize,text_color=txt_color_g)
table.cell(table_id = testTable, column = 3, row = 2, text = str.tostring(s_t1), bgcolor=color_wh,text_size=txtSize,text_color=txt_color_g)
table.cell(table_id = testTable, column = 4, row = 2, text = str.tostring(s_t2), bgcolor=color_rg,text_size=txtSize,text_color=txt_color_g)
table.cell(table_id = testTable, column = 5, row = 2, text = str.tostring(s_t3), bgcolor=color_rg,text_size=txtSize,text_color=txt_color_g)
table.cell(table_id = testTable, column = 6, row = 2, text = str.tostring(s_t4), bgcolor=coor_r,text_size=txtSize,text_color=txt_color_g)
table.cell(table_id = testTable, column = 7, row = 2, text = str.tostring(s_t5), bgcolor=coor_r,text_size=txtSize,text_color=txt_color_g)
table.cell(table_id = testTable, column = 8, row = 2, text = str.tostring(s_t6), bgcolor=coor_r,text_size=txtSize,text_color=txt_color_g)
tf = timeframe.isintraday ? "D" : "W"
d_high = f_secureSecurity(syminfo.tickerid, tf, high[1+test1])
d_low = f_secureSecurity(syminfo.tickerid, tf, low[1+test1])
d_close = f_secureSecurity(syminfo.tickerid, tf, close[1+test1])
pivot = (d_high + d_low + d_close)/3
BC = (d_high + d_low)/2
TC = (pivot - BC) + pivot
R1 = (pivot * 2) - d_low
R2 = pivot + (d_high-d_low)
S1 = (pivot * 2) - d_high
S2 = pivot - (d_high-d_low)
var testPTable = table.new(position = position.top_right, columns = 8, rows = 2, bgcolor = color.yellow, border_width = 1, border_color=color.white)
table.cell(table_id = testPTable, column = 0, row = 0, text = "S2 ",text_size=txtSize )
table.cell(table_id = testPTable, column = 1, row = 0, text = "S1 ",text_size=txtSize )
table.cell(table_id = testPTable, column = 2, row = 0, text = "Pivot" ,text_size=txtSize)
table.cell(table_id = testPTable, column = 3, row = 0, text = "R1 ",text_size=txtSize )
table.cell(table_id = testPTable, column = 4, row = 0, text = "R2",text_size=txtSize )
table.cell(table_id = testPTable, column = 5, row = 0, text = "BC",text_size=txtSize )
table.cell(table_id = testPTable, column = 6, row = 0, text = "TC",text_size=txtSize )
table.cell(table_id = testPTable, column = 7, row = 0, text = "Range",text_size=txtSize )
table.cell(table_id = testPTable, column = 0, row = 1, text = str.tostring(math.round(S2,round_preci)) ,bgcolor=color.green,text_size=txtSize)
table.cell(table_id = testPTable, column = 1, row = 1, text = str.tostring(math.round(S1,round_preci)), bgcolor=color.green,text_size=txtSize )
table.cell(table_id = testPTable, column = 2, row = 1, text = str.tostring(math.round(pivot,round_preci)) ,text_size=txtSize)
table.cell(table_id = testPTable, column = 3, row = 1, text = str.tostring(math.round(R1,round_preci)) , bgcolor=color.orange,text_size=txtSize )
table.cell(table_id = testPTable, column = 4, row = 1, text = str.tostring(math.round(R2,round_preci)) , bgcolor=color.orange,text_size=txtSize )
table.cell(table_id = testPTable, column = 5, row = 1, text = str.tostring(math.round(BC,round_preci)) , bgcolor=color.green,text_size=txtSize )
table.cell(table_id = testPTable, column = 6, row = 1, text = str.tostring(math.round(TC,round_preci)) , bgcolor=color.green,text_size=txtSize )
table.cell(table_id = testPTable, column = 7, row = 1, text = str.tostring(math.round((TC-BC),round_preci+1)) , bgcolor=color.orange,text_size=txtSize )
|
Strong, Weak, Intra | https://www.tradingview.com/script/pnFYxYPO-Strong-Weak-Intra/ | JustinJoh | https://www.tradingview.com/u/JustinJoh/ | 36 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator("Strong, Weak, Intra", overlay=true)
group_s = 'Strong Levels'
group_w = 'Weak Levels'
group_i = 'Intra Day Levels'
group_levels_s = 'Strong Levels:'
s18 = input.float(title='Strong', defval=0.0, inline='s12', group=group_levels_s)
s17 = input.float(title='Strong', defval=0.0, inline='s12', group=group_levels_s)
s16 = input.float(title='Strong', defval=0.0, inline='s12', group=group_levels_s)
s15 = input.float(title='Strong', defval=0.0, inline='s10', group=group_levels_s)
s14 = input.float(title='Strong', defval=0.0, inline='s10', group=group_levels_s)
s13 = input.float(title='Strong', defval=0.0, inline='s10', group=group_levels_s)
s12 = input.float(title='Strong', defval=0.0, inline='s8', group=group_levels_s)
s11 = input.float(title='Strong', defval=0.0, inline='s8', group=group_levels_s)
s10 = input.float(title='Strong', defval=0.0, inline='s8', group=group_levels_s)
s9 = input.float(title='Strong', defval=0.0, inline='s6', group=group_levels_s)
s8 = input.float(title='Strong', defval=0.0, inline='s6', group=group_levels_s)
s7 = input.float(title='Strong', defval=0.0, inline='s6', group=group_levels_s)
s6 = input.float(title='Strong', defval=0.0, inline='s4', group=group_levels_s)
s5 = input.float(title='Strong', defval=0.0, inline='s4', group=group_levels_s)
s4 = input.float(title='Strong', defval=0.0, inline='s4', group=group_levels_s)
s3 = input.float(title='Strong', defval=0.0, inline='s2', group=group_levels_s)
s2 = input.float(title='Strong', defval=0.0, inline='s2', group=group_levels_s)
s1 = input.float(title='Strong', defval=0.0, inline='s2', group=group_levels_s)
group_levels_w = 'Weak Levels:'
w18 = input.float(title='Weak', defval=0.0, inline='w9', group=group_levels_w)
w17 = input.float(title='Weak', defval=0.0, inline='w9', group=group_levels_w)
w16 = input.float(title='Weak', defval=0.0, inline='w9', group=group_levels_w)
w15 = input.float(title='Weak', defval=0.0, inline='w0', group=group_levels_w)
w14 = input.float(title='Weak', defval=0.0, inline='w0', group=group_levels_w)
w13 = input.float(title='Weak', defval=0.0, inline='w0', group=group_levels_w)
w12 = input.float(title='Weak', defval=0.0, inline='w1', group=group_levels_w)
w11 = input.float(title='Weak', defval=0.0, inline='w1', group=group_levels_w)
w10 = input.float(title='Weak', defval=0.0, inline='w1', group=group_levels_w)
w9 = input.float(title='Weak', defval=0.0, inline='w3', group=group_levels_w)
w8 = input.float(title='Weak', defval=0.0, inline='w3', group=group_levels_w)
w7 = input.float(title='Weak', defval=0.0, inline='w3', group=group_levels_w)
w6 = input.float(title='Weak', defval=0.0, inline='w5', group=group_levels_w)
w5 = input.float(title='Weak', defval=0.0, inline='w5', group=group_levels_w)
w4 = input.float(title='Weak', defval=0.0, inline='w5', group=group_levels_w)
w3 = input.float(title='Weak', defval=0.0, inline='w7', group=group_levels_w)
w2 = input.float(title='Weak', defval=0.0, inline='w7', group=group_levels_w)
w1 = input.float(title='Weak', defval=0.0, inline='w7', group=group_levels_w)
group_levels_i = 'Intra Day Levels:'
i8 = input.float(title='Intra', defval=0.0, inline='i8', group=group_levels_i)
i7 = input.float(title='Intra', defval=0.0, inline='i8', group=group_levels_i)
i6 = input.float(title='Intra', defval=0.0, inline='i6', group=group_levels_i)
i5 = input.float(title='Intra', defval=0.0, inline='i6', group=group_levels_i)
i4 = input.float(title='Intra', defval=0.0, inline='i4', group=group_levels_i)
i3 = input.float(title='Intra', defval=0.0, inline='i4', group=group_levels_i)
i2 = input.float(title='Intra', defval=0.0, inline='i2', group=group_levels_i)
i1 = input.float(title='Intra', defval=0.0, inline='i2', group=group_levels_i)
hline(s18, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s17, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s16, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s15, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s14, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s13, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s12, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s11, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s10, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s9, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s8, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s7, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s6, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s5, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s4, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s3, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s2, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(s1, title='strong', color=color.white, linestyle=hline.style_solid, linewidth=2)
hline(w18, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w17, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w16, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w15, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w14, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w13, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w12, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w11, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w10, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w9, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w8, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w7, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w6, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w5, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w4, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w3, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w2, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(w1, title='weak', color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(i8, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(i7, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(i6, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(i5, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(i4, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(i3, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(i2, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(i1, title='intra', color=color.gray, linestyle=hline.style_dotted, linewidth=1)
plot(close) |
Support & Resistance Hit Counter | https://www.tradingview.com/script/NhopkJLA-Support-Resistance-Hit-Counter/ | KSMT_Armenia | https://www.tradingview.com/u/KSMT_Armenia/ | 54 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Logic by @TradesByMatt
// Tool by @TheBitBrine
//@version=5
indicator("Support & Resistance Hit Counter", overlay=true)
var price = input.float(0, "Price line", step = 0.1)
enableTrend = input.bool(false, "Trend")
tradingMode = input.bool(false, "Enabled", group="Trade Simulator")
lev = input.float(10, "Leverage", group="Trade Simulator")
pos = input.float(10000, "Cointracts", group="Trade Simulator")
pos := pos / close
var crossed = 0
green = false
if(close > open)
green := true
highestBody = math.max(close, open)
lowestBody = math.min(close, open)
var highValue = 0.0
var lowValue = 9999999.0
var highValue2 = 0.0
var lowValue2 = 9999999.0
var lastHitPrice = 0.0
if(price < high and price > highestBody)
crossed := crossed+1
if(low < lowValue2)
lowValue2 := low
if(high > highValue)
highValue := high
lastHitPrice := close
if(price > low and price < lowestBody)
crossed := crossed+1
if(low < lowValue)
lowValue := low
if(high > highValue2)
highValue2 := high
lastHitPrice := close
plotshape(crossed != crossed[1] ? price : na, style = shape.cross, size=size.small, location=location.absolute, color=color.orange)
plot(lowValue < 9999999.0 ? price : na, color=color.orange, transp=40)
hvp = plot(highValue > 0 ? highValue : na, color=color.green, transp=0, style= plot.style_circles)
lvp = plot(lowValue < 9999999.0 ? lowValue : na, color=color.red, transp=0, style= plot.style_circles)
hvp2 = plot(highValue2 > 0 ? highValue2 : na, color=color.green, transp=0, style= plot.style_circles)
lvp2 = plot(lowValue2 < 9999999.0 ? lowValue2 : na, color=color.red, transp=0, style= plot.style_circles)
fill(hvp, lvp, color=color.blue, transp=95)
fill(hvp2, lvp2, color=color.blue, transp=95)
fallingside = price > close
risingside = price < close
side = "NA"
if(fallingside)
side := "Short"
if(risingside)
side := "Long"
fallingtrend = ta.falling(ta.ema(close, 9), 3)
risingtrend = ta.rising(ta.ema(close, 9), 3)
trend = "\n[ NA ]"
if(fallingtrend)
trend := "\n[ Bearish ]"
if(risingtrend)
trend := "\n[ Bullish ]"
if(enableTrend == false)
trend := ""
currLvl1 = fallingside ? lowValue : highValue
currLvl2 = fallingside ? lowValue2 : highValue2
tradeString = tradingMode ? "\n\nSide: " + side + "\nProfit: $" + str.tostring(math.round(math.abs(pos * ((close - lastHitPrice) * lev)), 2)) : ""
tradeString := tradingMode ? tradeString + "\nTP 1: $" + str.tostring(math.round(math.abs(pos * ((currLvl1 - lastHitPrice) * lev)), 2)) : ""
tradeString := tradingMode ? tradeString + "\nTP 2: $" + str.tostring(math.round(math.abs(pos * ((currLvl2 - lastHitPrice) * lev)), 2)) : ""
if(lowValue == 9999999.0 and lowValue2 == 9999999.0 and highValue == 0.0 and highValue2 == 0.0)
lab_l = label.new(
bar_index + 10, close, '[ S/R Hit Counter ]\n Please enter entry price',
color = color.black,
textcolor = color.orange,
style = label.style_diamond,
yloc = yloc.price)
label.delete(lab_l[1])
else
lab_l = label.new(
bar_index + 10, price, '[ ' + str.tostring(price) + ' ]' + trend + '\n\nHits: ' + str.tostring(crossed) + 'x\nHigh: ' + str.tostring(highValue) + '\nLow: ' + str.tostring(lowValue) + tradeString + '\n\nOffset: $' + str.tostring(close - price),
color = color.black,
textcolor = color.orange,
style = label.style_diamond,
yloc = yloc.price)
label.delete(lab_l[1])
|
jma + dwma crossover | https://www.tradingview.com/script/J1FyVBHT-jma-dwma-crossover/ | multigrain | https://www.tradingview.com/u/multigrain/ | 107 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © multigrain
// @version=5
indicator('jma + dwma by multigrain', 'jma + dwma', overlay=true)
//NAME TYPE DEFVAL TITLE MIN MAX GROUP
longs = input.bool (true, 'Enable longs?')
shorts = input.bool (false, 'Enable shorts?')
jmaSrc = input.source (close, 'JMA Source', group='JMA')
jmaLen = input.int (7, 'JMA Length', 0, 100, group='JMA')
jmaPhs = input.int (50, 'JMA Phase', -100, 100, group='JMA')
jmaPwr = input.float (1, 'JMA Power', 0.1, group='JMA')
dwmaSrc = input.source (close, 'DWMA Source', group='DWMA')
dwmaLen = input.int (10, 'DWMA Length', 1, 100, group='DWMA')
// Jurik Moving Average
f_jma(_src, _length, _phase, _power) =>
phaseRatio = _phase < -100 ? 0.5 : _phase > 100 ? 2.5 : _phase / 100 + 1.5
beta = 0.45 * (_length - 1) / (0.45 * (_length - 1) + 2)
alpha = math.pow(beta, _power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * _src + alpha * nz(e0[1])
e1 = 0.0
e1 := (_src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
jma
// Double Weighted Moving Average
f_dwma(_src, _length) =>
ta.wma(ta.wma(_src, _length), _length)
// Calculations
jma = f_jma (jmaSrc, jmaLen, jmaPhs, jmaPwr)
dwma = f_dwma (dwmaSrc, dwmaLen)
long = ta.crossover (jma, dwma)
long_tp = ta.pivothigh (jma, 1, 1) and jma > dwma
short_tp = ta.pivotlow (jma, 1, 1) and jma < dwma
short = ta.crossunder (jma, dwma)
// Colors
green = #0F7173
red = #F05D5E
tan = #D8A47F
grey = #939FA6
white = #FFFFFF
// Plots
plot (jma, 'JMA', grey, 1, display=display.none)
plot (dwma, 'DWMA', tan, 1, display=display.none)
plotshape (longs ? long : na, 'Long Signal', shape.labelup, location.belowbar, green, 0, 'long', white, size=size.small)
plotshape (longs ? long_tp : na, 'Long Take Profit', shape.labeldown, location.abovebar, tan, 0, 'tp', white, size=size.small)
plotshape (shorts ? short : na, 'Short Signal', shape.labeldown, location.abovebar, red, 0, 'short', white, size=size.small)
plotshape (shorts ? short_tp : na, 'Short Take Profit', shape.labelup, location.belowbar, tan, 0, 'tp', white, size=size.small)
// Alerts
alertcondition (longs ? long : na, "Long", "Long", alert.freq_once_per_bar_close)
alertcondition (longs ? long_tp : na, "Long Take Profit", "Long Take Profit", alert.freq_once_per_bar_close)
alertcondition (shorts ? short : na, "Short", "Short", alert.freq_once_per_bar_close)
alertcondition (shorts ? short_tp : na, "Short Take Profit", "Short Take Profit", alert.freq_once_per_bar_close)
|
Smoothed Heikin Ashi Trend on Chart - TraderHalai | https://www.tradingview.com/script/xAIVWFsY-Smoothed-Heikin-Ashi-Trend-on-Chart-TraderHalai/ | TraderHalai | https://www.tradingview.com/u/TraderHalai/ | 160 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TraderHalai
//@version=5
indicator("Smoothed Heikin Ashi Trend on Chart - TraderHalai", " SHA Trend - TraderHalai", overlay=true)
//Inputs
i_repaint = input (true, "Repaint - Keep on for live / Off for backtest", group = "Global Options")
i_useSmooth = input ( true, "Use smoothing Heikin Ashi", group="Smooth Heikin Ashi Trend")
i_heikinAshiMethod = input.string("Heikin Ashi Close", "Heikin Ashi Method", options=["Heikin Ashi Close", "Heikin Ashi Better Close"], group="Smooth Heikin Ashi Trend")
i_smoothingMethod = input.string("SMA", "Smoothing method", options=["SMA", "EMA", "HMA", "VMWA", "RMA"] , group="Smooth Heikin Ashi Trend")
i_smoothingPeriod = input ( 10, "Smoothing period" , group="Smooth Heikin Ashi Trend")
i_adjustForVolatility = input (true, "Adapt for Volatility (ATR)", group="Smooth Heikin Ashi Trend")
i_showVolatilityPivot = input (false, "Show Volatility Pivot Line", group="Volatility Pivot Line")
i_volPivot_maType = input.string ("Three-pole Ehlers Smoother", "HAVP Smoothing type", options= ["Two-pole Ehlers Butterworth", "Two-pole Ehlers smoother", "Three-pole Ehlers Butterworth", "Three-pole Ehlers Smoother"], group='Volatility Pivot Line')
i_volSmoothingPeriod = input.int (13, "Smoothing Length", minval=1, group='Volatility Pivot Line')
i_infoBox = input ( true, "Show Info Box" , group="Info Box")
i_decimalP = input ( 2, "Prices Decimal Places", group="Info Box")
i_boxOffSet = input ( 5, "Info Box Offset" , group="Info Box")
//Security functions to avoid repaint, as per PineCoders
f_security(_symbol, _res, _src, _repaint) => request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1]
//Common Variables
timeperiod = timeframe.period
candleClose = f_security(syminfo.tickerid, timeperiod, close, i_repaint)
candleOpen = f_security(syminfo.tickerid, timeperiod, open, i_repaint)
candleLow = f_security(syminfo.tickerid, timeperiod, low, i_repaint)
candleHigh = f_security(syminfo.tickerid, timeperiod, high, i_repaint)
//Heikin Ashi Reverse Close function
heikinAshiReverseClose(bool volatilityAdjusted) =>
haTicker = ticker.heikinashi(syminfo.tickerid)
haClose = f_security(haTicker, timeperiod, close, i_repaint)
haOpen = f_security(haTicker, timeperiod, open, i_repaint)
haLow = f_security(haTicker, timeperiod, low, i_repaint)
haHigh= f_security(haTicker, timeperiod, high, i_repaint)
reverseClose = (2 * (haOpen[1] + haClose[1])) - candleHigh - candleLow - candleOpen
if(reverseClose < candleLow and volatilityAdjusted)
reverseClose := (candleLow + reverseClose) / 2
if(reverseClose > candleHigh and volatilityAdjusted)
reverseClose := (candleHigh + reverseClose) / 2
reverseClose
//Heikin Ashi Better Reverse Close function - As described by BNP Paribas in 2005
heikinAshiBetterReverseClose(bool volatilityAdjusted) =>
habClose = ((candleOpen + candleClose) /2 ) + ((candleClose - candleOpen)/(candleHigh-candleLow)) * (math.abs(candleClose - candleOpen) / 2)
habOpen = 0.
habOpen := (nz(habOpen[1]) + habClose[1])/2
//Calculate reverse Better HA close - as this formula uses Square roots, it is possible for non real values to be produced, therefore we need to try all 4 permutations
// c = 1/2 (sqrt(-8 a h + 8 a l + h^2 - 2 h l + 8 h o + l^2 - 8 l o) + h - l + 2 o) - Formula sourced from Wolfram Alpha, solving for close price.
reverseBetterA = (-math.sqrt(candleHigh - candleLow) * math.sqrt(candleHigh - candleLow + 8 * candleOpen - 8 * habOpen) + candleHigh - candleLow + 2*candleOpen) /2
reverseBetterB = (math.sqrt(candleHigh - candleLow) * math.sqrt(candleHigh - candleLow - 8 * candleOpen + 8 * habOpen) + candleHigh - candleLow + 2*candleOpen) /2
reverseBetterC = (-math.sqrt(candleHigh - candleLow) * math.sqrt(candleHigh - candleLow - 8 * candleOpen + 8 * habOpen) - candleHigh + candleLow + 2*candleOpen) /2
reverseBetterD = (math.sqrt(candleHigh - candleLow) * math.sqrt(candleHigh - candleLow - 8 * candleOpen + 8 * habOpen) - candleHigh + candleLow + 2*candleOpen) /2
//Try reverse reverse function to see which one fits
rreverseBetterA = ((candleOpen + reverseBetterA) /2 ) + ((reverseBetterA - candleOpen)/(candleHigh-candleLow)) * (math.abs(reverseBetterA - candleOpen) / 2)
rreverseBetterB = ((candleOpen + reverseBetterB) /2 ) + ((reverseBetterB - candleOpen)/(candleHigh-candleLow)) * (math.abs(reverseBetterB - candleOpen) / 2)
rreverseBetterC = ((candleOpen + reverseBetterC) /2 ) + ((reverseBetterC - candleOpen)/(candleHigh-candleLow)) * (math.abs(reverseBetterC - candleOpen) / 2)
rreverseBetterD = ((candleOpen + reverseBetterD) /2 ) + ((reverseBetterD - candleOpen)/(candleHigh-candleLow)) * (math.abs(reverseBetterD - candleOpen) / 2)
float reverseClose = na
if(rreverseBetterA == habOpen)
reverseClose := reverseBetterA
else if(rreverseBetterB == habOpen)
reverseClose := reverseBetterB
else if(rreverseBetterC == habOpen)
reverseClose := reverseBetterC
else if(rreverseBetterD == habOpen)
reverseClose := reverseBetterD
if(reverseClose < candleLow and volatilityAdjusted)
reverseClose := (candleLow + reverseClose) / 2
if(reverseClose > candleHigh and volatilityAdjusted)
reverseClose := (candleHigh + reverseClose) / 2
reverseClose
//EHLER Smoothers
//Three pole Ehlers Butterworth
_3polebuttfilt(src, len)=>
a1 = 0., b1 = 0., c1 = 0.
coef1 = 0., coef2 = 0., coef3 = 0., coef4 = 0.
bttr = 0., trig = 0.
a1 := math.exp(-math.pi / len)
b1 := 2 * a1 * math.cos(1.738 * math.pi / len)
c1 := a1 * a1
coef2 := b1 + c1
coef3 := -(c1 + b1 * c1)
coef4 := c1 * c1
coef1 := (1 - b1 + c1) * (1 - c1) / 8
bttr := coef1 * (src + 3 * nz(src[1]) + 3 * nz(src[2]) + nz(src[3])) + coef2 * nz(bttr[1]) + coef3 * nz(bttr[2]) + coef4 * nz(bttr[3])
bttr := bar_index < 4 ? src : bttr
trig := nz(bttr[1])
bttr
_ssf3(src, length) =>
arg = math.pi / length
a1 = math.exp(-arg)
b1 = 2 * a1 * math.cos(1.738 * arg)
c1 = math.pow(a1, 2)
coef4 = math.pow(c1, 2)
coef3 = -(c1 + b1 * c1)
coef2 = b1 + c1
coef1 = 1 - coef2 - coef3 - coef4
src1 = nz(src[1], src)
src2 = nz(src[2], src1)
src3 = nz(src[3], src2)
ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1], src1) + coef3 * nz(ssf[2], src2) + coef4 * nz(ssf[3], src3)
//Three pole Ehlers smoother
_3polesss(src, len)=>
a1 = 0., b1 = 0., c1 = 0.
coef1 = 0., coef2 = 0., coef3 = 0., coef4 = 0.
filt = 0., trig = 0.
a1 := math.exp(-math.pi / len)
b1 := 2 * a1 * math.cos(1.738 * math.pi / len)
c1 := a1 * a1
coef2 := b1 + c1
coef3 := -(c1 + b1 * c1)
coef4 := c1 * c1
coef1 := 1 - coef2 - coef3 - coef4
filt := coef1 * src + coef2 * nz(filt[1]) + coef3 * nz(filt[2]) + coef4 * nz(filt[3])
filt := bar_index < 4 ? src : filt
trig := nz(filt[1])
filt
//Two pole Ehlers Butterworth
_2polebutter(src, len)=>
a1 = 0., b1 = 0.
coef1 = 0., coef2 = 0., coef3 = 0.
bttr = 0., trig = 0.
a1 := math.exp(-1.414 * math.pi / len)
b1 := 2 * a1 * math.cos(1.414 * math.pi / len)
coef2 := b1
coef3 := -a1 * a1
coef1 := (1 - b1 + a1 * a1) / 4
bttr := coef1 * (src + 2 * nz(src[1]) + nz(src[2])) + coef2 * nz(bttr[1]) + coef3 * nz(bttr[2])
bttr := bar_index < 3 ? src : bttr
trig := nz(bttr[1])
bttr
//Two pole Ehlers smoother
_2poless(src, len)=>
a1 = 0., b1 = 0.
coef1 = 0., coef2 = 0., coef3 = 0.
filt = 0., trig = 0.
a1 := math.exp(-1.414 * math.pi / len)
b1 := 2 * a1 * math.cos(1.414 * math.pi / len)
coef2 := b1
coef3 := -a1 * a1
coef1 := 1 - coef2 - coef3
filt := coef1 * src + coef2 * nz(filt[1]) + coef3 * nz(filt[2])
filt := bar_index < 3 ? src : filt
trig := nz(filt[1])
filt
//Volatility Pivot Line Smoothing options
f_volatilityMaType (_price, _len, _type) =>
_type == 'Three-pole Ehlers Smoother' ? _3polesss(_price, _len) : _type == "Two-pole Ehlers Butterworth" ? _2polebutter(_price, _len) : _type == "Two-pole Ehlers smoother" ? _2poless(_price, _len) : _type == "Three-pole Ehlers Butterworth" ? _3polebuttfilt(_price, _len) : _ssf3(_price, _len)
//Rounding function to truncate decimal places
f_truncdNum ( Val, DecPl ) =>
Fact = math.pow (10, DecPl)
int( Val * Fact) / Fact
//Smoothing Heikin Ashi
reverseClose = i_heikinAshiMethod == "Heikin Ashi Better Close" ? heikinAshiBetterReverseClose(i_adjustForVolatility) : heikinAshiReverseClose(i_adjustForVolatility)
smaSmoothed = ta.sma(reverseClose, i_smoothingPeriod)
emaSmoothed = ta.ema(reverseClose, i_smoothingPeriod)
hmaSmoothed = ta.hma(reverseClose, i_smoothingPeriod)
vwmaSmoothed = ta.vwma(reverseClose, i_smoothingPeriod)
rmaSmoothed = ta.rma(reverseClose, i_smoothingPeriod)
shouldApplySmoothing = i_useSmooth and i_smoothingPeriod > 1
smoothedReverseClose = reverseClose
if(shouldApplySmoothing)
if(i_smoothingMethod == "SMA")
smoothedReverseClose := smaSmoothed
else if(i_smoothingMethod == "EMA")
smoothedReverseClose := emaSmoothed
else if(i_smoothingMethod == "HMA")
smoothedReverseClose := hmaSmoothed
else if(i_smoothingMethod == "VWMA")
smoothedReverseClose := vwmaSmoothed
else if(i_smoothingMethod == "RMA")
smoothedReverseClose := rmaSmoothed
else
smoothedReverseClose := reverseClose // Default to non-smoothed for invalid smoothing type
//Calculations
haBull = candleClose >= smoothedReverseClose
delta = candleClose - reverseClose
haPivotPrice = reverseClose + delta[1]
haPivotPrice := f_volatilityMaType(haPivotPrice, i_volSmoothingPeriod, i_volPivot_maType)
// Compute Info Label
haDirectionText = haBull ? 'BULLISH Above: ' + '\t\t\t\t\t\t\t\t' : 'BEARISH Below: ' + '\t\t\t\t\t\t\t\t'
haPivotText = (haBull and close > haPivotPrice) ? 'EXPANDING above: ' + '\t\t\t\t': (not(haBull) and close < haPivotPrice) ? 'EXPANDING below: ' + '\t\t\t\t' : (haBull and close <= haPivotPrice) ? 'CONTRACTING below: ' : (not(haBull and close >= haPivotPrice)) ? 'CONTRACTING above: ' : 'Currently equals'
var label Infobox = na
labelXLoc = time_close + ( i_boxOffSet * ( time_close - time_close[1] ) )
infoBoxText = haDirectionText + str.tostring(f_truncdNum(smoothedReverseClose, i_decimalP)) + '\n' + haPivotText + + str.tostring(f_truncdNum(haPivotPrice, i_decimalP))
// InfoBox Plot
if i_infoBox
Infobox := label.new ( labelXLoc, close, infoBoxText, xloc.bar_time, yloc.price, color.new(#00000f, 50), label.style_label_left, color.white )
label.delete ( Infobox[1] )
//Plots
haCol = haBull ? color.green : color.red
plot(smoothedReverseClose, color=haCol, linewidth=2)
plot(i_showVolatilityPivot? haPivotPrice : na, color=color.gray)
|
ORB-PreDay_PerM_Levels | https://www.tradingview.com/script/MVYWa1RC-ORB-PreDay-PerM-Levels/ | sskcharts | https://www.tradingview.com/u/sskcharts/ | 303 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sskcharts
//@version=5
indicator(title='ORB-PreDay_PerM_Levels', shorttitle='ORB-PreDay_PerM_Levels', overlay=true)
//User Input
showORB = input(true, title='Show ORB', inline='1')
showORBExt = input(true, title='Show ORB Extension (Select Ext Below)', inline='1')
showExt1 = input(true, title='', inline='2')
valueExt1 = input.float(161.8, "%", inline='2', options = [127.2, 161.8, 200, 261.8])
showExt2 = input(true, "", inline='2')
valueExt2 = input.float(261.8, "%", inline='2', options = [127.2, 161.8, 200, 261.8])
showExt3 = input(true, "", inline='2')
valueExt3 = input.float(200, "%", inline='2', options = [127.2, 161.8, 200, 261.8])
showPMHL = input(true, title='Show Pre-Market H/L', inline='3')
aftermarket = input(title='Include After-Market', defval=false, inline='3')
showPrevDayHighLow = input(true, title='Show previous day\'s High & Low')
showPrev2DayHighLow = input(false, title='Show previous 2+ days High & Low')
showPrevDayClose = input(true, title='Show previous day\'s Close')
orbTimeFrame = input.timeframe("15", title='ORB timeframe')
sessSpec = input.session('0930-1600', title='Session time')
ORBHColor = input.color(title='ORBH Color', defval=color.new(#0bd68a, 30), inline='10')
ORBLColor = input.color(title='ORBL Color', defval=color.new(#d3396d, 30), inline='10')
PDHColor = input.color(title='PDH Color', defval=color.new(#81c784, 70), inline='11')
PDLColor = input.color(title='PDL Color', defval=color.new(#f06292, 75), inline='11')
PDCColor = input.color(title='PDC Color', defval=color.new(#2196f3, 20), inline='12')
ORBExtColor = input.color(title='ORBExt Color', defval=color.new(#5d606b, 50), inline='13')
PMHLColor = input.color(title='PMHL Color', defval=color.new(#ff9800, 10), inline='14')
plotSignals = input(false, title='Show Buy/Sell Signal', inline='15')
ORBWidth = input.int(title='', defval=1, minval=1, inline='10')
PDHLWidth = input.int(title='', defval=3, minval=1, inline='11')
PDCWidth = input.int(title='', defval=1, minval=1, inline='12')
ORBExtWidth = input.int(title='', defval=2, minval=1, inline='13')
PMHLWidth = input.int(title='', defval=1, minval=1, inline='14')
ORBOption = input.string(title='', options=['solid', 'dotted', 'dashed'], defval='solid', inline='10')
PDHLOption = input.string(title='', options=['solid', 'dotted', 'dashed'], defval='solid', inline='11')
PDCOption = input.string(title='', options=['solid', 'dotted', 'dashed'], defval='dashed', inline='12')
ORBExtOption = input.string(title='', options=['solid', 'dotted', 'dashed'], defval='solid', inline='13')
PMHLOption = input.string(title='', options=['solid', 'dotted', 'dashed'], defval='dashed', inline='14')
ORBStyle = ORBOption == 'dotted' ? line.style_dotted : ORBOption == 'dashed' ? line.style_dashed : line.style_solid
PDHLStyle = PDHLOption == 'dotted' ? line.style_dotted : PDHLOption == 'dashed' ? line.style_dashed : line.style_solid
PDCStyle = PDCOption == 'dotted' ? line.style_dotted : PDCOption == 'dashed' ? line.style_dashed : line.style_solid
ORBExtStyle = ORBExtOption == 'dotted' ? line.style_dotted : ORBExtOption == 'dashed' ? line.style_dashed : line.style_solid
PMHLStyle = PMHLOption == 'dotted' ? line.style_dotted : PMHLOption == 'dashed' ? line.style_dashed : line.style_solid
// Get ORB
t = ticker.new(syminfo.prefix, syminfo.ticker)
getSeries(_e, _timeFrame) =>
request.security(t, _timeFrame, _e, lookahead=barmerge.lookahead_on)
is_newbar(res, sess) =>
t1 = time(res, sess)
na(t1[1]) and not na(t1) or t1[1] < t1
newbar = is_newbar('1440', sessSpec)
var float orbH = na
var float orbL = na
if newbar
orbH := getSeries(high[0], orbTimeFrame)
orbH
orbL := getSeries(low[0], orbTimeFrame)
orbL
// Get ORB Extension
ORWidth = orbH-orbL
orb_ext_up1 = orbH + ORWidth*((valueExt1/100)-1)
orb_ext_down1 = orbL - ORWidth*((valueExt1/100)-1)
orb_ext_up2= orbH + ORWidth*((valueExt2/100)-1)
orb_ext_down2 = orbL - ORWidth*((valueExt2/100)-1)
orb_ext_up3= orbH + ORWidth*((valueExt3/100)-1)
orb_ext_down3 = orbL - ORWidth*((valueExt3/100)-1)
//Previous Days High Low
PrevDayHigh = getSeries(high[1], 'D')
PrevDayLow = getSeries(low[1], 'D')
PrevDayOpen = getSeries(open[1], 'D')
PrevDayClose = getSeries(close[1], 'D')
//Previous 2 Days High Low
PrevDayHigh1 = getSeries(high[2], 'D') > PrevDayHigh ? getSeries(high[2], 'D') : getSeries(high[3], 'D') > PrevDayHigh ? getSeries(high[3], 'D') : na
PrevDayLow1 = getSeries(low[2], 'D') < PrevDayLow ? getSeries(low[2], 'D') : getSeries(low[3], 'D') < PrevDayLow ? getSeries(low[3], 'D') : na
PrevDayHigh2 = PrevDayHigh1 == getSeries(high[2], 'D') ? getSeries(high[3], 'D') > getSeries(high[2], 'D') ? getSeries(high[3], 'D') : getSeries(high[4], 'D') > getSeries(high[3], 'D') ? getSeries(high[4], 'D') : na : na
PrevDayLow2 = PrevDayLow1 == getSeries(low[2], 'D') ? getSeries(low[3], 'D') < getSeries(low[2], 'D') ? getSeries(low[3], 'D') : getSeries(low[4], 'D') < getSeries(low[3], 'D') ? getSeries(low[4], 'D') : na : na
//PM High Low
ending_hour = 9
ending_minute = 30
// LastOnly = input(title="Last only", type=input.bool, defval=false)
pmt = aftermarket == false ? time('1440', '0000-1530:23456') : time('1440', '1600-0000:23456')
is_first = na(pmt[1]) and not na(pmt) or pmt[1] < pmt
pm_high = float(na)
pm_low = float(na)
k = int(na)
if is_first and barstate.isnew and (hour < ending_hour or hour >= 16 or hour == ending_hour and minute < ending_minute)
pm_high := high
pm_low := low
pm_low
else
pm_high := pm_high[1]
pm_low := pm_low[1]
pm_low
if high > pm_high and (hour < ending_hour or hour >= 16 or hour == ending_hour and minute < ending_minute)
pm_high := high
pm_high
if low < pm_low and (hour < ending_hour or hour >= 16 or hour == ending_hour and minute < ending_minute)
pm_low := low
pm_low
// Today's Session Start timestamp
y = year(timenow)
m = month(timenow)
d = dayofmonth(timenow)
d1 = d - 4
// Start & End time for Today
start = timestamp(y, m, d, 09, 00)
pmstart = timestamp(y, m, d, 04, 00)
start1 = timestamp(y, m, d1, 09, 30)
end = start + 86400000
pmend = start + 36000000
daysLeft = 0
_MilliSec_In_Day = 24 * 60 * 60 * 1000
if (60*hour(timenow)+minute(timenow)) < (60*hour(time)+minute(time))
daysLeft := math.floor((timenow - time) / _MilliSec_In_Day)+1
else
daysLeft := math.floor((timenow - time) / _MilliSec_In_Day)
//if daysLeft == 0
// daysLeft := daysLeft+1
orbstart = timestamp(y, m, d, 09, 00)
orbend = orbstart + 25200000
if time < timestamp(y, m, d, 09, 30)
orbstart := timestamp(y, m, d-daysLeft, 09, 00)
orbend := orbstart + 25200000
else
orbstart := timestamp(y, m, d, 09, 00)
orbend := orbstart + 25200000
if time < timestamp(y, m, d, 04, 00)
pmstart := timestamp(y, m, d-daysLeft, 04, 00)
pmend := pmstart + 43200000
else
pmstart := timestamp(y, m, d, 04, 00)
pmend := pmstart + 43200000
// Plot only if session started
isToday = timenow > start
// Plot selected timeframe's High, Low & Avg
// Plot lines
if isToday
if showORB
_h = line.new(orbstart, orbH, orbend, orbH, xloc.bar_time, color=ORBHColor, style=ORBStyle, width=ORBWidth)
line.delete(_h[1])
_l = line.new(orbstart, orbL, orbend, orbL, xloc.bar_time, color=ORBLColor, style=ORBStyle, width=ORBWidth)
line.delete(_l[1])
if showORBExt
if showExt1
_orb_ext_up1 = line.new(orbstart, orb_ext_up1, orbend, orb_ext_up1, xloc.bar_time, color=ORBExtColor, style=ORBExtStyle, width=ORBExtWidth)
line.delete(_orb_ext_up1[1])
_orb_ext_down1 = line.new(orbstart, orb_ext_down1, orbend, orb_ext_down1, xloc.bar_time, color=ORBExtColor, style=ORBExtStyle, width=ORBExtWidth)
line.delete(_orb_ext_down1[1])
if showExt2
_orb_ext_up2 = line.new(orbstart, orb_ext_up2, orbend, orb_ext_up2, xloc.bar_time, color=ORBExtColor, style=ORBExtStyle, width=ORBExtWidth)
line.delete(_orb_ext_up2[1])
_orb_ext_down2 = line.new(orbstart, orb_ext_down2, orbend, orb_ext_down2, xloc.bar_time, color=ORBExtColor, style=ORBExtStyle, width=ORBExtWidth)
line.delete(_orb_ext_down2[1])
if showExt3
_orb_ext_up3 = line.new(orbstart, orb_ext_up3, orbend, orb_ext_up3, xloc.bar_time, color=ORBExtColor, style=ORBExtStyle, width=ORBExtWidth)
line.delete(_orb_ext_up3[1])
_orb_ext_down3 = line.new(orbstart, orb_ext_down3, orbend, orb_ext_down3, xloc.bar_time, color=ORBExtColor, style=ORBExtStyle, width=ORBExtWidth)
line.delete(_orb_ext_down3[1])
if showPrevDayHighLow
_pdh = line.new(start1, PrevDayHigh, end, PrevDayHigh, xloc.bar_time, color=PDHColor, style=PDHLStyle, width=PDHLWidth)
line.delete(_pdh[1])
_pdl = line.new(start1, PrevDayLow, end, PrevDayLow, xloc.bar_time, color=PDLColor, style=PDHLStyle, width=PDHLWidth)
line.delete(_pdl[1])
if showPrevDayClose
_pdc = line.new(orbstart, PrevDayClose, orbend, PrevDayClose, xloc.bar_time, color=PDCColor, style=PDCStyle, width=PDCWidth)
line.delete(_pdc[1])
if showPrev2DayHighLow
_p2dh1 = line.new(start1, PrevDayHigh1, end, PrevDayHigh1, xloc.bar_time, color=PDHColor, style=PDHLStyle, width=PDHLWidth)
line.delete(_p2dh1[1])
if showPrev2DayHighLow
_p2dl1 = line.new(start1, PrevDayLow1, end, PrevDayLow1, xloc.bar_time, color=PDLColor, style=PDHLStyle, width=PDHLWidth)
line.delete(_p2dl1[1])
if showPrev2DayHighLow
_p2dh2 = line.new(start1, PrevDayHigh2, end, PrevDayHigh2, xloc.bar_time, color=PDHColor, style=PDHLStyle, width=PDHLWidth)
line.delete(_p2dh2[1])
if showPrev2DayHighLow
_p2dl2 = line.new(start1, PrevDayLow2, end, PrevDayLow2, xloc.bar_time, color=PDLColor, style=PDHLStyle, width=PDHLWidth)
line.delete(_p2dl2[1])
if timenow > pmstart
if showPMHL
_pmh = line.new(pmstart, pm_high, pmend, pm_high, xloc.bar_time, color=PMHLColor, style=PMHLStyle, width=PMHLWidth)
line.delete(_pmh[1])
_pml = line.new(pmstart, pm_low, pmend, pm_low, xloc.bar_time, color=PMHLColor, style=PMHLStyle, width=PMHLWidth)
line.delete(_pml[1])
// Plot labels
ShowLabel = input(true, title='Show Label')
if isToday and ShowLabel
if showORB
l_h = label.new(orbstart, orbH, text="ORB_H", xloc=xloc.bar_time, textcolor=ORBHColor, style=label.style_none)
label.delete(l_h[1])
l_l = label.new(orbstart, orbL, text="ORB_L", xloc=xloc.bar_time, textcolor=ORBLColor, style=label.style_none)
label.delete(l_l[1])
if showPrevDayHighLow
l_pdh = label.new(start1, PrevDayHigh, text="PDH", xloc=xloc.bar_time, textcolor=PDHColor, style=label.style_none)
label.delete(l_pdh[1])
l_pdl = label.new(start1, PrevDayLow, text="PDL", xloc=xloc.bar_time, textcolor=PDLColor, style=label.style_none)
label.delete(l_pdl[1])
if showPrevDayClose
l_pdc = label.new(start1, PrevDayClose, text="PDC", xloc=xloc.bar_time, textcolor=PDCColor, style=label.style_none)
label.delete(l_pdc[1])
if (timenow > pmstart) and ShowLabel
if showPMHL
l_pmh = label.new(pmstart, pm_high, text="PMH", xloc=xloc.bar_time, textcolor=PMHLColor, style=label.style_none)
label.delete(l_pmh[1])
l_pml = label.new(pmstart, pm_low, text="PML", xloc=xloc.bar_time, textcolor=PMHLColor, style=label.style_none)
label.delete(l_pml[1])
plotshape(plotSignals ? ta.crossover(close, orbH) : na, style=shape.triangleup, location=location.belowbar, color=color.new(color.blue, 0), text='Buy', textcolor=color.new(color.blue, 0))
plotshape(plotSignals ? ta.crossover(orbL, close) : na, style=shape.triangledown, location=location.abovebar, color=color.new(color.blue, 0), text='Sell', textcolor=color.new(color.blue, 0))
|
topsy-turvy tousled candles | https://www.tradingview.com/script/vAF9vt9x-topsy-turvy-tousled-candles/ | fikira | https://www.tradingview.com/u/fikira/ | 41 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fikira
//@version=5
indicator('topsy-turvy tousled candles', 'tttc', overlay=false)
//
// –––––––[ Example ]–––––––
//
//
//
// high -------- hi
// | | |
// | | |
// | | |
// | | |
// -------- close -------- cl
// | | |
// | | |
// | | |
// | | --> |
// | | |
// | | |
// | | | op
// -------- open --------
// | | |
// | | |
// | | |
// | | |
// low -------- lo
float hi = high
float cl = math.max(open, close)
float op = math.min(open, close)
float lo = low
color col = close > open ? #26a69a : #ef5350
plotcandle(hi, hi, op, cl, title='top-middle', color=col, wickcolor=col, bordercolor=col)
plotcandle(lo, op, lo, op, title='bottom' , color=col, wickcolor=col, bordercolor=col)
|
Percents_0,25% | https://www.tradingview.com/script/BTUsySZJ-Percents-0-25/ | jacobfabris | https://www.tradingview.com/u/jacobfabris/ | 27 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jacobfabris
//@version=5
indicator("Percents_0,25%",overlay=true)
pitch = input.float(defval=0.0025,minval=0.0025,maxval=0.0100,step=0.0025)
Nbars = input.int(defval=100,minval=10,maxval=1000,step=1)
sp = request.security(syminfo.tickerid,"D",close)
U(p)=>
a = nz(sp[1])*(1.0+p)
D(p)=>
b = nz(sp[1])*(1.0-p)
plot(U(pitch*1),color=color.lime,show_last=Nbars)
plot(U(pitch*2),color=color.lime,show_last=Nbars)
plot(U(pitch*3),color=color.lime,show_last=Nbars)
plot(U(pitch*4),color=color.lime,show_last=Nbars)
plot(U(pitch*5),color=color.lime,show_last=Nbars)
plot(U(pitch*6),color=color.lime,show_last=Nbars)
plot(U(pitch*7),color=color.lime,show_last=Nbars)
plot(U(pitch*8),color=color.lime,show_last=Nbars)
//---
plot(sp,color=color.gray,show_last=Nbars)
//---
plot(D(pitch*1),color=color.orange,show_last=Nbars)
plot(D(pitch*2),color=color.orange,show_last=Nbars)
plot(D(pitch*3),color=color.orange,show_last=Nbars)
plot(D(pitch*4),color=color.orange,show_last=Nbars)
plot(D(pitch*5),color=color.orange,show_last=Nbars)
plot(D(pitch*6),color=color.orange,show_last=Nbars)
plot(D(pitch*7),color=color.orange,show_last=Nbars)
plot(D(pitch*8),color=color.orange,show_last=Nbars)
//---
P1 = input(defval=8)
P2 = input(defval=34)
P3 = input(defval=144)
plot(ta.ema(close,P1),color=color.silver,show_last=Nbars,linewidth=2)
plot(ta.ema(close,P2),color=color.yellow,show_last=Nbars,linewidth=2)
plot(ta.ema(close,P3),color=color.red,show_last=Nbars,linewidth=2)
|
world stage index ver02 | https://www.tradingview.com/script/4pooJ9GQ/ | trader_aaa111 | https://www.tradingview.com/u/trader_aaa111/ | 27 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kattsu
//@version=5
indicator('world stage index', overlay=false)
//40symbols
//"TVC:SHCOMP" is revised to "SSE:000001"
s1 = request.security('OSE:NK2251!', '', close)
s2 = request.security('DJ:DJI', '', close)
s3 = request.security('NASDAQ:IXIC', '', close)
s4 = request.security('SP:SPX', '', close)
s5 = request.security('XETR:DAX', '', close)
s6 = request.security('TVC:CAC40', '', close)
s7 = request.security('TVC:UKX', '', close)
s8 = request.security('TSX:TSX', '', close)
s9 = request.security('SSE:000001', '', close)
s10 = request.security('SZSE:399001', '', close)
s11 = request.security('TVC:HSI', '', close)
s12 = request.security('TWSE:TAIEX', '', close)
s13 = request.security('BSE:SENSEX', '', close)
s14 = request.security('OANDA:SG30SGD', '', close)
s15 = request.security('INDEX:KSI', '', close)
s16 = request.security('SET:SET', '', close)
s17 = request.security('INDEX:SX5E', '', close)
s18 = request.security('INDEX:FTSEMIB', '', close)
s19 = request.security('SIX:SMI', '', close)
s20 = request.security('BME:IBC', '', close)
s21 = request.security('EURONEXT:BEL20', '', close)
s22 = request.security('TVC:AEX', '', close)
s23 = request.security('OMXCOP:OMXC25', '', close)
s24 = request.security('ATHEX:GD', '', close)
s25 = request.security('ASX:XJO', '', close)
s26 = request.security('TVC:NZ50G', '', close)
s27 = request.security('IDX:COMPOSITE', '', close)
s28 = request.security('FTSEMYX:FBMKLCI', '', close)
s29 = request.security('BMFBOVESPA:IBOV', '', close)
s30 = request.security('BMV:ME', '', close)
s31 = request.security('BVL:SPBLPGPT', '', close)
s32 = request.security('BYMA:IMV', '', close)
s33 = request.security('MOEX:IMOEX', '', close)
s34 = request.security('GPW:WIG20', '', close)
s35 = request.security('OMXHEX:OMXH25', '', close)
s36 = request.security('OMXSTO:OMXS30', '', close)
s37 = request.security('DFM:DFMGI', '', close)
s38 = request.security('TADAWUL:TASI', '', close)
s39 = request.security('QSE:GNRI', '', close)
s40 = request.security('EGX:EGX30', '', close)
//ema5,20,40 of each symbols
As1 = ta.ema(s1, 5)
Bs1 = ta.ema(s1, 20)
Cs1 = ta.ema(s1, 40)
As2 = ta.ema(s2, 5)
Bs2 = ta.ema(s2, 20)
Cs2 = ta.ema(s2, 40)
As3 = ta.ema(s3, 5)
Bs3 = ta.ema(s3, 20)
Cs3 = ta.ema(s3, 40)
As4 = ta.ema(s4, 5)
Bs4 = ta.ema(s4, 20)
Cs4 = ta.ema(s4, 40)
As5 = ta.ema(s5, 5)
Bs5 = ta.ema(s5, 20)
Cs5 = ta.ema(s5, 40)
As6 = ta.ema(s6, 5)
Bs6 = ta.ema(s6, 20)
Cs6 = ta.ema(s6, 40)
As7 = ta.ema(s7, 5)
Bs7 = ta.ema(s7, 20)
Cs7 = ta.ema(s7, 40)
As8 = ta.ema(s8, 5)
Bs8 = ta.ema(s8, 20)
Cs8 = ta.ema(s8, 40)
As9 = ta.ema(s9, 5)
Bs9 = ta.ema(s9, 20)
Cs9 = ta.ema(s9, 40)
As10 = ta.ema(s10, 5)
Bs10 = ta.ema(s10, 20)
Cs10 = ta.ema(s10, 40)
As11 = ta.ema(s11, 5)
Bs11 = ta.ema(s11, 20)
Cs11 = ta.ema(s11, 40)
As12 = ta.ema(s12, 5)
Bs12 = ta.ema(s12, 20)
Cs12 = ta.ema(s12, 40)
As13 = ta.ema(s13, 5)
Bs13 = ta.ema(s13, 20)
Cs13 = ta.ema(s13, 40)
As14 = ta.ema(s14, 5)
Bs14 = ta.ema(s14, 20)
Cs14 = ta.ema(s14, 40)
As15 = ta.ema(s15, 5)
Bs15 = ta.ema(s15, 20)
Cs15 = ta.ema(s15, 40)
As16 = ta.ema(s16, 5)
Bs16 = ta.ema(s16, 20)
Cs16 = ta.ema(s16, 40)
As17 = ta.ema(s17, 5)
Bs17 = ta.ema(s17, 20)
Cs17 = ta.ema(s17, 40)
As18 = ta.ema(s18, 5)
Bs18 = ta.ema(s18, 20)
Cs18 = ta.ema(s18, 40)
As19 = ta.ema(s19, 5)
Bs19 = ta.ema(s19, 20)
Cs19 = ta.ema(s19, 40)
As20 = ta.ema(s20, 5)
Bs20 = ta.ema(s20, 20)
Cs20 = ta.ema(s20, 40)
As21 = ta.ema(s21, 5)
Bs21 = ta.ema(s21, 20)
Cs21 = ta.ema(s21, 40)
As22 = ta.ema(s22, 5)
Bs22 = ta.ema(s22, 20)
Cs22 = ta.ema(s22, 40)
As23 = ta.ema(s23, 5)
Bs23 = ta.ema(s23, 20)
Cs23 = ta.ema(s23, 40)
As24 = ta.ema(s24, 5)
Bs24 = ta.ema(s24, 20)
Cs24 = ta.ema(s24, 40)
As25 = ta.ema(s25, 5)
Bs25 = ta.ema(s25, 20)
Cs25 = ta.ema(s25, 40)
As26 = ta.ema(s26, 5)
Bs26 = ta.ema(s26, 20)
Cs26 = ta.ema(s26, 40)
As27 = ta.ema(s27, 5)
Bs27 = ta.ema(s27, 20)
Cs27 = ta.ema(s27, 40)
As28 = ta.ema(s28, 5)
Bs28 = ta.ema(s28, 20)
Cs28 = ta.ema(s28, 40)
As29 = ta.ema(s29, 5)
Bs29 = ta.ema(s29, 20)
Cs29 = ta.ema(s29, 40)
As30 = ta.ema(s30, 5)
Bs30 = ta.ema(s30, 20)
Cs30 = ta.ema(s30, 40)
As31 = ta.ema(s31, 5)
Bs31 = ta.ema(s31, 20)
Cs31 = ta.ema(s31, 40)
As32 = ta.ema(s32, 5)
Bs32 = ta.ema(s32, 20)
Cs32 = ta.ema(s32, 40)
As33 = ta.ema(s33, 5)
Bs33 = ta.ema(s33, 20)
Cs33 = ta.ema(s33, 40)
As34 = ta.ema(s34, 5)
Bs34 = ta.ema(s34, 20)
Cs34 = ta.ema(s34, 40)
As35 = ta.ema(s35, 5)
Bs35 = ta.ema(s35, 20)
Cs35 = ta.ema(s35, 40)
As36 = ta.ema(s36, 5)
Bs36 = ta.ema(s36, 20)
Cs36 = ta.ema(s36, 40)
As37 = ta.ema(s37, 5)
Bs37 = ta.ema(s37, 20)
Cs37 = ta.ema(s37, 40)
As38 = ta.ema(s38, 5)
Bs38 = ta.ema(s38, 20)
Cs38 = ta.ema(s38, 40)
As39 = ta.ema(s39, 5)
Bs39 = ta.ema(s39, 20)
Cs39 = ta.ema(s39, 40)
As40 = ta.ema(s40, 5)
Bs40 = ta.ema(s40, 20)
Cs40 = ta.ema(s40, 40)
//criteria of stage 1
//A=ema05, B=ema20 , C=ema40
Sone(A, B, C) =>
if A >= B and B >= C
1
else
0
//criteria of stage 4
//A=ema05, B=ema20 , C=ema40
Sfour(A, B, C) =>
if C >= B and B >= A
1
else
0
//Assign each symbols to a function
Sone1 = Sone(As1, Bs1, Cs1)
Sone2 = Sone(As2, Bs2, Cs2)
Sone3 = Sone(As3, Bs3, Cs3)
Sone4 = Sone(As4, Bs4, Cs4)
Sone5 = Sone(As5, Bs5, Cs5)
Sone6 = Sone(As6, Bs6, Cs6)
Sone7 = Sone(As7, Bs7, Cs7)
Sone8 = Sone(As8, Bs8, Cs8)
Sone9 = Sone(As9, Bs9, Cs9)
Sone10 = Sone(As10, Bs10, Cs10)
Sone11 = Sone(As11, Bs11, Cs11)
Sone12 = Sone(As12, Bs12, Cs12)
Sone13 = Sone(As13, Bs13, Cs13)
Sone14 = Sone(As14, Bs14, Cs14)
Sone15 = Sone(As15, Bs15, Cs15)
Sone16 = Sone(As16, Bs16, Cs16)
Sone17 = Sone(As17, Bs17, Cs17)
Sone18 = Sone(As18, Bs18, Cs18)
Sone19 = Sone(As19, Bs19, Cs19)
Sone20 = Sone(As20, Bs20, Cs20)
Sone21 = Sone(As21, Bs21, Cs21)
Sone22 = Sone(As22, Bs22, Cs22)
Sone23 = Sone(As23, Bs23, Cs23)
Sone24 = Sone(As24, Bs24, Cs24)
Sone25 = Sone(As25, Bs25, Cs25)
Sone26 = Sone(As26, Bs26, Cs26)
Sone27 = Sone(As27, Bs27, Cs27)
Sone28 = Sone(As28, Bs28, Cs28)
Sone29 = Sone(As29, Bs29, Cs29)
Sone30 = Sone(As30, Bs30, Cs30)
Sone31 = Sone(As31, Bs31, Cs31)
Sone32 = Sone(As32, Bs32, Cs32)
Sone33 = Sone(As33, Bs33, Cs33)
Sone34 = Sone(As34, Bs34, Cs34)
Sone35 = Sone(As35, Bs35, Cs35)
Sone36 = Sone(As36, Bs36, Cs36)
Sone37 = Sone(As37, Bs37, Cs37)
Sone38 = Sone(As38, Bs38, Cs38)
Sone39 = Sone(As39, Bs39, Cs39)
Sone40 = Sone(As40, Bs40, Cs40)
Sfour1 = Sfour(As1, Bs1, Cs1)
Sfour2 = Sfour(As2, Bs2, Cs2)
Sfour3 = Sfour(As3, Bs3, Cs3)
Sfour4 = Sfour(As4, Bs4, Cs4)
Sfour5 = Sfour(As5, Bs5, Cs5)
Sfour6 = Sfour(As6, Bs6, Cs6)
Sfour7 = Sfour(As7, Bs7, Cs7)
Sfour8 = Sfour(As8, Bs8, Cs8)
Sfour9 = Sfour(As9, Bs9, Cs9)
Sfour10 = Sfour(As10, Bs10, Cs10)
Sfour11 = Sfour(As11, Bs11, Cs11)
Sfour12 = Sfour(As12, Bs12, Cs12)
Sfour13 = Sfour(As13, Bs13, Cs13)
Sfour14 = Sfour(As14, Bs14, Cs14)
Sfour15 = Sfour(As15, Bs15, Cs15)
Sfour16 = Sfour(As16, Bs16, Cs16)
Sfour17 = Sfour(As17, Bs17, Cs17)
Sfour18 = Sfour(As18, Bs18, Cs18)
Sfour19 = Sfour(As19, Bs19, Cs19)
Sfour20 = Sfour(As20, Bs20, Cs20)
Sfour21 = Sfour(As21, Bs21, Cs21)
Sfour22 = Sfour(As22, Bs22, Cs22)
Sfour23 = Sfour(As23, Bs23, Cs23)
Sfour24 = Sfour(As24, Bs24, Cs24)
Sfour25 = Sfour(As25, Bs25, Cs25)
Sfour26 = Sfour(As26, Bs26, Cs26)
Sfour27 = Sfour(As27, Bs27, Cs27)
Sfour28 = Sfour(As28, Bs28, Cs28)
Sfour29 = Sfour(As29, Bs29, Cs29)
Sfour30 = Sfour(As30, Bs30, Cs30)
Sfour31 = Sfour(As31, Bs31, Cs31)
Sfour32 = Sfour(As32, Bs32, Cs32)
Sfour33 = Sfour(As33, Bs33, Cs33)
Sfour34 = Sfour(As34, Bs34, Cs34)
Sfour35 = Sfour(As35, Bs35, Cs35)
Sfour36 = Sfour(As36, Bs36, Cs36)
Sfour37 = Sfour(As37, Bs37, Cs37)
Sfour38 = Sfour(As38, Bs38, Cs38)
Sfour39 = Sfour(As39, Bs39, Cs39)
Sfour40 = Sfour(As40, Bs40, Cs40)
//Sum of stage1
//divided by 0.4
//to displey from 0to 100
ST1 = Sone1 + Sone2 + Sone3 + Sone4 + Sone5 + Sone6 + Sone7 + Sone8 + Sone9 + Sone10 + Sone11 + Sone12 + Sone13 + Sone14 + Sone15 + Sone16 + Sone17 + Sone18 + Sone19 + Sone20 + Sone21 + Sone22 + Sone23 + Sone24 + Sone25 + Sone26 + Sone27 + Sone28 + Sone29 + Sone30 + Sone31 + Sone32 + Sone33 + Sone34 + Sone35 + Sone36 + Sone37 + Sone38 + Sone39 + Sone40
plot(ST1 / 0.4, color=#ffd70050, style=plot.style_area)
//Sum of stage4
//divided by 0.4
//to displey from 0to 100
ST4 = Sfour1 + Sfour2 + Sfour3 + Sfour4 + Sfour5 + Sfour6 + Sfour7 + Sfour8 + Sfour9 + Sfour10 + Sfour11 + Sfour12 + Sfour13 + Sfour14 + Sfour15 + Sfour16 + Sfour17 + Sfour18 + Sfour19 + Sfour20 + Sfour21 + Sfour22 + Sfour23 + Sfour24 + Sfour25 + Sfour26 + Sfour27 + Sfour28 + Sfour29 + Sfour30 + Sfour31 + Sfour32 + Sfour33 + Sfour34 + Sfour35 + Sfour36 + Sfour37 + Sfour38 + Sfour39 + Sfour40
plot(ST4 / 0.4, color=#1e90ff50, style=plot.style_area)
//R=ratio of stage1/4
//2.5times to displey from 0 to 100
//Because R is almost between 0 and 40
R = ST1 / ST4 * 2.5
plot(R, color=color.new(color.red, 20), style=plot.style_line, linewidth=2)
//center line
hline(50, title='50', color=color.black, linestyle=hline.style_solid, linewidth=2, editable=true)
//80% and 20% line
hline(80, title='50', color=color.green, linestyle=hline.style_solid, linewidth=1, editable=true)
hline(20, title='50', color=color.green, linestyle=hline.style_solid, linewidth=1, editable=true)
//ずらっと40個並べないで、ループ化したコードにしたい。今後の勉強課題。
|
Wick Pressure by SiddWolf | https://www.tradingview.com/script/w2sPsVff-Wick-Pressure-by-SiddWolf/ | SiddWolf | https://www.tradingview.com/u/SiddWolf/ | 897 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SiddWolf
//@version=5
indicator(title="Wick Pressure by SiddWolf", shorttitle="WP [SiddWolf]", overlay=true)
mee_rsi = ta.rsi(close, 14)
atr_mult = input.float(title="ATR Multiplier",defval=0.7, step=0.1, minval=0.4, maxval=2.0, tooltip="The Wick area is filtered on the basis of atr and this is multiplier to that ATR. The more the multiplier value, the less the signals and vice versa")
box_length = input.int(title="Box Length",defval=16, step=2, minval=4, maxval=100, tooltip="Length of Wick Pressure Box")
rsi_ob = input.int(title="RSI OverBought",defval=60, step=5, minval=50, maxval=90, inline="rsi_settings", tooltip="RSI based on which signnals are filtered")
rsi_os = input.int(title="RSI OverSold",defval=40, step=5, minval=10, maxval=50, inline="rsi_settings")
bull_color = input(defval=#00FF0021, title="Bullish Pressure", inline="box_color")
bear_color = input(defval=#FF000021, title="Bearish Pressure", inline="box_color")
//bullish wick pressure
rsi_bullish_cond = mee_rsi < rsi_os or mee_rsi[1] < rsi_os or mee_rsi[2] < rsi_os
ll3 = ta.lowest(low, 3)
lc3 = math.min(ta.lowest(close, 3), ta.lowest(open, 3))
sidd_bull_cond = low<=lc3 and low[1]<=lc3 and low[2]<=lc3 and open>=lc3 and open[1]>=lc3 and open[2]>=lc3 and lc3-ll3>(atr_mult*ta.atr(14)) and rsi_bullish_cond and close>open
if sidd_bull_cond
box.new(bar_index, lc3, bar_index+box_length, ll3, bgcolor=bull_color, border_color=color.green)
plotshape(sidd_bull_cond, style = shape.triangleup, color = color.green, location = location.belowbar, size = size.small)
//bearish wick pressure
rsi_bearish_cond = mee_rsi > rsi_ob or mee_rsi[1] > rsi_ob or mee_rsi[2] > rsi_ob
hh3 = ta.highest(high, 3)
hc3 = math.max(ta.highest(close, 3), ta.highest(open, 3))
sidd_bear_cond = high>=hc3 and high[1]>=hc3 and high[2]>=hc3 and open<=hc3 and open[1]<=hc3 and open[2]<=hc3 and hh3-hc3>(atr_mult*ta.atr(14)) and rsi_bearish_cond and close<open
if sidd_bear_cond
box.new(bar_index, hh3, bar_index+box_length, hc3, bgcolor=bear_color, border_color=color.red)
plotshape(sidd_bear_cond, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.small)
|
Zigzag Matrix | https://www.tradingview.com/script/0DSiPGjP-Zigzag-Matrix/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 623 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
// __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
// / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
// $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
// $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
// $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
// $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
// $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
// $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
// $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
//
//
//
//@version=5
indicator("Zigzag Matrix", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=500)
import HeWhoMustNotBeNamed/mZigzag/3 as zigzag
import HeWhoMustNotBeNamed/enhanced_ta/14 as eta
length = input.int(8, 'Length', group='Zigzag', tooltip='Zigzag Length')
supertrendLength = input.int(5, 'Zupertrend Length', group='Zigzag', tooltip='Number of past pivots to calculate zigzag supertrend')
showIndicators = input.bool(false, 'Show Indicators', group='Zigzag', inline='b')
showSupertrend = input.bool(false, 'Show Supertrend', group='Zigzag', inline='b')
useClosePrices = input.bool(false, 'Use Close Prices', group='Zigzag', inline='b', tooltip='Show Indicators - Display Indicator values along with pivots.\n\n'+
'Show Supertrend - Show supertrend derived from zigzag. This trend is also used for calculating divergence.\n\n'+
'Use Close Prices - Use close prices for calculating pivots instead of high/low. This also means indicator values are calculated on close instead of high/low')
includeMa = input.bool(true, 'Moving Average', group="Indicators", inline='ma')
matype = input.string("sma", title="", group="Indicators", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "median"], inline="ma")
malength = input.int(60, title="", group="Indicators", inline="ma", tooltip='Moving Average Type and Length')
includeOscillator = input.bool(true, "Oscillator ", inline="osc", group="Indicators")
oscillatorType = input.string("rsi", title="", group="Indicators", inline="osc", options=["cci", "cmo", "cog", "mfi", "roc", "rsi"])
oscLength = input.int(14, title="", group="Indicators", inline="osc", tooltip='Oscillator Type and Length')
includeVolume = input.bool(true, "Volume ", inline="vol", group="Indicators")
volType = input.string("obv", title="", group="Indicators", inline="vol", options=["obv", "pvi", "nvi", "pvt", "vwap"], tooltip='Volume Indicator Type')
showStats = input.bool(true, 'Show Stats Table', group='Stats', inline='s')
tblPosition = input.string(position.top_right, '', group='Stats', options=[position.top_right, position.bottom_right, position.top_left, position.bottom_left], inline='s')
textSize = input.string(size.small, '', group='Stats', options=[size.tiny, size.small, size.normal, size.large, size.huge], inline='s', tooltip='Option to display pivot details in stats table')
indicatorHigh = array.new_float()
indicatorLow = array.new_float()
indicatorLabels = array.new_string()
getSentimentDetails(sentiment) =>
sentimentSymbol = sentiment == 4 ? '⬆' :
sentiment == -4 ? '⬇' :
sentiment == 3 ? '↗' :
sentiment == -3 ? '↘' :
sentiment == 2 ? '⤴' :
sentiment == -2 ? '⤵' :
sentiment == 1 ? '⤒' :
sentiment == -1 ? '⤓' : '▣'
sentimentColor = sentiment == 4 ? color.green :
sentiment == -4 ? color.red :
sentiment == 3 ? color.lime :
sentiment == -3 ? color.orange :
sentiment == 2 ? color.rgb(202, 224, 13, 0) :
sentiment == -2 ? color.rgb(250, 128, 114, 0) :
sentiment == 1? color.lime:
sentiment == -1? color.orange: color.silver
sentimentLabel = math.abs(sentiment) == 4 ? 'C' : math.abs(sentiment) == 3 ? 'H' : math.abs(sentiment) == 2 ? 'D' : 'I'
[sentimentSymbol, sentimentLabel, sentimentColor]
getDirectionDetails(directionMatrix, i, j)=>
value = matrix.get(directionMatrix,i,j)
direction = value == 2? "⇈" :
value == 1? "↑" :
value == -1? "↓" :
value == -2? "⇊" : "⬍"
directionColor = value == 2? color.green:
value == 1? color.orange:
value == -1? color.lime:
value == -2? color.red: color.silver
[direction, directionColor]
highSource = useClosePrices? close : high
lowSource = useClosePrices? close : low
if(includeMa)
maHigh = eta.ma(highSource, matype, malength)
maLow = eta.ma(lowSource, matype, malength)
array.push(indicatorHigh, maHigh)
array.push(indicatorLow, maLow)
array.push(indicatorLabels, str.upper(matype+str.tostring(malength)))
if(includeOscillator)
[oscHigh, _, _] = eta.oscillator(oscillatorType, oscLength, oscLength, oscLength, highSource)
[oscLow, _, _] = eta.oscillator(oscillatorType, oscLength, oscLength, oscLength, lowSource)
array.push(indicatorHigh, oscHigh)
array.push(indicatorLow, oscLow)
array.push(indicatorLabels, str.upper(oscillatorType+str.tostring(oscLength)))
if(includeVolume)
volHigh = volType == "obv"? ta.obv:
volType == "pvi"? ta.pvi:
volType == "nvi"? ta.nvi:
volType == "pvt"? ta.pvt: ta.vwap(highSource)
volLow = volType == "obv"? ta.obv:
volType == "pvi"? ta.pvi:
volType == "nvi"? ta.nvi:
volType == "pvt"? ta.pvt: ta.vwap(lowSource)
array.push(indicatorHigh, volHigh)
array.push(indicatorLow, volLow)
array.push(indicatorLabels, str.upper(volType))
ohlc = array.from(highSource, lowSource)
[valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, supertrendDir, supertrend, newZG, doubleZG] =
zigzag.calculate(length, ohlc, indicatorHigh, indicatorLow, supertrendLength = supertrendLength)
zigzag.draw(valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, newZG, doubleZG, indicatorLabels, showIndicators=showIndicators)
var lastD = 0
lastD := array.size(barArray)>=2? array.get(barArray, 1) : lastD
plot(showSupertrend? supertrend:na, color=supertrendDir>0? color.green:color.red, style=plot.style_linebr)
if(lastD > lastD[1])
alert('New pivot Alert')
if(barstate.islast and showStats)
numberOfSubColumns = 4
stats = table.new(tblPosition, (matrix.columns(valueMatrix)+1)*numberOfSubColumns, matrix.rows(valueMatrix)+2, border_color=color.black, border_width=2)
rows = matrix.rows(valueMatrix)
columns = matrix.columns(valueMatrix)
headers = array.from('DISTANCE', 'PRICE')
array.concat(headers, indicatorLabels)
for [index, lbl] in headers
table.cell(stats, index*numberOfSubColumns, 0, lbl, text_color=color.white, text_size=textSize, bgcolor=color.maroon)
if(index!=0)
table.merge_cells(stats, index*numberOfSubColumns, 0, (index+1)*numberOfSubColumns-(index==1? 2 : 1), 0)
for i=0 to rows-1
table.cell(stats, 0, rows-i, str.tostring(bar_index-array.get(barArray, i)), text_color=color.black, text_size=textSize, bgcolor=color.aqua)
for j=0 to columns-1
[direction, directionColor] = getDirectionDetails(directionMatrix, i, j)
table.cell(stats, numberOfSubColumns+(j*numberOfSubColumns), rows-i, str.tostring(math.round_to_mintick(matrix.get(valueMatrix, i, j))), text_color=color.black, text_size=textSize, bgcolor=color.new(directionColor, 20), tooltip='Value')
table.cell(stats, numberOfSubColumns+(j*numberOfSubColumns)+1, rows-i, direction, text_color=color.black, text_size=textSize, bgcolor=color.new(directionColor, 20), tooltip='Direction')
if(j==0)
table.cell(stats, numberOfSubColumns+(j*numberOfSubColumns)+2, rows-i, str.tostring(math.round(matrix.get(ratioMatrix, i, j), 3)), text_color=color.black, text_size=textSize, bgcolor=color.new(directionColor, 20), tooltip='Retracement')
else
divergence = matrix.get(divergenceMatrix, i, j)
doubleDivergence = matrix.get(doubleDivergenceMatrix, i, j)
[dSymbol, dLabel, dColor] = getSentimentDetails(divergence)
[ddSymbol, ddLabel, ddColor] = getSentimentDetails(doubleDivergence)
table.cell(stats, numberOfSubColumns+(j*numberOfSubColumns)+2, rows-i, dSymbol, text_color=color.black, text_size=textSize, bgcolor=color.new(dColor, 20), tooltip='Divergence')
table.cell(stats, numberOfSubColumns+(j*numberOfSubColumns)+3, rows-i, ddSymbol, text_color=color.black, text_size=textSize, bgcolor=color.new(ddColor, 20), tooltip='Double Divergence') |
Korea Premium | https://www.tradingview.com/script/RfeJXc2c-Korea-Premium/ | dokang | https://www.tradingview.com/u/dokang/ | 247 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dokang
//@version=5
// ________________________________________________
// | |
// | --------------------------------- |
// | | Developed by JangDoKang | |
// | --------------------------------- |
// |_______________________________________________|
indicator("Korea Premium", overlay = true)
usdkrw = request.security("FX_IDC:USDKRW", timeframe.period, close)
isShowPrice = input.bool(true, "Show Price")
isSimple = input.bool(false, "Simple Mode")
isKorean = input.bool(false, "한국어")
isFuture = input.bool(false, "Future")
title = isKorean ? isSimple ? "김프" : "김치프리미엄" : isSimple ? "PREMIUM" : "KOREA PREMIUM"
col0 = isKorean ? "코인" : "COIN"
col1 = isKorean ? "업비트" : "UPBIT"
col2 = isKorean ? "바이낸스" : "BINANCE"
col3 = isKorean ? "김프" : "PREMIUM"
binance_price_array = array.new<float>()
upbit_price_array = array.new<float>()
kimp_array = array.new<float>()
var base = syminfo.basecurrency
get_kimp(a, b) =>
100*(a-b)/b
var id_array = array.from("BTC","ETH","XRP","ADA","DOGE","MATIC","SOL","TRX","DOT","SHIB")
var findIndex = array.indexof(id_array, base)
UPBIT_BTC_PRICE = request.security("UPBIT:BTCKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_BTC_PRICE)
BINANCE_BTC_PRICE = request.security(isFuture ? "BINANCE:BTCUSDTPERP" : "BINANCE:BTCUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_BTC_PRICE)
BTC_KIMP = get_kimp(UPBIT_BTC_PRICE, BINANCE_BTC_PRICE)
array.push(kimp_array, BTC_KIMP)
UPBIT_ETH_PRICE = request.security("UPBIT:ETHKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_ETH_PRICE)
BINANCE_ETH_PRICE = request.security(isFuture ? "BINANCE:ETHUSDTPERP" : "BINANCE:ETHUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_ETH_PRICE)
ETH_KIMP = get_kimp(UPBIT_ETH_PRICE, BINANCE_ETH_PRICE)
array.push(kimp_array, ETH_KIMP)
UPBIT_XRP_PRICE = request.security("UPBIT:XRPKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_XRP_PRICE)
BINANCE_XRP_PRICE = request.security(isFuture ? "BINANCE:XRPUSDTPERP" : "BINANCE:XRPUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_XRP_PRICE)
XRP_KIMP = get_kimp(UPBIT_XRP_PRICE, BINANCE_XRP_PRICE)
array.push(kimp_array, XRP_KIMP)
UPBIT_ADA_PRICE = request.security("UPBIT:ADAKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_ADA_PRICE)
BINANCE_ADA_PRICE = request.security(isFuture ? "BINANCE:ADAUSDTPERP" : "BINANCE:ADAUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_ADA_PRICE)
ADA_KIMP = get_kimp(UPBIT_ADA_PRICE, BINANCE_ADA_PRICE)
array.push(kimp_array, ADA_KIMP)
UPBIT_DOGE_PRICE = request.security("UPBIT:DOGEKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_DOGE_PRICE)
BINANCE_DOGE_PRICE = request.security(isFuture ? "BINANCE:DOGEUSDTPERP" : "BINANCE:DOGEUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_DOGE_PRICE)
DOGE_KIMP = get_kimp(UPBIT_DOGE_PRICE, BINANCE_DOGE_PRICE)
array.push(kimp_array, DOGE_KIMP)
UPBIT_MATIC_PRICE = request.security("UPBIT:MATICKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_MATIC_PRICE)
BINANCE_MATIC_PRICE = request.security(isFuture ? "BINANCE:MATICUSDTPERP" : "BINANCE:MATICUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_MATIC_PRICE)
MATIC_KIMP = get_kimp(UPBIT_MATIC_PRICE, BINANCE_MATIC_PRICE)
array.push(kimp_array, MATIC_KIMP)
UPBIT_SOL_PRICE = request.security("UPBIT:SOLKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_SOL_PRICE)
BINANCE_SOL_PRICE = request.security(isFuture ? "BINANCE:SOLUSDTPERP" : "BINANCE:SOLUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_SOL_PRICE)
SOL_KIMP = get_kimp(UPBIT_SOL_PRICE, BINANCE_SOL_PRICE)
array.push(kimp_array, SOL_KIMP)
UPBIT_TRX_PRICE = request.security("UPBIT:TRXKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_TRX_PRICE)
BINANCE_TRX_PRICE = request.security(isFuture ? "BINANCE:TRXUSDTPERP" : "BINANCE:TRXUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_TRX_PRICE)
TRX_KIMP = get_kimp(UPBIT_TRX_PRICE, BINANCE_TRX_PRICE)
array.push(kimp_array, TRX_KIMP)
UPBIT_DOT_PRICE = request.security("UPBIT:DOTKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_DOT_PRICE)
BINANCE_DOT_PRICE = request.security(isFuture ? "BINANCE:DOTUSDTPERP" : "BINANCE:DOTUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_DOT_PRICE)
DOT_KIMP = get_kimp(UPBIT_DOT_PRICE, BINANCE_DOT_PRICE)
array.push(kimp_array, DOT_KIMP)
UPBIT_SHIB_PRICE = request.security("UPBIT:SHIBKRW", timeframe.period, close)
array.push(upbit_price_array, UPBIT_SHIB_PRICE)
BINANCE_SHIB_PRICE = request.security(isFuture ? "BINANCE:SHIBUSDTPERP" : "BINANCE:SHIBUSDT", timeframe.period, close) * usdkrw
array.push(binance_price_array, BINANCE_SHIB_PRICE)
SHIB_KIMP = get_kimp(UPBIT_SHIB_PRICE, BINANCE_SHIB_PRICE)
array.push(kimp_array, SHIB_KIMP)
backgroundColor = #112D4E
cellColor = #F9F7F7
titleColor = #FF2E63
borderColor = #3F72AF
column_size = isSimple ? 1 : isShowPrice ? 4 : 2
row_size = 30
title_tooltip = "Developed by JangDoKang"
var myTable = table.new(position = position.top_right, columns = column_size, rows = row_size, border_width = 2, border_color = borderColor , frame_color= borderColor, frame_width = 2, bgcolor = backgroundColor)
if barstate.isfirst
if not isSimple
table.cell(myTable, 0, 0, text = title, bgcolor = titleColor, text_color = cellColor, tooltip=title_tooltip)
if isShowPrice
table.merge_cells(myTable, 0, 0, column_size -1, 0)
table.cell(myTable, column = 0, row = 1, text=col0, text_color=cellColor)
table.cell(myTable, column = 1, row = 1, text=col1, text_color=cellColor)
table.cell(myTable, column = 2, row = 1, text=col2, text_color=cellColor)
table.cell(myTable, column = 3, row = 1, text=col3, text_color=cellColor)
else
table.merge_cells(myTable, 0, 0, column_size -1, 0)
table.cell(myTable, column = 0, row = 1, text=col0, text_color=cellColor)
table.cell(myTable, column = 1, row = 1, text=col3, text_color=cellColor)
else
table.cell(myTable, 0, 0, text = col3, bgcolor = titleColor, text_color = cellColor, tooltip=title_tooltip)
if barstate.islast
if not isSimple
if isShowPrice
for i = 0 to array.size(id_array)-1
id = array.get(id_array, i)
upbit_price = array.get(upbit_price_array, i)
binance_price = array.get(binance_price_array, i)
kimp = array.get(kimp_array, i)
table.cell(myTable, column = 0, row = i+2, text = id, text_color=cellColor, bgcolor = findIndex == i ? color.purple : na)
table.cell(myTable, column = 1, row = i+2, text = str.tostring(upbit_price, "#.##"), text_color = cellColor, bgcolor = findIndex == i ? color.purple : na)
table.cell(myTable, column = 2, row = i+2, text = str.tostring(binance_price, "#"), text_color = cellColor, bgcolor = findIndex == i ? color.purple : na)
table.cell(myTable, column = 3, row = i+2, text = str.tostring(kimp, "#.##") + "%", text_color = kimp > 4 ? color.green : kimp > 2 ? color.yellow : kimp> 0 ? color.white : color.red , bgcolor = findIndex == i ? color.purple : na)
else
for i = 0 to array.size(id_array)-1
id = array.get(id_array, i)
upbit_price = array.get(upbit_price_array, i)
binance_price = array.get(binance_price_array, i)
kimp = array.get(kimp_array, i)
table.cell(myTable, column = 0, row = i+2, text = id, text_color=cellColor, bgcolor = findIndex == i ? color.purple : na)
table.cell(myTable, column = 1, row = i+2, text = str.tostring(kimp, "#.##") + "%", text_color = kimp > 4 ? color.green : kimp > 2 ? color.yellow : kimp> 0 ? color.white : color.red , bgcolor = findIndex == i ? color.purple : na)
else
table.cell(myTable, column = 0, row = 1, text = str.tostring(BTC_KIMP, "#.##")+"%", text_color = BTC_KIMP > 4 ? color.green : BTC_KIMP> 2 ? color.yellow : BTC_KIMP> 0 ? color.white : color.red, width=4) |
Distance from Vwap | https://www.tradingview.com/script/0Zbpftno-Distance-from-Vwap/ | TradingWolf | https://www.tradingview.com/u/TradingWolf/ | 214 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MensaTrader
//@version=5
indicator("Distance from Vwap", overlay=false, timeframe="", timeframe_gaps=false)
//Titles
vwapTitle = "=== VWAP Settings ==="
plots = "=== Plots ==="
tool = "Distance to lookback and compare relative values with"
//Inputs
vwapRes = input.timeframe("W", title="VWAP Resolution", group=vwapTitle)
threshold = input.int(3, title="Distance Threshold", group=vwapTitle, tooltip=tool)*100
bullColor = input.color(#00E600, title="Bull", group=plots, inline="1")
bearColor = input.color(#FF0000, title="Bear", group=plots, inline="1")
//Calculations
v = ta.vwap
vwap = request.security(syminfo.tickerid, vwapRes, v, barmerge.gaps_off)
distance = (close>vwap ? (close-vwap)/close : (vwap-close)/vwap) * 100
recentH = ta.highest(distance, threshold)
recentL = ta.lowest(distance, threshold)
c = distance>=recentH ? close>vwap ? bearColor : bullColor : distance <= recentL ? color.orange : color.gray
//Plot
plot(distance, style=plot.style_histogram, color=c, title="VWAP Distance")
|
PercentagefromEMA | https://www.tradingview.com/script/2nNpNTDi-PercentagefromEMA/ | CRYPTOHHH | https://www.tradingview.com/u/CRYPTOHHH/ | 96 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CRYPTOHHH
//@version=5
indicator(title="PercentagefromEMA", shorttitle="PercentagefromEMA", overlay=true, timeframe="5", timeframe_gaps=true)
len = input.int(200,title="EMA - length", defval=0, minval=1, maxval=333)
src = close
perc1 = input.int(4,title="percentage-1", defval=0, minval=1, maxval=100)
perc2 = input.int(5,title="percentage-2", defval=0, minval=1, maxval=100)
perc3 = input.int(6,title="percentage-3", defval=0, minval=1, maxval=100)
perc4 = input.int(7,title="percentage-4", defval=0, minval=1, maxval=100)
out = ta.ema(src, len)
plot(out, title="EMA", color=color.red)
emaplusperc1= out+(out*(perc1/100))
emaplusperc2= out+(out*(perc2/100))
emaplusperc3= out+(out*(perc3/100))
emaplusperc4= out+(out*(perc4/100))
emaminusperc1= out-(out*(perc1/100))
emaminusperc2= out-(out*(perc2/100))
emaminusperc3= out-(out*(perc3/100))
emaminusperc4= out-(out*(perc4/100))
pp1 = plot(emaplusperc1, "Upper1", color=#ff0606)
pp2 = plot(emaplusperc2, "Upper2", color=#ff0606)
pp3 = plot(emaplusperc3, "Upper3", color=#ff0606)
pp4 = plot(emaplusperc4, "Upper4", color=#ff0606)
pm1 = plot(emaminusperc1, "Lower1", color=#00ff00)
pm2 = plot(emaminusperc2, "Lower2", color=#00ff00)
pm3 = plot(emaminusperc3, "Lower3", color=#00ff00)
pm4 = plot(emaminusperc4, "Lower4", color=#00ff00) |
Volume Profile Premium | https://www.tradingview.com/script/ZVtvdIFT-Volume-Profile-Premium/ | dandrideng | https://www.tradingview.com/u/dandrideng/ | 1,476 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dandrideng
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
//# *
//# * Study : Volume Profile Premium
//# * Author : © dandri deng
//# *
//# * Revision History
//# * Release : Jun. 03, 2022 First release of Volume Profile Premium indicator
//# * Update : Sep. 11, 2022 Fix the bugs of real time volume-profile updates
//# * Update : Dec. 30, 2022 Fix the bugs of collecting wrong history data in replay mode
//# *
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//@version=5
indicator("Volume Profile Premium", shorttitle="VP-Premium", overlay=true, max_bars_back=500, max_lines_count=500, max_labels_count=500, max_boxes_count=500)
// ---------------------------------------------------------------------------------------------- //
// Functions ----------------------------------------------------------------------------------- //
print(string txt) =>
var table t = table.new(position.middle_right, 1, 1)
table.cell(t, 0, 0, txt, bgcolor = color.yellow)
// ---------------------------------------------------------------------------------------------- //
// volume profile ------------------------------------------------------------------------------ //
group_volume_profile = "Volume Profile Parameters"
max_lbk = input.int(defval=100, title="max of lookback forward", minval=1, maxval=1200, step=1, group=group_volume_profile)
lower_reso = input.int(defval=5, title="lower resolution (Minute)", minval=1, maxval=300, step=1, group=group_volume_profile)
display = input.string(defval="Buy/Sell", title="display volume profile", options=["Buy/Sell", "Total"], group=group_volume_profile)
num_rows = input.int(defval=30, title="rows of volume profile", minval=5, maxval=150, step=1, group=group_volume_profile)
placement = input.string(defval="Right", title="placement of volume profile", options=["Left", "Right"], group=group_volume_profile)
width = input.int(defval=75, title="width of volume profile", minval=5, maxval=300, step=1, group=group_volume_profile)
offset = input.int(defval=5, title="horizontal offset", minval=5, maxval=300, step=1, group=group_volume_profile)
realtime = input.bool(defval=false, title="Enable realtime volum-profile mode", tooltip="do not use realtime mode in replay mode!", group=group_volume_profile)
if timeframe.multiplier % lower_reso != 0
runtime.error("The multiplier of current timeframe (" + str.tostring(timeframe.multiplier) + ") can not be divided by that of the lower timeframe (" + str.tostring(lower_reso) + ")")
//stage one: request bars from lower time frame
[open_sec, high_sec, low_sec, close_sec, vol_sec] = request.security_lower_tf(syminfo.tickerid, str.tostring(lower_reso), [open, high, low, close, volume])
request_size = array.size(open_sec)
var open_arr_var = array.new_float(0)
var high_arr_var = array.new_float(0)
var low_arr_var = array.new_float(0)
var close_arr_var = array.new_float(0)
var vol_arr_var = array.new_float(0)
array.concat(open_arr_var, open_sec)
array.concat(high_arr_var, high_sec)
array.concat(low_arr_var, low_sec)
array.concat(close_arr_var, close_sec)
array.concat(vol_arr_var, vol_sec)
//stage two: volume accumulation in the specific price region
open_arr = array.new_float(0)
high_arr = array.new_float(0)
low_arr = array.new_float(0)
close_arr = array.new_float(0)
vol_arr = array.new_float(0)
slice_size = request_size[1] * (max_lbk - 1) + request_size
var_array_size = array.size(open_arr_var)
if var_array_size > slice_size
open_arr := array.slice(open_arr_var, var_array_size - slice_size - 1, var_array_size - 1)
high_arr := array.slice(high_arr_var, var_array_size - slice_size - 1, var_array_size - 1)
low_arr := array.slice(low_arr_var, var_array_size - slice_size - 1, var_array_size - 1)
close_arr := array.slice(close_arr_var, var_array_size - slice_size - 1, var_array_size - 1)
vol_arr := array.slice(vol_arr_var, var_array_size - slice_size - 1, var_array_size - 1)
if realtime
array.push(open_arr, open)
array.push(high_arr, high)
array.push(low_arr, low)
array.push(close_arr, close)
array.push(vol_arr, volume)
price_region = array.new_float(0)
array.concat(price_region, high_arr)
array.concat(price_region, low_arr)
array.sort(price_region, order.descending)
price_region_size = array.size(price_region)
buy_volume = array.new_float(math.max(price_region_size, 1) - 1, 0)
sell_volume = array.new_float(math.max(price_region_size, 1) - 1, 0)
price_array_size = array.size(open_arr)
if price_array_size > 0
for i = 0 to price_array_size - 1
o = array.get(open_arr, i)
h = array.get(high_arr, i)
l = array.get(low_arr, i)
c = array.get(close_arr, i)
v = array.get(vol_arr, i)
h_idx = array.indexof(price_region, h)
l_idx = array.lastindexof(price_region, l)
for j = h_idx to l_idx - 1
l_rgn = array.get(price_region, j)
r_rgn = array.get(price_region, j + 1)
if c > o
array.set(buy_volume, j, array.get(buy_volume, j) + (l_rgn - r_rgn) / (h - l) * v)
else
array.set(sell_volume, j, array.get(sell_volume, j) + (l_rgn - r_rgn) / (h - l) * v)
//stage three: discretization processing
buy_profile = array.new_float(num_rows, 0)
sell_profile = array.new_float(num_rows, 0)
highest = ta.highest(high, max_lbk)
lowest = ta.lowest(low, max_lbk)
interval = (highest - lowest) / num_rows
if price_region_size > 1
for i = 0 to price_region_size - 2
h = array.get(price_region, i)
l = array.get(price_region, i + 1)
bv = array.get(buy_volume, i)
sv = array.get(sell_volume, i)
r_min = int((highest - h) / interval)
r_max = int((highest - l) / interval)
if r_min <= r_max
for r = r_min to r_max
if r >= 0 and r <= num_rows - 1
r1 = highest - r * interval
r2 = highest - (r + 1) * interval
up = math.min(r1, h)
dn = math.max(r2, l)
if up > dn
array.set(buy_profile, r, array.get(buy_profile, r) + (up - dn) * bv / (h - l))
array.set(sell_profile, r, array.get(sell_profile, r) + (up - dn) * sv / (h - l))
total_profile = array.new_float(num_rows, 0)
for r = 0 to num_rows - 1
array.set(total_profile, r, array.get(buy_profile, r) + array.get(sell_profile, r))
max_profile = array.max(total_profile)
buy_bar = array.new_int(num_rows, 0)
sell_bar = array.new_int(num_rows, 0)
for r = 0 to num_rows - 1
array.set(buy_bar, r, int(array.get(buy_profile, r) / max_profile * width))
array.set(sell_bar, r, int(array.get(sell_profile, r) / max_profile * width))
// ---------------------------------------------------------------------------------------------- //
// display settings ----------------------------------------------------------------------------- //
group_display_settings = "Display Settings"
color_hl_line = input.color(defval=color.new(#5d606b, 95), title="lookback region color, lines/region", inline="AA", group=group_display_settings)
color_hl_region = input.color(defval=color.new(#5d606b, 95), title="", inline="AA", group=group_display_settings)
color_buy_profile = input.color(defval=color.new(#1592e6, 30), title="profile color, buys/sells/total", inline="BB", group=group_display_settings)
color_sell_profile = input.color(defval=color.new(#fbc123, 30), title="", inline="BB", group=group_display_settings)
color_total_profile = input.color(defval=color.new(#1592e6, 30), title="", inline="BB", group=group_display_settings)
color_bull_profile = input.color(defval=color.new(#26a69a, 30), title="difference color, bull/bear", inline="CC", group=group_display_settings)
color_bear_profile = input.color(defval=color.new(#ef5350, 30), title="", inline="CC", group=group_display_settings)
var line highest_line = na
var line lowest_line = na
line.delete(highest_line)
line.delete(lowest_line)
if placement == "Right"
highest_line := line.new(x1=bar_index - max_lbk, y1=highest, x2=bar_index + width + offset, y2=highest, width=2, color=color_hl_line)
lowest_line := line.new(x1=bar_index - max_lbk, y1=lowest, x2=bar_index + width + offset, y2=lowest, width=2, color=color_hl_line)
else
highest_line := line.new(x1=bar_index - max_lbk, y1=highest, x2=bar_index, y2=highest, width=2, color=color_hl_line)
lowest_line := line.new(x1=bar_index - max_lbk, y1=lowest, x2=bar_index, y2=lowest, width=2, color=color_hl_line)
linefill.new(highest_line, lowest_line, color_hl_region)
all_boxes = box.all
if array.size(all_boxes) > 0
for i = 0 to array.size(all_boxes) - 1
box.delete(array.get(all_boxes, i))
left = 0
right = 0
for r = 0 to num_rows - 1
top = highest - r * interval
bottom = highest - (r + 1) * interval
top := top - interval * 0.15
bottom := bottom + interval * 0.15
diff_bar = array.get(buy_bar, r) - array.get(sell_bar, r)
if display == "Buy/Sell"
if placement == "Right"
left := array.get(buy_bar, r) - (width + offset)
right := -(width + offset)
else
left := max_lbk
right := left - array.get(buy_bar, r)
lbx = box.new(left=bar_index - left, top=top, right=bar_index - right, bottom=bottom)
box.set_bgcolor(lbx, color_buy_profile)
box.set_border_color(lbx, color_buy_profile)
if placement == "Right"
right := left
left := left + array.get(sell_bar, r)
else
left := right
right := left - array.get(sell_bar, r)
sbx = box.new(left=bar_index - left, top=top, right=bar_index - right, bottom=bottom)
box.set_bgcolor(sbx, color_sell_profile)
box.set_border_color(sbx, color_sell_profile)
else
if placement == "Right"
left := array.get(buy_bar, r) + array.get(sell_bar, r) - (width + offset)
right := -(width + offset)
else
left := max_lbk
right := left - diff_bar
tbx = box.new(left=bar_index - left, top=top, right=bar_index - right, bottom=bottom)
box.set_bgcolor(tbx, color_total_profile)
box.set_border_color(tbx, color_total_profile)
if placement == "Right"
left := -(width + offset + 1)
right := -(math.abs(diff_bar) + width + offset + 1)
else
left := max_lbk + 1 + math.abs(diff_bar)
right := max_lbk + 1
clr = diff_bar > 0 ? color_bull_profile : diff_bar < 0 ? color_bear_profile : na
dbx = box.new(left=bar_index - left, top=top, right=bar_index - right, bottom=bottom)
box.set_bgcolor(dbx, clr)
box.set_border_color(dbx, clr)
// ---------------------------------------------------------------------------------------------- //
// end of file ---------------------------------------------------------------------------------- //
|
Key Levels | https://www.tradingview.com/script/dleePUDm-Key-Levels/ | TradingWolf | https://www.tradingview.com/u/TradingWolf/ | 306 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MensaTrader
//@version=5
indicator('Key Levels', overlay=true)
//Titles
plot = "=== Plots ==="
//Inputs
plotDaily = input.bool(true, title=' Daily Levels........', group=plot, inline="1")
plotWeekly = input.bool(true, title=' Weekly Levels.... ', group=plot, inline="2")
plotMonthly = input.bool(true, title=' Monthly Levels... ', group=plot, inline="3")
showDVwap = input.bool(true, title=' Vwaps', group=plot, inline="1")
showWVwap = input.bool(true, title=' Vwaps', group=plot, inline="2")
showMVwap = input.bool(true, title=' Vwaps', group=plot, inline="3")
plotBack = input.int(15, title='Plot bars back', group=plot)
//Vwap
v = ta.vwap(close)
av = ta.vwap(hlc3)
//Monthly Vwap
mv = request.security(syminfo.tickerid, 'M', v[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
mav = request.security(syminfo.tickerid, 'M', av[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//Weekly Vwap
wv = request.security(syminfo.tickerid, 'W', v[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
wav = request.security(syminfo.tickerid, 'W', av[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//Daily Vwap
dv = request.security(syminfo.tickerid, 'D', v[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
dav = request.security(syminfo.tickerid, 'D', av[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//Monthly Levels
monthly = request.security(syminfo.tickerid, 'M', close[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
monthlyHigh = request.security(syminfo.tickerid, 'M', high[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
monthlyLow = request.security(syminfo.tickerid, 'M', low[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
monthlyOpen = request.security(syminfo.tickerid, 'M', open[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//Weekly Levels
weekly = request.security(syminfo.tickerid, 'W', close[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
weeklyHigh = request.security(syminfo.tickerid, 'W', high[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
weeklyLow = request.security(syminfo.tickerid, 'W', low[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
weeklyOpen = request.security(syminfo.tickerid, 'W', open[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//Daily Levels
daily = request.security(syminfo.tickerid, 'D', close[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
dailyHigh = request.security(syminfo.tickerid, 'D', high[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
dailyLow = request.security(syminfo.tickerid, 'D', low[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
dailyOpen = request.security(syminfo.tickerid, 'D', open[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
//Colours
dailyC = input.color(color.new(color.teal, 0), title='Daily Levels', group='=== Colors ===')
weeklyC = input.color(color.new(color.yellow, 0), title='Weekly Levels', group='=== Colors ===')
monthlyC = input.color(color.new(color.purple, 0), title='Monthly Levels', group='=== Colors ===')
//Key levels
m = monthly
mH = monthlyHigh
mL = monthlyLow
mO = monthlyOpen
var mPlot = m
var mHPlot = m
var mLPlot = m
var mOPlot = m
newMonth = ta.change(m)
if newMonth
mPlot := m
mHPlot := mH
mLPlot := mL
mOPlot := mO
mOPlot
//Plot
plot(plotMonthly ? monthly : na, title='Monthly Close', color=monthlyC, show_last=plotBack)
plot(plotMonthly ? monthlyHigh : na, title='Monthly High', color=monthlyC, show_last=plotBack)
plot(plotMonthly ? monthlyLow : na, title='Monthly Low', color=monthlyC, show_last=plotBack)
plot(plotMonthly ? monthlyOpen : na, title='Monthly Open', color=monthlyC, show_last=plotBack)
plot(plotWeekly ? weekly : na, title='Weekly Close', color=weeklyC, show_last=plotBack)
plot(plotWeekly ? weeklyHigh : na, title='Weekly High', color=weeklyC, show_last=plotBack)
plot(plotWeekly ? weeklyLow : na, title='Weekly Low', color=weeklyC, show_last=plotBack)
plot(plotWeekly ? weeklyOpen : na, title='Weekly Open', color=weeklyC, show_last=plotBack)
plot(plotDaily ? daily : na, title='Daily Close', color=dailyC, show_last=plotBack)
plot(plotDaily ? dailyHigh : na, title='Daily High', color=dailyC, show_last=plotBack)
plot(plotDaily ? dailyLow : na, title='Daily Low', color=dailyC, show_last=plotBack)
plot(plotDaily ? dailyOpen : na, title='Daily Open', color=dailyC, show_last=plotBack)
//Vwap Plots
plot(showMVwap ? mv : na, title='Monthly Vwap', color=monthlyC, show_last=plotBack)
plot(showMVwap ? mav : na, title='Monthly Anchored Vwap', color=monthlyC, show_last=plotBack)
plot(showWVwap ? wv : na, title='Weekly Vwap', color=weeklyC, show_last=plotBack)
plot(showWVwap ? wav : na, title='Weekly Anchored Vwap', color=weeklyC, show_last=plotBack)
plot(showDVwap ? dv : na, title='Daily Vwap', color=dailyC, show_last=plotBack)
plot(showDVwap ? dav : na, title='Daily Anchored Vwap', color=dailyC, show_last=plotBack)
//Labels
textStyle = label.style_none
m1 = label.new(plotMonthly ? bar_index : na, monthly, text='Monthly', style=textStyle)
m2 = label.new(plotMonthly ? bar_index : na, monthlyHigh, text='Monthly High', style=textStyle)
m3 = label.new(plotMonthly ? bar_index : na, monthlyLow, text='Monthly Low', style=textStyle)
m4 = label.new(plotMonthly ? bar_index : na, monthlyOpen, text='Monthly Open', style=textStyle)
//Weekly Labels
w1 = label.new(plotWeekly ? bar_index : na, weekly, text='Weekly', style=textStyle)
w2 = label.new(plotWeekly ? bar_index : na, weeklyHigh, text='Weekly High', style=textStyle)
w3 = label.new(plotWeekly ? bar_index : na, weeklyLow, text='Weekly Low', style=textStyle)
w4 = label.new(plotWeekly ? bar_index : na, weeklyOpen, text='Weekly Open', style=textStyle)
//Daily Labels
d1 = plotDaily ? label.new(plotDaily ? bar_index : na, daily, text='Daily', style=textStyle) : na
d2 = plotDaily ? label.new(plotDaily ? bar_index : na, dailyHigh, text='Daily High', style=textStyle) : na
d3 = plotDaily ? label.new(plotDaily ? bar_index : na, dailyLow, text='Daily Low', style=textStyle) : na
d4 = plotDaily ? label.new(plotDaily ? bar_index : na, dailyOpen, text='Daily Open', style=textStyle) : na
//Vwap Labels
m11 = label.new(showMVwap ? bar_index : na, mv, text='Monthly Vwap', style=textStyle)
m22 = label.new(showMVwap ? bar_index : na, mav, text='Monthly Awap', style=textStyle)
w11 = label.new(showWVwap ? bar_index : na, wv, text='Weekly Vwap', style=textStyle)
w22 = label.new(showWVwap ? bar_index : na, wav, text='Weekly Awap', style=textStyle)
d11 = label.new(showDVwap ? bar_index : na, dv, text='Daily Vwap', style=textStyle)
d22 = label.new(showDVwap ? bar_index : na, dav, text='Daily Awap', style=textStyle)
//Delete Labels
label.delete(m1[1])
label.delete(m2[1])
label.delete(m3[1])
label.delete(m4[1])
label.delete(w1[1])
label.delete(w2[1])
label.delete(w3[1])
label.delete(w4[1])
label.delete(d1[1])
label.delete(d2[1])
label.delete(d3[1])
label.delete(d4[1])
//Delete Vwap Labels
label.delete(m11[1])
label.delete(m22[1])
label.delete(w11[1])
label.delete(w22[1])
label.delete(d11[1])
label.delete(d22[1])
|
MTF previous high and low quarter levels | https://www.tradingview.com/script/6dziDMD4-MTF-previous-high-and-low-quarter-levels/ | geneclash | https://www.tradingview.com/u/geneclash/ | 94 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © geneclash
//
// Acknowledgement:
//
// @HeWhoMustNotBeNamed - Previous High/Low MTF
// https://www.tradingview.com/script/DNqSoMlx-Previous-High-Low-MTF/
//
//@version=5
indicator('MTF previous high and low quarter levels', overlay=true, max_lines_count=500, max_labels_count=500)
tf1 = input.timeframe(defval='D', title='Timeframe for High/Low')
showhist = input(defval=false, title='Show Historical Lines')
showlabel = input(defval=false, title='Show Price Labels')
linestyle2 = input.string(defval='Solid', options=['Solid', 'Dotted', 'Dashed'], group='Lines')
linestyle1 = linestyle2 == 'Solid' ? line.style_solid : linestyle2 == 'Dotted' ? line.style_dotted : line.style_dashed
lwidth = input.int(defval=1, minval=1, maxval=4, title='Line Width', group='Lines')
color1 = input.color(defval=color.orange, title='Color (Lines & Labels)', group='Lines')
hhigh = request.security(syminfo.ticker, tf1, high[1], lookahead=barmerge.lookahead_on)
hlow = request.security(syminfo.ticker, tf1, low[1], lookahead=barmerge.lookahead_on)
hbar = request.security(syminfo.ticker, tf1, barstate.islast)
// hline(42500, color = color.white)
// plot(hhigh,color = hhigh==hhigh[1] and showhist ? color.green : color.new(color.green,100))
// plot(hlow,color = hlow==hlow[1] and showhist ? color.red : color.new(color.red,100))
range1 = (hhigh - hlow) / 4
zerolevel = hlow
var line highline = na
var line lowline = na
// var label highlabel = na
// var label lowlabel = na
var lines = array.new_line()
var labels = array.new_label()
var label highlabel = label.new(bar_index + 1, hhigh, style=label.style_none, text=str.tostring(hhigh), textcolor=color1)
var label lowlabel = label.new(bar_index + 1, hlow, style=label.style_none, text=str.tostring(hlow), textcolor=color1)
if hhigh != hhigh[1] or hlow != hlow[1]
if not showhist
line.delete(highline)
line.delete(lowline)
label.delete(highlabel)
label.delete(lowlabel)
highline := line.new(bar_index, hhigh, bar_index + 1, hhigh, color=color1, style=linestyle1, width=lwidth)
lowline := line.new(bar_index, hlow, bar_index + 1, hlow, color=color1, style=linestyle1, width=lwidth)
if showlabel
highlabel := label.new(bar_index + 1, hhigh, style=label.style_none, text=str.tostring(hhigh), textcolor=color1)
lowlabel := label.new(bar_index + 1, hlow, style=label.style_none, text=str.tostring(hlow), textcolor=color1)
label.set_y(highlabel, hhigh)
label.set_y(lowlabel, hlow)
label.set_text(highlabel, str.tostring(hhigh) + '-(1.0)')
label.set_text(lowlabel, str.tostring(hlow) + '-(0.0)')
label.set_x(highlabel, bar_index + 2)
label.set_x(lowlabel, bar_index + 2)
line.set_x2(highline, bar_index + 1)
line.set_x2(lowline, bar_index + 1)
if not showlabel
label.delete(highlabel)
label.delete(lowlabel)
if hhigh != hhigh[1] or hlow != hlow[1]
if not showhist and array.size(lines) > 0
for i = 0 to array.size(lines) - 1 by 1
line.delete(array.get(lines, i))
label.delete(array.get(labels, i))
array.clear(lines)
array.clear(labels)
for i = 1 to 10 by 1
shigh = zerolevel + i * range1
slow = zerolevel - i * range1
// line.delete(lowline)
if i != 4
array.push(lines, line.new(bar_index, shigh, bar_index + 1, shigh, color=color1, style=linestyle1, width=lwidth))
array.push(labels, label.new(bar_index, shigh, text=str.tostring(shigh), textcolor=showlabel ? color1 : color.new(color1, 100), style=label.style_none))
array.push(lines, line.new(bar_index, slow, bar_index + 1, slow, color=color1, style=linestyle1, width=lwidth))
array.push(labels, label.new(bar_index, slow, text=str.tostring(slow), textcolor=showlabel ? color1 : color.new(color1, 100), style=label.style_none))
// label.set_y(highlabel,hhigh)
// label.set_y(lowlabel,hlow)
// label.set_text(highlabel,tostring(hhigh) + "(1)")
// label.set_text(lowlabel,tostring(hlow) + "(0)")
// label.set_x(highlabel,bar_index+2)
// label.set_x(lowlabel,bar_index+2)
if array.size(lines) > 0
for i = 0 to array.size(lines) - 1 by 1
line.set_x2(array.get(lines, i), bar_index + 1)
label.set_x(array.get(labels, i), bar_index + 2)
// if array.size(labels)>0 and not showlabel
// for i = 0 to (array.size(labels)-1)
// label.delete(array.get(labels,i))
// array.clear(labels)
// label.new(bar_index,high,text = tostring(array.size(lines)))
// line.set_x2(highline,bar_index+1)
// line.set_x2(lowline,bar_index+1)
// if not showlabel
// label.delete(highlabel)
// label.delete(lowlabel)
|
Syminfo [Epi] | https://www.tradingview.com/script/lFLNYWjd-Syminfo-Epi/ | Epi_ | https://www.tradingview.com/u/Epi_/ | 14 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Epi_
//@version=5
indicator("Syminfo [Epi]","Syminfo",true)
//=== Inputs ===
var color ctransp=color.new(color.white,100)
syminfo_label_offset=input.int(10,"Label offset horizontal")
syminfo_label_center=input.int(10,"Label centered around prices of last x bars",minval=1,maxval=5000)
syminfo_label_ctext=input.color(color.black,"Color text, background",inline="Color")
syminfo_label_cback=input.color(ctransp,"",inline="Color")
syminfo_label_style=input.string(label.style_label_left,"Label style, size",options=[label.style_label_left,label.style_label_right,label.style_label_center,label.style_label_up,label.style_label_down,label.style_label_lower_left,label.style_label_lower_right,label.style_label_upper_left,label.style_label_upper_right,label.style_none],inline="Label")
// Other styles (not useful with texts): label.style_square,label.style_diamond,label.style_flag,label.style_cross,label.style_xcross,label.style_triangleup,label.style_triangledown,label.style_circle,label.style_arrowup,label.style_arrowdown
syminfo_label_size=input.string(size.small,"",options=[size.auto,size.tiny,size.small,size.normal,size.large,size.huge],inline="Label")
//=== Calculations ===
var string syminfo_text="Description: "+syminfo.description+(na(syminfo.description)?"(na)":"")+
"\nType: "+syminfo.type+(na(syminfo.type)?"(na)":"")+
"\nTickerId: "+syminfo.tickerid+(na(syminfo.tickerid)?"(na)":"")+
"\nPrefix: "+syminfo.prefix+(na(syminfo.prefix)?"(na)":"")+
"\nTicker: "+syminfo.ticker+(na(syminfo.ticker)?"(na)":"")+
"\nRoot: "+syminfo.root+(na(syminfo.root)?"(na)":"")+
"\nCurrency: "+syminfo.currency+(na(syminfo.currency)?"(na)":"")+
"\nBase currency: "+syminfo.basecurrency+(na(syminfo.basecurrency)?"(na)":"")+
"\nMinTick: "+str.tostring(syminfo.mintick)+(na(syminfo.mintick)?"(na)":"")+
"\nPoint value: "+str.tostring(syminfo.pointvalue)+(na(syminfo.pointvalue)?"(na)":"")+
"\nSession: "+syminfo.session+(na(syminfo.session)?"(na)":"")+
"\nTimezone: "+syminfo.timezone+(na(syminfo.timezone)?"(na)":"")+
"\nVolume type: "+syminfo.volumetype+(na(syminfo.volumetype)?"(na)":"")+
"\nSector: "+syminfo.sector+(na(syminfo.sector)?"(na)":"")+
"\nIndustry: "+syminfo.industry+(na(syminfo.industry)?"(na)":"")+
"\nCountry of listing: "+syminfo.country+(na(syminfo.country)?"(na)":"")
var label syminfo_label=na
syminfo_label_pos=ta.sma(close,syminfo_label_center)
//=== Outputs ===
if barstate.islast
if na(syminfo_label)
syminfo_label:=label.new(bar_index+syminfo_label_offset,syminfo_label_pos,syminfo_text,xloc.bar_index,yloc.price,syminfo_label_cback,syminfo_label_style,syminfo_label_ctext,syminfo_label_size,text.align_left,"Syminfo values of the ticker")
else
label.set_xy(syminfo_label,bar_index+syminfo_label_offset,syminfo_label_pos)
na
|
PClose Levels 2.0 | https://www.tradingview.com/script/AVkxumQP-PClose-Levels-2-0/ | TheWaysian | https://www.tradingview.com/u/TheWaysian/ | 26 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © financialCode47408
//@version=5
indicator("PClose Levels 2.0", overlay=true)
f_newLine(_color) => line.new(na, na, na, na, xloc.bar_time, extend.both, _color)
f_moveLine(_line, _x, _y) =>
line.set_xy1(_line, _x, _y)
line.set_xy2(_line, _x+1, _y)
var line line_close = f_newLine(color.blue)
var line line_emrpos = f_newLine(color.green)
var line line_erpos = f_newLine(color.green)
var line line_pos2 = f_newLine(color.green)
var line line_pos1 = f_newLine(color.green)
var line line_em = f_newLine(color.white)
var line line_neg1 = f_newLine(color.red)
var line line_neg2 = f_newLine(color.red)
var line line_erneg = f_newLine(color.red)
var line line_emrneg = f_newLine(color.red)
[pdc,pdt] = request.security(syminfo.tickerid,"D", [close[1],time[1]])
VIX = request.security("VIX", "1", close)
PCLOSE = request.security("SPX", "D", close[1])
if VIX <18.71
if barstate.islast
f_moveLine(line_close, pdt, PCLOSE)
f_moveLine(line_emrpos, pdt, PCLOSE*1.0067)
f_moveLine(line_erpos, pdt, PCLOSE*1.0042)
f_moveLine(line_pos2, pdt, PCLOSE*1.0034)
f_moveLine(line_pos1, pdt, PCLOSE*1.0018)
f_moveLine(line_em, pdt, PCLOSE*1.0016)
f_moveLine(line_neg1, pdt, PCLOSE*-.0010+PCLOSE)
f_moveLine(line_neg2, pdt, PCLOSE*-.0027+PCLOSE)
f_moveLine(line_erneg, pdt, PCLOSE*-.0013+PCLOSE)
f_moveLine(line_emrneg, pdt, PCLOSE*-.0051+PCLOSE)
if VIX >18.71 and VIX <22.38
if barstate.islast
f_moveLine(line_close, pdt, PCLOSE)
f_moveLine(line_emrpos, pdt, PCLOSE*1.0105)
f_moveLine(line_erpos, pdt, PCLOSE*1.0082)
f_moveLine(line_pos2, pdt, PCLOSE*1.0082)
f_moveLine(line_pos1, pdt, PCLOSE*1.0031)
f_moveLine(line_em, pdt, PCLOSE*1.0008)
f_moveLine(line_neg1, pdt, PCLOSE*-.0016+PCLOSE)
f_moveLine(line_neg2, pdt, PCLOSE*-.0045+PCLOSE)
f_moveLine(line_erneg, pdt, PCLOSE*-.0042+PCLOSE)
f_moveLine(line_emrneg, pdt, PCLOSE*-.0087+PCLOSE)
if VIX >22.38 and VIX <26.41
if barstate.islast
f_moveLine(line_close, pdt, PCLOSE)
f_moveLine(line_emrpos, pdt, PCLOSE*1.0161)
f_moveLine(line_erpos, pdt, PCLOSE*1.0105)
f_moveLine(line_pos2, pdt, PCLOSE*1.0109)
f_moveLine(line_pos1, pdt, PCLOSE*1.0042)
f_moveLine(line_em, pdt, PCLOSE*-.0004+PCLOSE)
f_moveLine(line_neg1, pdt, PCLOSE*-.0042+PCLOSE)
f_moveLine(line_neg2, pdt, PCLOSE*-.0084+PCLOSE)
f_moveLine(line_erneg, pdt, PCLOSE*-.0086+PCLOSE)
f_moveLine(line_emrneg, pdt, PCLOSE*-.0166+PCLOSE)
if VIX >26.41
if barstate.islast
f_moveLine(line_close, pdt, PCLOSE)
f_moveLine(line_emrpos, pdt, PCLOSE*1.0197)
f_moveLine(line_erpos, pdt, PCLOSE*1.0114)
f_moveLine(line_pos2, pdt, PCLOSE*1.0142)
f_moveLine(line_pos1, pdt, PCLOSE*1.0054)
f_moveLine(line_em, pdt, PCLOSE*-.0027+PCLOSE)
f_moveLine(line_neg1, pdt, PCLOSE*-.0048+PCLOSE)
f_moveLine(line_neg2, pdt, PCLOSE*-.0096+PCLOSE)
f_moveLine(line_erneg, pdt, PCLOSE*-.0118+PCLOSE)
f_moveLine(line_emrneg, pdt, PCLOSE*-.0191+PCLOSE)
line.set_style(line_close, line.style_dashed)
line.set_width(line_close, 2)
line.set_style(line_em, line.style_dotted)
line.set_width(line_em, 2)
line.set_style(line_emrpos, line.style_dashed)
line.set_width(line_emrpos, 2)
line.set_style(line_emrneg, line.style_dashed)
line.set_width(line_emrneg, 2)
line.set_style(line_erpos, line.style_dotted)
line.set_width(line_erpos, 2)
line.set_style(line_erneg, line.style_dotted)
line.set_width(line_erneg, 2) |
Momentum 2.0 [AstrideUnicorn] | https://www.tradingview.com/script/pF5MAeqK-Momentum-2-0-AstrideUnicorn/ | AstrideUnicorn | https://www.tradingview.com/u/AstrideUnicorn/ | 420 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AstrideUnicorn
//@version=5
indicator("Momentum 2.0", overlay = false)
source = close
// Script Inputs
window = input(defval=15, title="Oscillator Period")
base_level_window = input.int(defval=700, title="Base Level Period", minval=300)
// Calculate normalized and smoothed momentum oscillator
momentum = ta.mom(source, window)
momentum_normalized = ( momentum ) / ta.stdev(momentum, base_level_window)
momentum_smoothed = ta.linreg(momentum_normalized, 30,0)
// Calculated the base-level
momentum_base = -ta.ema(momentum_normalized,base_level_window)
// Plot the oscillator and base-level
plot(momentum_smoothed, color = momentum_smoothed > momentum_base? color.green: momentum_smoothed < momentum_base? color.red: color.blue, style = plot.style_columns)
plot(momentum_base, color=color.blue, linewidth=2)
// Calculate base-level cross signals
bullish = ta.crossover(momentum_smoothed, momentum_base) and barstate.isconfirmed
bearish = ta.crossunder(momentum_smoothed, momentum_base) and barstate.isconfirmed
if bullish
alert("Momentum 2.0 BUY signal")
if bearish
alert("Momentum 2.0 SELL signal")
// Plot trading signals labels
plotshape(bearish?momentum_base:na, style=shape.labeldown, color = #9A2A2A, text="▼",textcolor = color.white, size=size.normal, location = location.absolute)
plotshape(bullish?momentum_base:na, style=shape.labelup, color = #006400, text="▲", textcolor = color.white, size=size.normal, location = location.absolute)
|
MZ Adaptive Ichimoku Cloud (Volume, Volatility, Chikou Filter) | https://www.tradingview.com/script/ppZeynEd-MZ-Adaptive-Ichimoku-Cloud-Volume-Volatility-Chikou-Filter/ | MightyZinger | https://www.tradingview.com/u/MightyZinger/ | 157 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MightyZinger
//@version=5
indicator('MZ Adaptive Ichimoku Cloud (Volume, Volatility, Chikou Filter) (MZ AIC)', shorttitle='MZ AIC', overlay=true)
import MightyZinger/RVSI/1 as mz
import MightyZinger/Chikou/3 as filter
import MightyZinger/Adaptive_Length/5 as length
uha =input(true, title="Use Heikin Ashi Candles for Volume Oscillator Calculations")
// Use only Heikinashi Candles for all calculations
haclose = uha ? ohlc4 : close
f_ha_open() =>
haopen = float(na)
haopen := na(haopen[1]) ? (open + close) / 2 : (nz(haopen[1]) + nz(haclose[1])) / 2
haopen
haopen = uha ? f_ha_open() : open
vol = volume
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
///// Source Options //////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// ─── Different Sources Options List ───► [
string SRC_Tv = 'Use traditional TradingView Sources '
string SRC_Wc = '(open+close+3(high+low))/8'
string SRC_Wo = 'close+high+low-2*open'
string SRC_Wu = '(close+5(high+low)-7(open))/4'
string SRC_Wi = '(open+close+5(high+low))/12'
string SRC_Exi = 'close>open ? high : low'
string SRC_Exj = 'Heiken-ashi(close>open) ? high : low'
string src_grp = 'Source Parameters'
// ●───────── Inputs ─────────● {
diff_src = input.string(SRC_Exi, '→ Different Sources Options', options=[SRC_Tv, SRC_Wc, SRC_Wo, SRC_Wu, SRC_Wi, SRC_Exi, SRC_Exj], group=src_grp)
i_sourceSetup = input.source(close, 'Tradingview Source Setup', group=src_grp)
i_Sym = input.bool(true, 'Apply Symmetrically Weighted Moving Average at the price source (May Result Repainting)', group=src_grp)
h_open = f_ha_open()
// Get Source
src_o = diff_src == SRC_Wc ? (open+close+3*(high+low))/8 :
diff_src == SRC_Wo ? close+high+low-2*open :
diff_src == SRC_Wu ? (close+5*(high+low)-7*(open))/4 :
diff_src == SRC_Wi ? (open+close+5*(high+low))/12 :
diff_src == SRC_Exi ? (close > open ? high : low) :
diff_src == SRC_Exj ? (ohlc4 > h_open ? high : low) :
i_sourceSetup
src_f = i_Sym ? ta.swma(src_o) : src_o // Symmetrically Weighted Moving Average?
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Ichimoku cloud display ON/OFF selections {
ich_group='☁️ Ichimoku Cloud ☁️'
ichimoku_onf = input.bool(true, 'Ichimoku On/Off', group = ich_group)
tenkanof = input.bool(true, 'Tenkan Sen', group = ich_group)
kijunof = input.bool(true, 'Kijun Sen', group = ich_group)
chikouof = input.bool(true, 'Chikou Span', group = ich_group)
senkouAof = input.bool(false, 'Senkou Span A', group = ich_group)
senkouBof = input.bool(false, 'Senkou Span B', group = ich_group)
cloudof = input.bool(true, 'Kumo Fill', group = ich_group)
//}
// Dynamic Length Range Inputs {
k_min_len = input.int(title='Kijun Min Length', defval=20, inline='i1', group = ich_group)
k_max_len = input.int(title='Kijun Max Length', defval=60, inline='i1', group = ich_group)
t_min_len = input.int(title='Tenkan Min Length', defval=9, inline='i2', group = ich_group)
t_max_len = input.int(title='Tenkan Max Length', defval=30, inline='i2', group = ich_group)
sn_offset = input.int(title='Senkou-Span Offset', defval=26, group = ich_group)
sn_min_len = input.int(title='Senkou-Span Min Length', defval=50, inline='i3', group = ich_group)
sn_max_len = input.int(title='Senkou-Span Max Length', defval=120, inline='i3', group = ich_group)
c_min_len = input.int(title='Chikou Min Length', defval=26, inline='i4', group = ich_group)
c_max_len = input.int(title='Chikou Max Length', defval=50, inline='i4', group = ich_group)
//}
//Adapting Percentage{
k_AadaptPerc = input.float(96.85, minval=0, maxval=100, title='Kijun Dynamic Length Adapting Percentage:', group = ich_group) / 100.0
t_AadaptPerc = input.float(96.85, minval=0, maxval=100, title='Tenkan Dynamic Length Adapting Percentage:', group = ich_group) / 100.0
sn_AadaptPerc = input.float(96.85, minval=0, maxval=100, title='Senkou Dynamic Length Adapting Percentage:', group = ich_group) / 100.0
c_AadaptPerc = input.float(96.85, minval=0, maxval=100, title='Chikou Dynamic Length Adapting Percentage:', group = ich_group) / 100.0
//}
// Chikou Fiter length and color inputs{
string c_grp = 'Chikou Filter Parameters'
c_len = input.int(25, title='Chikou Filter Period', group=c_grp)
c_bull_col = input.color(color.green, 'Chikou Bull Color ', group = c_grp, inline='c_col')
c_bear_col = input.color(color.red, 'Chikou Bear Color ', group = c_grp, inline='c_col')
c_rvsl_col = input.color(color.yellow, 'Chikou Consollidation/Reversal Color ', group = c_grp, inline='c_col')
//}
// Dynamic Adaption Parameters Checks{
grp2 = 'Adapt Kijun Dynamic Length Based on '
grp3 = 'Adapt Tenkan Dynamic Length Based on '
grp4 = 'Show Trade Signals Based on'
grp5 = 'Adapt Chikou Dynamic Length Based on '
grp6 = 'Adapt Senkou Dynamic Length Based on '
// Adaptive Length Checks
ch1 = 'Volume'
ch2 = 'Cross(Tenkan,Kijun)'
ch3 = 'Volatility'
ch4 = 'Tenkan = Kijun'
ch5 = 'Chikou > Source'
ch6 = 'Chikou Momentum'
ch7 = 'Source > Kumo'
ch8 = 'Source > Tenkan'
ch9 = 'Chikou Backward Trend Filter'
k_volume_chk = input.bool(true, title=ch1, group=grp2, inline='k_chks')
k_volat_chk = input.bool(true, title=ch3, group=grp2, inline='k_chks')
k_chik_chk = input.bool(true, title=ch9, group=grp2, inline='k_chks')
t_volume_chk = input.bool(true, title=ch1, group=grp3, inline='ten_chks')
t_volat_chk = input.bool(true, title=ch3, group=grp3, inline='ten_chks')
t_chik_chk = input.bool(true, title=ch9, group=grp3, inline='ten_chks')
sn_volume_chk = input.bool(true, title=ch1, group=grp6, inline='sn_chks')
sn_volat_chk = input.bool(true, title=ch3, group=grp6, inline='sn_chks')
sn_chik_chk = input.bool(true, title=ch9, group=grp6, inline='sn_chks')
c_volume_chk = input.bool(true, title=ch1, group=grp5, inline='c_chks')
c_volat_chk = input.bool(true, title=ch3, group=grp5, inline='c_chks')
c_chik_chk = input.bool(true, title=ch9, group=grp5, inline='c_chks')
s_volume_chk = input.bool(true, title=ch1, group=grp4, inline='sell_chks')
s_cross_chk = input.bool(false, title=ch2, group=grp4, inline='sell_chks')
s_volat_chk = input.bool(true, title=ch3, group=grp4, inline='sell_chks')
s_eq_chk = input.bool(false, title=ch4, group=grp4, inline='sell_chks')
s_chikou_chk = input.bool(false, title=ch5, group=grp4, inline='sell_chks')
s_cs_mom_chk = input.bool(false, title=ch6, group=grp4, inline='sell_chks')
s_senkou_chk = input.bool(true, title=ch7, group=grp4, inline='sell_chks')
s_tenk_chk = input.bool(true, title=ch8, group=grp4, inline='sell_chks')
s_c_fltr_chk = input.bool(true, title=ch9, group=grp4, inline='sell_chks')
//}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Charting and Plotting display parameters{
show_color_bar = input.bool(title='Color Bars', defval=true, group='Plot Parameters')
showSignals = input.bool(true, title='Show Trade Signals', group='Plot Parameters')
bar_grp = 'Bars Coloring'
bar_bull = input.color(color.rgb(38, 208, 124, 0), 'src > tenkanSen and src > kijunSen', group = bar_grp)
bar_bear = input.color(color.rgb(225, 6, 0, 0), 'src < tenkanSen and src < kijunSen', group = bar_grp)
bar_bot_rev = input.color(color.rgb(255, 114, 118, 0), 'src > tenkanSen and src < kijunSen', group = bar_grp)
bar_top_rev = input.color(color.rgb(31, 32, 34, 0), 'src < tenkanSen and src > kijunSen', group = bar_grp)
//}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Volume and other Inputs{
// Volume Oscillator Types Input
osc1 = 'TFS Volume Oscillator'
osc2 = 'On Balance Volume'
osc3 = 'Klinger Volume Oscillator'
osc4 = 'Cumulative Volume Oscillator'
osc5 = 'Volume Zone Oscillator'
k_osctype = input.string(title='Volume Oscillator Type for Kijun', group='RVSI Parameters', defval=osc2, options=[osc1, osc2, osc3, osc4, osc5])
t_osctype = input.string(title='Volume Oscillator Type for Tenkan', group='RVSI Parameters', defval=osc2, options=[osc1, osc2, osc3, osc4, osc5])
sn_osctype = input.string(title='Volume Oscillator Type for Senkou', group='RVSI Parameters', defval=osc2, options=[osc1, osc2, osc3, osc4, osc5])
c_osctype = input.string(title='Volume Oscillator Type for Chikou', group='RVSI Parameters', defval=osc2, options=[osc1, osc2, osc3, osc4, osc5])
s_osctype = input.string(title='Volume Oscillator Type for Sell Confirmation', group='RVSI Parameters', defval=osc2, options=[osc1, osc2, osc3, osc4, osc5])
rvsiLen = input.int(14, minval=1,title="RVSI Length", group="RVSI Parameters")
vBrk = input.int(50, minval=1,title="RVSI Break point", group="RVSI Parameters")
atrFlength = input.int(14, title="ATR Fast Length", group="Volatility Parameters")
atrSlength = input.int(46, title="ATR Slow Length", group="Volatility Parameters")
//}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
///// Kijun Function //////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Kijun V2 Function {
kidiv = input.int(defval=1, maxval=4, title='Kijun MOD Divider')
// Kijun v2 Main function
kijunv2(src, len) =>
var float result = 0.0
kijun = math.avg(ta.lowest(len), ta.highest(len)) //, (open + close)/2)
conversionLine = math.avg(ta.lowest(len / kidiv), ta.highest(len / kidiv))
delta = (kijun + conversionLine) / 2
result := delta
result
//}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
///// Relative Volume Strength Index (MZ RVSI) //////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// TFS Volume Oscillator
tfs_volLen = input.int(30, minval=1,title="Volume Length", group="TFS Volume Oscillator")
// Volume Zone Oscillator
vzo_Len = input.int(21, "VZO Length", minval=1, group="Volume Zone Oscillator Parameters")
// Volume Oscillator function
kvo_FastX = input.int(34, minval=1,title="Volume Fast Length", group="KVO Parameters")
kvo_SlowX = input.int(55, minval=1,title="Volume Slow Length", group="KVO Parameters")
// Cumulative Volume Oscillator
cvo(vol_src, rvsiLen, _open, _high, _low, _close) =>
float result = 0
ema1len = input.int(defval = 8, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters")
ema2len = input.int(defval = 21, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters")
obvl = "On Balance Volume"
cvdo = "Cumulative Volume Delta"
pvlt = "Price Volume Trend"
cvtype = input.string(defval = pvlt, options = [obvl, cvdo, pvlt], group="Cumulative Volume Oscillator Parameters")
_obv = mz.rvsi_cvo_obv(ema1len, ema2len, rvsiLen)
_pvt = mz.rvsi_cvo_pvt(ema1len, ema2len, rvsiLen)
_cvd = mz.rvsi_cvo_cvd(vol_src, ema1len, ema2len, rvsiLen, _open, _high, _low, _close)
result := cvtype == obvl ? _obv : cvtype == cvdo ? _cvd : _pvt
result
vol_osc(type, vol_src, _rvsiLen, _open, _high, _low, _close) =>
float _rvsi = 0
if type=="TFS Volume Oscillator"
_rvsi := mz.rvsi_tfs(vol_src, tfs_volLen, _rvsiLen, _open, _close)
if type=="On Balance Volume"
_rvsi := mz.rvsi_obv(vol_src, _close, _rvsiLen)
if type=="Klinger Volume Oscillator"
_rvsi := mz.rvsi_kvo(vol_src, _close, kvo_FastX, kvo_SlowX, _rvsiLen)
if type=="Cumulative Volume Oscillator"
_rvsi := cvo(vol_src, _rvsiLen, _open, _high, _low, _close)
if type=="Volume Zone Oscillator"
_rvsi := mz.rvsi_vzo(vol_src, _close, vzo_Len, _rvsiLen)
_rvsi
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
//RVSI calculations for Kijun, Tenkan, Senkou, Chikou and Trade Confirmations{
// RVSI for Kijun
k_rvsi = vol_osc(k_osctype,vol,rvsiLen,haopen,high,low,haclose)
// RVSI for Tenkan
t_rvsi = vol_osc(t_osctype,vol,rvsiLen,haopen,high,low,haclose)
// RVSI for Senkou
sn_rvsi = vol_osc(sn_osctype,vol,rvsiLen,haopen,high,low,haclose)
// RVSI for Chikou
c_rvsi = vol_osc(c_osctype,vol,rvsiLen,haopen,high,low,haclose)
// RVSI for Sell Confirmation
s_rvsi = vol_osc(s_osctype,vol,rvsiLen,haopen,high,low,haclose)
// Volume Breakout Condition for Kijun
k_volBrkUp = k_rvsi > vBrk // and rvsiSlp >= flat
k_volBrkDn = k_rvsi < vBrk //or rvsiSlp <= -flat //
// Volume Breakout Condition for Tenkan
t_volBrkUp = t_rvsi > vBrk // and rvsiSlp >= flat
t_volBrkDn = t_rvsi < vBrk //or rvsiSlp <= -flat //
// Volume Breakout Condition for Senkou
sn_volBrkUp = sn_rvsi > vBrk // and rvsiSlp >= flat
sn_volBrkDn = sn_rvsi < vBrk //or rvsiSlp <= -flat //
// Volume Breakout Condition for Chikou
c_volBrkUp = c_rvsi > vBrk // and rvsiSlp >= flat
c_volBrkDn = c_rvsi < vBrk //or rvsiSlp <= -flat //
// Volume Breakout Condition for Sell Confirmation
s_volBrkUp = s_rvsi > vBrk // and rvsiSlp >= flat
s_volBrkDn = s_rvsi < vBrk //or rvsiSlp <= -flat //
//}
//Volatility Meter
highVolatility = ta.atr(atrFlength) > ta.atr(atrSlength)
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Calling Chikou filter function from library to obtaing dynamic color of Chikou-Span and also Trend
[chikou_clr, c_filter_sig] = filter.chikou(src_f, c_len, high, low, c_bull_col, c_bear_col, c_rvsl_col)
// Function to form table between selection boolean parameters
f_para(chk_a, return_a)=>
var result_p = bool(na)
// Initializing Return Parameter
for i = 0 to array.size(chk_a)-1
if array.get(chk_a, i) == true
result_p := array.get(return_a, i)
break
// Checking other Return Parameters
for i = 0 to array.size(chk_a)-1
result_p := array.get(chk_a, i) ? array.get(return_a, i) and result_p : result_p // Varifying Other Checks
result_p
bool[] k_chk_array = array.from(k_volume_chk,
k_volat_chk,
k_chik_chk)
bool[] t_chk_array = array.from(t_volume_chk,
t_volat_chk,
t_chik_chk)
bool[] sn_chk_array = array.from(sn_volume_chk,
sn_volat_chk,
sn_chik_chk)
bool[] c_chk_array = array.from(c_volume_chk,
c_volat_chk,
c_chik_chk)
bool[] k_up_para_a = array.from(k_volBrkUp,
highVolatility,
c_filter_sig == 1)
bool[] t_up_para_a = array.from(t_volBrkUp,
highVolatility,
c_filter_sig == 1)
bool[] sn_up_para_a = array.from(sn_volBrkUp,
highVolatility,
c_filter_sig == 1)
bool[] c_up_para_a = array.from(c_volBrkUp,
highVolatility,
c_filter_sig == 1)
k_up_para = f_para(k_chk_array, k_up_para_a)
t_up_para = f_para(t_chk_array, t_up_para_a)
sn_up_para = f_para(sn_chk_array, sn_up_para_a)
c_up_para = f_para(c_chk_array, c_up_para_a)
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Calculating Dynamic Lengths
k_dyna = length.dynamic(k_up_para , k_AadaptPerc, k_min_len, k_max_len)
t_dyna = length.dynamic(t_up_para , t_AadaptPerc, t_min_len, t_max_len)
senko_dyna = length.dynamic(sn_up_para , sn_AadaptPerc, sn_min_len, sn_max_len)
c_dyna = length.dynamic(c_up_para , c_AadaptPerc, c_min_len, c_max_len)
// Calculating Kijun, Tenkan and Senkou
kijunSen = kijunv2(src_f, k_dyna)
tenkanSen = kijunv2(src_f, t_dyna)
senkouSpanA = math.avg(tenkanSen, kijunSen)
senkouSpanB = math.avg(ta.highest(high, senko_dyna), ta.lowest(low, senko_dyna))
chikouSpan = src_f
/////////////////////////////////////////////////////////////////////
// Plotting chikou-span on dynamic adaptive length based offset
plotchikouSpan = plot(ichimoku_onf ? chikouSpan : na, offset = -c_dyna, color=not chikouof ? na : chikou_clr, title='Chikou', linewidth=2)
// ---Color for Kumo Cloud
f_c_gradientRelative(_source, _min, _max, _c_bear, _c_bull) =>
var float _center = _min + (_max - _min) / 2
color _return = _source >= _center ?
color.from_gradient(_source, _center, _max, color.new(_c_bull, 100), color.new(_c_bull, 0)) :
color.from_gradient(_source, _min, _center, color.new(_c_bear, 0), color.new(_c_bear, 100))
sen_clr_src = (senkouSpanA - senkouSpanB) / src_f * 100
clrfill = senkouSpanA > senkouSpanB ? color.from_gradient(ta.rsi(math.avg(senkouSpanA , senkouSpanB), 14) , 0, 100, color.rgb(219,226,233), color.rgb(8,255,8)) :
senkouSpanA < senkouSpanB ? color.from_gradient(ta.rsi(math.avg(senkouSpanA , senkouSpanB), 14) , 0, 100, color.rgb(229,225,230), color.rgb(210,39,48)) : color.rgb(229,225,230)
// ---Ploting Senkou-span A & B and Kumo
plotkijunSen = plot(ichimoku_onf ? kijunSen : na, offset=00, color=not kijunof ? na : color.rgb(157, 34, 53, 0), title='Kijun-Sen', linewidth=2)
plottenkanSen = plot(ichimoku_onf ? tenkanSen : na, offset=00, color=not tenkanof ? na : color.rgb(170, 219, 30, 0), title='Tenkan-Sen', linewidth=2)
plotsenkouSpanA = plot(ichimoku_onf ? senkouSpanA : na, offset = sn_offset-1, color=not senkouAof ? na : color.yellow, title='Senkou-Span A', linewidth=1)
plotsenkouSpanB = plot(ichimoku_onf ? senkouSpanB : na, offset = sn_offset-1, color=not senkouBof ? na : color.red, title='Senkou-Span B', linewidth=2)
fill(plotsenkouSpanA, plotsenkouSpanB, color=not cloudof ? na : color.new(clrfill, 80))
// Funtion to define Bars coloring
colbar(src, tenkanSen, kijunSen) =>
col_bar = color.new(na, 10)
col_bar := src > tenkanSen and src > kijunSen? bar_bull :
src < tenkanSen and src < kijunSen ? bar_bear :
src > tenkanSen and src < kijunSen ? bar_bot_rev :
src < tenkanSen and src > kijunSen ? bar_top_rev : na
col_bar
color_bar = colbar(close, tenkanSen, kijunSen)
barcolor(show_color_bar ? color_bar : na)
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Trade signals confirmations decided based on input checks
cs_bull = ta.mom(src_f, c_dyna - 1) > 0
cs_bear = ta.mom(src_f, c_dyna - 1) < 0
ss_high = math.max(senkouSpanA[sn_offset - 1], senkouSpanB[sn_offset - 1])
ss_low = math.min(senkouSpanA[sn_offset - 1], senkouSpanB[sn_offset - 1])
price_above_kumo = src_f > ss_high
price_below_kumo = src_f < ss_high // ss_low
bool[] chk_array = array.from(s_volume_chk,
s_volat_chk,
s_cross_chk,
s_cs_mom_chk,
s_chikou_chk,
s_senkou_chk,
s_tenk_chk,
s_c_fltr_chk)
bool[] up_para_array = array.from(s_volBrkUp,
highVolatility,
tenkanSen > kijunSen,
cs_bull,
chikouSpan > src_f[int(c_dyna)],
price_above_kumo,
tenkanSen,
c_filter_sig == 1)
bool[] dn_para_array = array.from(s_volBrkDn,
highVolatility,
tenkanSen < kijunSen,
cs_bear,
chikouSpan < src_f[int(c_dyna)],
price_below_kumo,
src_f < tenkanSen,
c_filter_sig == -1)
c_fltr_up = f_para(chk_array, up_para_array)
c_fltr_dn = f_para(chk_array, dn_para_array)
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
eq_up = s_eq_chk ? tenkanSen == kijunSen and tenkanSen[1] < kijunSen[1] or c_fltr_up : c_fltr_up
eq_dn = s_eq_chk ? tenkanSen == kijunSen and tenkanSen[1] > kijunSen[1] or c_fltr_dn : c_fltr_dn
_up = eq_up
_dn = eq_dn
// Defining Buy/Sell Signals
buy = _up and not _up[1]
sell = _dn and not _dn[1]
var sig = 0
if buy and sig <= 0
sig := 1
if sell and sig >= 0
sig := -1
longsignal = sig == 1 and sig[1] != 1
shortsignal = sig == -1 and sig[1] != -1
atrPos = 0.85 * ta.atr(5)
// Plotting Signals for every confirmed condition
plotshape(showSignals and buy ? low - atrPos : na, style=shape.circle, color=color.new(#AADB1E, 0), location=location.absolute, size=size.tiny)
plotshape(showSignals and sell ? high + atrPos : na, style=shape.circle, color=color.new(#E10600, 0), location=location.absolute, size=size.tiny)
// Plotting Long term Buy/Sell signals
plotshape(showSignals and longsignal ? (low ) - atrPos : na, style=shape.triangleup, color=color.new(color.green, 0), location=location.absolute, text='Buy', size=size.small)
plotshape(showSignals and shortsignal ? (high ) + atrPos : na, style=shape.triangledown, color=color.new(color.red, 0), location=location.absolute, text='Sell', size=size.small)
|
Power of Stock's Trading Idea | https://www.tradingview.com/script/6KLbverJ-Power-of-Stock-s-Trading-Idea/ | mortal_glitch | https://www.tradingview.com/u/mortal_glitch/ | 185 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mortal_glitch
//@version=5
indicator("Power of Stocks Trading Strategy",shorttitle="POS", overlay=true)
showEMA = input(title="Show EMA Sell", defval=true)
showIB = input(title="Show Inside Bar", defval=true)
//Inside Bars
RR=input.float(2, minval=1, title="Risk:Reward Ratio")
showST = input(title="Show SL & Target", defval=true)
insideBar() => high[1] <= high[2] and low[1] >= low[2] ? 1 : 0
draw_line(y,col,sty)=>line.new(x1=time-(10*60*1000),y1=y,x2=time+(60*60*1000),y2=y, color=col,xloc= xloc.bar_time, style=sty)
draw_label(y)=>
display_text =str.format(" ({0})", math.round_to_mintick(y))
label.new(x = time+(60*60*1000), y=y, text=display_text, textcolor=color.new(color.white,50), color=#00000000, xloc=xloc.bar_time)
if insideBar() and close>=high[1] and not(barstate.islast) and not(barstate.isfirst) and showIB and showST
draw_line(high[1],color.white,line.style_solid)
draw_line(low[2],color.red,line.style_dashed)
draw_label(low[2])
draw_line((high[1]+(RR*(high[1]-low[2]))),color.green,line.style_dashed)
draw_label(high[1]+(RR*(high[1]-low[2])))
if insideBar() and close<=low[1] and not(barstate.islast) and not(barstate.isfirst) and showIB and showST
draw_line(low[1],color.white,line.style_solid)
draw_line(high[2],color.red,line.style_dashed)
draw_label(high[2])
draw_line((low[1]-(RR*(high[2]-low[1]))),color.green,line.style_dashed)
draw_label((low[1]-(RR*(high[2]-low[1]))))
//5EMA
ema5 = ta.ema(close, 5 )
sl=high>high[1]?high:high<high[1]?high[1]:0
tar=low[1]-(RR*(sl-low[1]))
plotshape( low[1]>ema5 and open[1]>close[1] and close<close[1] and showEMA and not(barstate.isfirst), title="Sell Label", text="SELL",color=color.new(#FF000D,50), location=location.abovebar, style=shape.labeldown, size=size.tiny, textcolor=color.white)
if low[1]>ema5 and open[1]>close[1] and close<close[1] and showEMA and showST and not(barstate.isfirst)
draw_line(sl,color.red,line.style_dotted)
draw_label(sl)
draw_line(tar,color.green,line.style_dotted)
draw_label(tar)
draw_line(low[1],color.white,line.style_solid)
|
Volume Strength Finder | https://www.tradingview.com/script/yYa3hro5-Volume-Strength-Finder/ | Saravanan_Ragavan | https://www.tradingview.com/u/Saravanan_Ragavan/ | 765 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Saravanan_Ragavan
//@version=4
study("Volume Strength Finder", "VSF", overlay=true)
T1 = time(timeframe.period, "0915-0916")
T2 = time(timeframe.period, "0915-1530")
Y = bar_index
Z1 = valuewhen(T1, bar_index, 0)
L = Y-Z1 + 1
SSPV = 0.00
SSNV = 0.00
pdw=0.00
ndw=0.00
total_w=0.00
for i = 1 to L-1
total_w:=high[i]-low[i]
positive = close[i]-low[i]
negative = high[i]- close[i]
pdw := (positive/total_w)*100
ndw := (negative/total_w)*100
SSPV := (volume[i]*pdw)/100 + SSPV
SSNV := (volume[i]*ndw)/100 + SSNV
total_v = SSPV +SSNV
Pos = (SSPV / total_v) *100
Neg = (SSNV / total_v) *100
bgc = SSPV>SSNV ? color.green: SSPV<SSNV ? color.red: color.white
barcolor (bgc)
var table sDisplay = table.new(position.top_right, 1, 5, bgcolor = color.aqua, frame_width = 2, frame_color = color.black)
if barstate.islast
table.cell(sDisplay, 0, 0, "Today's Volume : " + tostring(total_v), text_color = color.white, text_size=size.large, bgcolor=color.aqua)
table.cell(sDisplay, 0, 1, "Buyers Volume: " +tostring(round(SSPV)) , text_color = color.white, text_size=size.large, bgcolor=color.green)
table.cell(sDisplay, 0, 2, "Sellers Volume: " +tostring(round(SSNV)) , text_color = color.white, text_size=size.large, bgcolor=color.red)
table.cell(sDisplay, 0, 3, "Buyers Strength: " +tostring(round(Pos)) + "%" , text_color = color.white, text_size=size.large, bgcolor=color.green)
table.cell(sDisplay, 0, 4, "Sellers Strength: " +tostring(round(Neg)) + "%" , text_color = color.white, text_size=size.large, bgcolor=color.red)
|
EPS Dashboard | https://www.tradingview.com/script/oQewDZFY-EPS-Dashboard/ | millerrh | https://www.tradingview.com/u/millerrh/ | 174 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © millerrh
//@version=5
indicator("EPS", overlay=false)
var table epsTable = table.new(position.middle_left, 7, 1, border_width=3)
lightTransp = 90
avgTransp = 80
heavyTransp = 70
// === USER INPUTS ===
i_posColor = input(color.rgb(38, 166, 154), title='Positive Color')
i_negColor = input(color.rgb(240, 83, 80), title='Negative Color')
// i_volColor = input(color.new(#999999, 0), title='Neutral Color')
// === FUNCTIONS AND CALCULATIONS ===
// Current earnings per share
EPS = request.financial(syminfo.tickerid, "EARNINGS_PER_SHARE", "FQ")
// Function to define previous quarters' earnings per share
f_eps(i) =>
request.security(syminfo.tickerid, '1M', EPS[i])
// Year over year percentage change EPS
EPSyoy = (EPS-f_eps(12))/math.abs(f_eps(12))*100
// === TABLE FUNCTIONS ===
f_fillCell(_table, _column, _row, _value, _quarter) =>
_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = math.abs(_value) > 3 ? heavyTransp : math.abs(_value) > 1 ? avgTransp : lightTransp
_cellText = '$' + str.tostring(_value, '0.000') + '\n' + _quarter
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(_c_color, _transp), text_color=_c_color, width=7)
f_fillCellComp(_table, _column, _row, _value, _text) =>
_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = math.abs(_value) > 60 ? heavyTransp : math.abs(_value) > 20 ? avgTransp : lightTransp
_cellText = str.tostring(_value, '0.00') + '%\n' + _text
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(_c_color, _transp), text_color=_c_color, width=10)
oneQperf = (EPS-f_eps(4))/math.abs(f_eps(4))*100
twoQperf = (f_eps(4)-f_eps(7))/math.abs(f_eps(7))*100
threeQperf = (f_eps(7)-f_eps(10))/math.abs(f_eps(10))*100
avgPerf = math.avg(oneQperf, twoQperf, threeQperf)
// Display table
if barstate.islast
f_fillCell(epsTable, 0, 0, f_eps(13), '1Y BACK')
f_fillCell(epsTable, 1, 0, f_eps(10), '3Q BACK')
f_fillCell(epsTable, 2, 0, f_eps(7), '2Q BACK')
f_fillCell(epsTable, 3, 0, f_eps(4), '1Q BACK')
f_fillCell(epsTable, 4, 0, EPS, 'CURRENT')
f_fillCellComp(epsTable, 5, 0, avgPerf, 'QTRLY AVERAGE')
f_fillCellComp(epsTable, 6, 0, (EPS-f_eps(13))/math.abs(f_eps(13))*100, 'YOY CHANGE')
|
SOPR Candles Oscillator | https://www.tradingview.com/script/eywr9q1Q-SOPR-Candles-Oscillator/ | Gokubro | https://www.tradingview.com/u/Gokubro/ | 46 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Gokubro
//@version=5
indicator("SOPR Candles", overlay = false)
string crypto_choice = input.string("BTC", "Type in desired Crypto e.g. BTC, ETH, or LTC")
BTC_SOPR = request.security(crypto_choice + "_SOPR", timeframe.period, close)
matype = input.string(title='Moving Average Type', options=['SMA', 'EMA'], defval='SMA')
length = input(30, 'Moving Average Length')
BTC_SOPR_ema = matype == 'SMA' ? ta.sma(BTC_SOPR, length) : ta.ema(BTC_SOPR, length)
plot(BTC_SOPR-1, title="BTC SOPR", color=color.green, style=plot.style_columns, color=(BTC_SOPR-1>=0? color.gray : color.green))
plot(BTC_SOPR_ema-1, title="BTC SOPR smoothed", color=color.green, style=plot.style_columns, color=(BTC_SOPR_ema-1>=0? color.gray : color.green), display=display.none)
bcolor = BTC_SOPR-1>=0 ? color.green : color.blue
barcolor(bcolor)
|
Bar Overlap - Sort of inside bars | https://www.tradingview.com/script/hqs9zZE3-Bar-Overlap-Sort-of-inside-bars/ | callmejaytrader | https://www.tradingview.com/u/callmejaytrader/ | 9 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © callmejaytrader
//@version=5
indicator("Bar Overlap")
overlapAmount = math.max(0,math.min(high, high[1]) - math.max(low, low[1]))
barAmount = high - low
overlap = overlapAmount /barAmount
averageOverlap = ta.sma(overlap, 10)
plot(overlap)
hline(0.5)
hline(0.1)
hline(0.9)
|
Pivot Order Blocks | https://www.tradingview.com/script/uO4zPk1a-Pivot-Order-Blocks/ | TradingWolf | https://www.tradingview.com/u/TradingWolf/ | 1,461 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MensaTrader
//@version=5
indicator("Pivot Order Blocks", shorttitle="Pivot - OB", overlay=true, max_bars_back=500, max_boxes_count=250)
//Titles
inputGroupTitle = "=== Pivots ==="
plotGroupTitle = "=== Plots ==="
//Inputs
source = input.string("Wicks", options=['Wicks','Bodys'], title="Source", group=inputGroupTitle)
leftLenH = input.int(title="Pivot High", defval=25, minval=1, inline="Pivot High", group=inputGroupTitle)
rightLenH = input.int(title="/", defval=25, minval=1, inline="Pivot High", group=inputGroupTitle)
leftLenL = input.int(title="Pivot Low", defval=25, minval=1, inline="Pivot Low", group=inputGroupTitle)
rightLenL = input.int(title="/", defval=25, minval=1, inline="Pivot Low", group=inputGroupTitle)
bullBoxColor = input.color(color.new(#00E600,90), title="Bullish Color", group=plotGroupTitle, inline="1")
bearBoxColor = input.color(color.new(#FF0000,90), title="Bearish Color", group=plotGroupTitle, inline="1")
closedBoxColor = input.color(color.new(color.gray,90), title="Closed", group=plotGroupTitle, inline="1")
extendBox = input.bool(true, title="Extend Boxes", group=plotGroupTitle, tooltip="Extend boxes until price hits them")
boxLength = input.int(30, title="Box Size", tooltip="if Extend boxes is off, boxes will be drawn this long", group=plotGroupTitle)
//Wick / Body option
phOption = source == "Wicks" ? high : close
plOption = source == "Wicks" ? low : close
ph = ta.pivothigh(phOption,leftLenH, rightLenH)
pl = ta.pivotlow(plOption,leftLenL, rightLenL)
//Variables
var leftBull = bar_index
var rightBull = bar_index
var topBull = close
var bottomBull = close
var leftBear = bar_index
var rightBear = bar_index
var topBear = close
var bottomBear = close
var box[] _bearBoxes = array.new_box()
var box[] _bullBoxes = array.new_box()
//Bear Box Calc
if ph
leftBear := bar_index-leftLenH
rightBear := bar_index-(leftLenH-boxLength)
topBear := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? close[leftLenH] : open[leftLenH]) : high[leftLenL]
bottomBear := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? open[leftLenH] : close[leftLenH]) : close[leftLenL] > open[leftLenL] ? close[leftLenL] : open[leftLenL]
//Bull Box Calc
if pl
leftBull := bar_index-leftLenL
rightBull := bar_index-(leftLenL-boxLength)
topBull := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? close[leftLenL] : open[leftLenL]) : close[leftLenL] > open[leftLenL] ? open[leftLenL] : close[leftLenL]
bottomBull := source == "Bodys" ? (close[leftLenL]>open[leftLenL] ? open[leftLenL] : close[leftLenL]) : low[leftLenL]
if pl
array.push(_bullBoxes, box.new(left=leftBull, right=rightBull, top=topBull, bottom=bottomBull, bgcolor=color.new(bullBoxColor,80), border_color=bullBoxColor))
if ph
array.push(_bearBoxes, box.new(left=leftBear, right=rightBear, top=topBear, bottom=bottomBear, bgcolor=color.new(bearBoxColor,80), border_color=bearBoxColor))
extend_boxes(_array, _type)=>
if array.size(_array)>0
for i = 0 to array.size(_array)-1
_box = array.get(_array,i)
_boxLow = box.get_bottom(_box)
_boxHigh = box.get_top(_box)
_boxLeft = box.get_left(_box)
_boxRight = box.get_right(_box)
if _type=="bull" and _boxRight == bar_index
if low > _boxHigh
box.set_right(_box,bar_index+1)
else
box.set_bgcolor(_box, closedBoxColor)
box.set_border_color(_box, closedBoxColor)
box.set_text_color(_box, closedBoxColor)
box.set_right(_box,bar_index)
if _type=="bear" and _boxRight == bar_index
if high < _boxLow
box.set_right(_box,bar_index+1)
else
box.set_bgcolor(_box, closedBoxColor)
box.set_border_color(_box, closedBoxColor)
box.set_text_color(_box, closedBoxColor)
box.set_right(_box,bar_index)
if extendBox
extend_boxes(_bullBoxes,"bull")
extend_boxes(_bearBoxes,"bear")
|
ICT KillZone [Index futures edition] | https://www.tradingview.com/script/Bec6tTTy-ICT-KillZone-Index-futures-edition/ | SimoneMicucci00 | https://www.tradingview.com/u/SimoneMicucci00/ | 326 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SimoneMicucci00
//@version=5
indicator("ICT Killzone [Index Version]", "Strikezone", true)
//background disply options
bbg = input.bool(true, "", "", "bg", "Background")
cbg = input.color(#80ADFF, "", "", "bg", "Background")
tbg = input.int(80, "", 0, 99, 1,
"1. Display index Strikezone Backgorund\n2. Color of the background\n3. Transparency level",
"bg", "Background")
//swing high-low options
bsw = input.bool(false, "", "", "sw", "Weak Highs and Lows of the strikezone")
csw = input.color(#000000, "", "", "sw", "Weak Highs and Lows of the strikezone")
tsw = input.int(0, "", 0, 99, 1, "", "sw", "Weak Highs and Lows of the strikezone")
wsw = input.int(1, "", [1,2,3,4],
"1. Display index Strikezone High and Low\n2. Color of the line\n3. Transparency\n4. Style of the level\n5. Width",
"sw", "Weak Highs and Lows of the strikezone")
bbox = input.bool(true, "Background", "if you don't want to display full background but only between the high and low of the session\nturn off background and turn this on",
"", "Weak Highs and Lows of the strikezone")
//background plot
t1 = time("", "0830-1201", "America/New_York")
t2 = time("", "1300-1631", "America/New_York")
bgcolor(bbg and (t1 or t2) ? color.new(cbg, tbg) : na)
//line plot
line_(price) =>
ret = line.new(bar_index, price, bar_index, price, color = csw , width = wsw)
box_(hi, lo) =>
ret = box.new(bar_index, hi, bar_index, lo, na, bgcolor = color.new(cbg, tbg))
update_(id_line, price) =>
line.set_x2(id_line, bar_index)
line.set_y1(id_line, price)
line.set_y2(id_line, price)
update(id_box, hi, lo) =>
box.set_right(id_box, bar_index)
box.set_top(id_box, hi)
box.set_bottom(id_box, lo)
if bsw
//position declaration
var float t1high = na
var float t1low = na
var float t2high = na
var float t2low = na
//line declaration
var line hi1 = na
var line lo1 = na
var line hi2 = na
var line lo2 = na
//box declaration
var box b1 = na
var box b2 = na
if(t1 and not t1[1])
t1high := high
t1low := low
hi1 := line_(high)
lo1 := line_(low)
if not bbg and bbox
b1 := box_(high, low)
if(t1 and t1[1])
t1high := high>t1high[1] ? high : t1high[1]
t1low := low<t1low[1] ? low : t1low[1]
update_(hi1, t1high)
update_(lo1, t1low)
if not bbg and bbox
update(b1, t1high, t1low)
if(not t1 and t1[1])
hi1 := na
lo1 := na
b1 := na
if(t2 and not t2[1])
t2high := high
t2low := low
hi2 := line_(high)
lo2 := line_(low)
if not bbg and bbox
b2 := box_(high, low)
if(t2 and t2[1])
t2high := high>t2high[1] ? high : t2high[1]
t2low := low<t2low[1] ? low : t2low[1]
update_(hi2, t2high)
update_(lo2, t2low)
if not bbg and bbox
update(b2, t2high, t2low)
if(not t2 and t2[1])
hi2 := na
lo2 := na
b2 := na
|
US Stock Market Sectors Overview Table [By MUQWISHI] | https://www.tradingview.com/script/3stawKPB-US-Stock-Market-Sectors-Overview-Table-By-MUQWISHI/ | MUQWISHI | https://www.tradingview.com/u/MUQWISHI/ | 367 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MUQWISHI
//@version=5
indicator("US Sectors Overview", overlay = true)
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | INPUT |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// Sorting
sortTable = input.string(title="Sort Table by" , defval="High-Low Change%",
options=["High-Low Change%", "Low-High Change%", "Alphabet", "Correlated"])
// Set Type
set = input.string(title="Sector Set Type " , defval="SPDR SECTOR FUNDs",
options = ["SPDR SECTOR FUNDs", "VANGUARD SECTOR ETFs"])
// Correlation
chos_symbol = input.string("Chart Symbol", title = "Correlated To ",
options = ["Chart Symbol" , "Custom"], group = "Correlation", inline="s01")
corr_symbol = input.symbol("SPY", title= "", group = "Correlation", inline="s01",
tooltip = "Only Vaild When Choosing 'Custom'")
corr_length = input.int(10, title= "Length", minval=1, maxval=1000,
group= "Correlation")
// Table Position
in_table_pos = input.string(title="Table Location", defval= "Middle Right",
options = [ "Top Right" , "Middle Right" , "Bottom Right" ,
"Top Center", "Middle Center", "Bottom Center",
"Top Left" , "Middle Left" , "Bottom Left" ],
group= "Table Styling")
// Table Size
in_table_size = input.string(title="Table Size", defval="Small",
options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"],
group= "Table Styling")
// Table Colors
cell_lowColor = input.color(color.red, title= "Low Cell ",
inline="1", group="TableColor")
cell_midColor = input.color(color.yellow, title= "Mid Cell ",
inline="2", group="TableColor")
cell_highColor = input.color(color.green, title= "High Cell ",
inline="3", group="TableColor")
background_col = input.color(color.gray, title= " Background Color",
inline="1", group="TableColor")
title_textCol = input.color(color.white, title=" Title Text Color ",
inline="2", group="TableColor")
cell_textCol = input.color(color.black, title=" Cell Text Color ",
inline="3", group="TableColor")
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | SYMBOLS |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
sym_short(s) =>
str.substring(s, str.pos(s, ":") + 1)
symbol(num, req) =>
if req == "symbols"
if set == "SPDR SECTOR FUNDs"
symbols= num == 0 ? "NASDAQ:QQQ": num == 1 ? "AMEX:SPY" :
num == 2 ? "AMEX:XLC" : num == 3 ? "AMEX:XLY" :
num == 4 ? "AMEX:XLP" : num == 5 ? "AMEX:XLE" :
num == 6 ? "AMEX:XLF" : num == 7 ? "AMEX:XLV" :
num == 8 ? "AMEX:XLI" : num == 9 ? "AMEX:XLB" :
num == 10 ? "AMEX:XLRE" : num == 11 ? "AMEX:XLK" :
num == 12 ? "AMEX:XLU" : na
else if set == "VANGUARD SECTOR ETFs"
symbols= num == 0 ? "NASDAQ:QQQ": num == 1 ? "AMEX:SPY" :
num == 2 ? "AMEX:VOX" : num == 3 ? "AMEX:VCR" :
num == 4 ? "AMEX:VDC" : num == 5 ? "AMEX:VDE" :
num == 6 ? "AMEX:VFH" : num == 7 ? "AMEX:VHT" :
num == 8 ? "AMEX:VIS" : num == 9 ? "AMEX:VAW" :
num == 10 ? "AMEX:VNQ" : num == 11 ? "AMEX:VGT" :
num == 12 ? "AMEX:VPU" : na
else if req == "description"
des= num== 0 ? "INVESCO" :
num== 1 ? "S&P500" :
num== 2 ? "Communication" :
num== 3 ? "Consumer Discretionary" :
num== 4 ? "Consumer Staples" :
num== 5 ? "Energy" :
num== 6 ? "Financial" :
num== 7 ? "Health Care" :
num== 8 ? "Industrial" :
num== 9 ? "Materials" :
num== 10 ? "Real Estate" :
num== 11 ? "Technology" :
num== 12 ? "Utilities" : na
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | CALCULATION |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// Adjest TimeFrame
mkt_tf() =>
if (timeframe.isdaily and timeframe.multiplier > 1) or
(timeframe.isweekly or timeframe.ismonthly)
mkt_tf = timeframe.period
else
mkt_tf = "D"
// Sorting Table
[colMtx, order] = switch sortTable
"High-Low Change%" => [2, order.descending]
"Low-High Change%" => [2, order.ascending ]
"Correlated" => [3, order.descending]
=> [0, order.ascending]
// Target Symbol for Correlation
custm = request.security(ticker.modify(corr_symbol, syminfo.session),
timeframe.period, close, barmerge.gaps_off)
sym2 = chos_symbol == "Custom"? custm : close
// Matrix
leaders = matrix.new<float>(2, 4, na)
sectors = matrix.new<float>(11, 4, na)
// Fill Matrix Function
fun_matrix(mtxName, row, adj) =>
// Symbol Name
string sym= symbol(row, "symbols")
s = ticker.modify(sym, syminfo.session)
// Symbol code
matrix.set(mtxName, row + adj, 0, row)
// Price
cls = request.security(s, timeframe.period, close, barmerge.gaps_off)
matrix.set(mtxName, row + adj, 1, cls)
// Change in Price
preCls = request.security(s, mkt_tf(), close, barmerge.gaps_off)
mktCls = request.security(s, mkt_tf(), close[1], barmerge.gaps_off)
cls1 = session.ispremarket ? preCls : mktCls
chng = (cls-cls1)/ cls1
matrix.set(mtxName, row + adj, 2, chng)
// Correlation
correlation = ta.correlation(cls, sym2, corr_length)
matrix.set(mtxName, row + adj, 3, correlation)
//++++++++++ Leaders Matrix
fun_matrix(leaders, 0, 0)
fun_matrix(leaders, 1, 0)
matrix.sort(leaders, colMtx, order)
//++++++++++ Sector Matrix
fun_matrix(sectors, 2, -2)
fun_matrix(sectors, 3, -2)
fun_matrix(sectors, 4, -2)
fun_matrix(sectors, 5, -2)
fun_matrix(sectors, 6, -2)
fun_matrix(sectors, 7, -2)
fun_matrix(sectors, 8, -2)
fun_matrix(sectors, 9, -2)
fun_matrix(sectors, 10, -2)
fun_matrix(sectors, 11, -2)
fun_matrix(sectors, 12, -2)
matrix.sort(sectors, colMtx, order)
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | Table |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// Get Table Position
table_pos(p) =>
switch p
"Top Right" => position.top_right
"Middle Right" => position.middle_right
"Bottom Right" => position.bottom_right
"Top Center" => position.top_center
"Middle Center" => position.middle_center
"Bottom Center" => position.bottom_center
"Top Left" => position.top_left
"Middle Left" => position.middle_left
=> position.bottom_left
// Get Table Size
table_size(s) =>
switch s
"Auto" => size.auto
"Huge" => size.huge
"Large" => size.large
"Normal" => size.normal
"Small" => size.small
=> size.tiny
tz = table_size(in_table_size)
// Get Title Column
fun_titlCol(tbl, col, txtCol) =>
table.cell(tbl, col, 0,
text = txtCol,
text_color = title_textCol,
text_size = tz,
bgcolor = background_col)
// Get Cell Values
fun_cell(tbl, row, mtxName, mtxRow) =>
changePerc = math.round(matrix.get(mtxName, mtxRow, 2), 4) * 100
bgColor = changePerc < 0 ?
color.from_gradient(changePerc, -1.5, 0, cell_lowColor, cell_midColor ):
color.from_gradient(changePerc, 0, 1.5, cell_midColor, cell_highColor)
table.cell(tbl, 0, row,
text = sym_short(symbol(matrix.get(mtxName, mtxRow, 0), "symbols")),
text_color = title_textCol, text_size = tz, bgcolor= background_col)
table.cell(tbl, 1, row,
text = symbol(matrix.get(mtxName, mtxRow, 0), "description"),
text_color = cell_textCol, text_size = tz, bgcolor = bgColor)
table.cell(tbl, 2, row,
text = str.tostring(matrix.get(mtxName, mtxRow, 1), "#.##"),
text_color = cell_textCol, text_size = tz, bgcolor = bgColor)
table.cell(tbl, 3, row,
text = str.tostring(changePerc) +"%",
text_color = cell_textCol, text_size = tz, bgcolor = bgColor)
table.cell(tbl, 4, row,
text = str.tostring(matrix.get(mtxName, mtxRow, 3), "#.###"),
text_color = cell_textCol, text_size = tz, bgcolor = bgColor)
// Create Table
var tbl = table.new(table_pos(in_table_pos), 5, 16, frame_width = 5,
border_width = 1, border_color = color.new(title_textCol, 100))
// Fill up Cells.
if barstate.islast
table.clear(tbl, 0, 0, 4, 15)
// columns
fun_titlCol(tbl, 0, "Symbol" )
fun_titlCol(tbl, 1, "Description" )
fun_titlCol(tbl, 2, " Last " )
fun_titlCol(tbl, 3, "Change% \n TF= " + mkt_tf() )
fun_titlCol(tbl, 4, "Correlation\nTo " +
sym_short(chos_symbol == "Custom" ? corr_symbol : syminfo.ticker))
// Leaders
fun_cell(tbl, 1, leaders, 0)
fun_cell(tbl, 2, leaders, 1)
// Sectors
table.cell(tbl, 0, 3,
text= set, text_color = title_textCol, text_size = tz, bgcolor = background_col)
table.merge_cells(tbl, 0, 3, 4, 3)
for i = 4 to 14
fun_cell(tbl, i, sectors, i - 4) |
Moon Launch Alerts Template [Indicator] | https://www.tradingview.com/script/lcZSZDN7-Moon-Launch-Alerts-Template-Indicator/ | zombie76 | https://www.tradingview.com/u/zombie76/ | 41 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zombie76
//@version=5
indicator("ML Alerts Template [indicator]", shorttitle = "ML Alerts Template [indicator]", overlay=false)
/////////////////////////////////////////////////////////////////////////
tradeshorts = input(title='- *Trade Shorts* - ', defval=true)
tradeexitsignals = input(title='- *Trade Exits* -', defval=true)
/////////////////////////////////////////////////////////////////////////
src = (close)
source = (close)
///////////////////// EMA's ////////////////////////
p10=input(title="EMA 1",defval=10)
p200=input(title="EMA 2",defval=200)
ema10=ta.ema(close,p10)
ema200=ta.ema(close,p200)
////////////////////////////////////////////////////
//************* ATR ***************//
lengthatr = input(12, title="ATR Length")
atr = ta.rma(ta.tr(true), lengthatr)
ema = ta.ema(close, lengthatr)
emaPlus1Atr = ema + atr
emaMinus1Atr = ema - atr
//************ END ATR ***********//
////////////////////////////// HIST ///////////////////////////////////
fastLengthHist = input(title='Hist Fast Length',defval=12)
slowLengthHist=input(title='Hist Slow Length',defval=26)
signalLength=input(title='Hist Signal Length',defval=9)
fastMA = ta.ema(source, fastLengthHist)
slowMA = ta.ema(source, slowLengthHist)
macd = fastMA - slowMA
signal = ta.sma(macd, signalLength)
hist = macd - signal
///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////
//// INPUT YOUR BUY/SELL/EXIT SIGNALS HERE: ////
//////////////////////////////////////////////////
tradeups = ema10 > ema10[1] and low > emaMinus1Atr and hist > hist[1] // LONG
tradeexits = tradeexitsignals and (ema10 < ema10[1]) and not tradeups // Exit Long
tradedowns = ((ema10 < ema10[1] and hist < hist[1]) or (high > emaPlus1Atr and close < emaPlus1Atr and close < open and hist < hist[1])) and not tradeups // SHORT
exitshort = low < emaMinus1Atr and close > open and ema10 > ema10[1] and hist > hist[1] // Exit Short
//////////////////////////////////////////////////
//////////////////////////////////////////////////
///////////////////////////////// Buy Sell Line ///////////////////////////////////////////
////////////////////////// DO NOT EDIT ANYTHING BELOW /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Filters out signals if opposite signal is also on:
heikDownColor() => tradedowns
heikUpColor() => tradeups
heikExitColor() => tradeexitsignals and tradeexits
previnashort = 0
previnalong = 0
previnaexit = 0
// Heiki Down Filter //
//short//
inashort_filt = heikDownColor() and tradeshorts and not heikUpColor()
previnashort := inashort_filt ? 1 : heikUpColor() ? -1 : previnashort[1]
inashort2 = previnashort[1] == 1
// Heiki Up Filter //
//long//
inalong_filt = heikUpColor() and not (heikDownColor() or tradeexits)
previnalong := inalong_filt ? 1 : heikDownColor() ? -1 : previnalong[1]
inalong2 = previnalong[1] == 1
// Heiki Exit Filter //
//exit//
inaexit_filt = heikExitColor() and not heikDownColor() and not (heikUpColor() or tradeups)
previnaexit := inaexit_filt ? 1 : heikDownColor() or heikUpColor() ? -1 : previnaexit[1]
inaexit2 = previnaexit[1] == 1
// Heiki Exit Filter 2 //
//exit short//
previnasexits = 0
inasexits_filt = exitshort and (inashort2 or tradedowns) and not tradeups //and not tradedowns[1]
previnasexits := inasexits_filt ? 1 : heikDownColor() or heikUpColor() ? -1 : previnasexits[1]
inasexit2 = previnasexits[1] == 1 //and not exitshort[1]
///////////////////////////////////////////////////////
heikDownColor_filt = (heikDownColor() and not heikUpColor()) or (heikDownColor() and not heikExitColor())
heikUpColor_filt = tradeups or ((heikUpColor() or inalong2) and not (tradeexits or tradedowns or (inaexit2 and not tradeups)))
heikExitColor_filt = heikExitColor() and not (heikDownColor_filt or tradeups)
heikNeuColor_filt = (heikUpColor() or heikDownColor() or tradeups)
prev5 = 0
prev5 := (heikUpColor_filt and (not (tradedowns or tradeexits))) or tradeups ? 1000 : (tradeshorts and tradedowns) or not (inashort2 and (exitshort or inasexit2)) and (tradeshorts and (inashort2 or heikDownColor_filt)) ? -1000 : not (tradeups or heikUpColor_filt) and (((not tradeshorts and (heikExitColor_filt)) or (inashort2 and exitshort) or (tradeshorts and tradeexits and heikUpColor_filt and not (heikDownColor_filt)) or (tradeshorts and tradeexits and not heikDownColor_filt and not heikUpColor_filt))) ? 0 : prev5[0]
plot(prev5, color=color.new(color.aqua, 10), style=plot.style_stepline, title='Trade Line')
shortdata2 = prev5[0] == -1000 and (heikDownColor_filt or inashort2) //and heikNeuColor_filt
longdata2 = prev5[0] == 1000 and (heikUpColor_filt or not (heikExitColor_filt or heikDownColor_filt))
exitdata2 = prev5[0] == 0 and not (heikNeuColor_filt or heikDownColor_filt)
////////////////////// END Buy Sell Line ///////////////////////////////////
/////////////////////////////////// Plot Dots //////////////////////////////
plotshape(longdata2 and not tradeexits, style=shape.diamond, location=location.bottom, color=color.new(color.lime, 50)) //LONG
plotshape(shortdata2 and tradeshorts, style=shape.diamond, location=location.bottom, color=color.new(color.red, 50)) // SHORT
plotshape(exitdata2 and not (tradeups or heikUpColor_filt), style=shape.diamond, location=location.bottom, color=color.new(color.purple, 50)) // EXIT
plotshape(tradeups and not tradeups[1], style=shape.diamond, location=location.bottom, color=color.new(color.lime, 0)) //LONG
plotshape(tradedowns and tradeshorts and not tradedowns[1], style=shape.diamond, location=location.bottom, color=color.new(color.red, 0)) // SHORT
plotshape(prev5[0] == 0 and (prev5[1] > 0 or prev5[1] < 0) and not (tradeups or heikUpColor_filt), style=shape.diamond, location=location.bottom, color=color.new(color.white, 70))
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////
GoLong = prev5[0] > 0 and prev5[1] < 900
GoShort = prev5[0] < 0 and prev5[1] > -900
GoExit = prev5[0] == 0 and (prev5[1] > 0 or prev5[1] < 0)
///////////// Alerts ////////////////
alertcondition(condition=GoLong,
title="1_Warp LONG",
message="LONG *")
alertcondition(condition=GoShort and tradeshorts,
title="2_Warp SHORT",
message="SHORT *")
alertcondition(condition=GoExit,
title="3_EXIT Warp",
message="EXIT *")
////// Alerts Add to Position //////
alertcondition(condition=tradeups and not exitdata2[1] and not tradeups[1],
title="4_Warp Add to LONG",
message="LONG *increase")
alertcondition(condition=tradedowns and tradeshorts and not exitdata2[1] and not tradedowns[1],
title="5_Warp Add to SHORT",
message="SHORT *increase")
//////////////// END ALL /////////////////////
|
FDAX Impulse Times | https://www.tradingview.com/script/sVIt4hW4-FDAX-Impulse-Times/ | reichel-holding | https://www.tradingview.com/u/reichel-holding/ | 18 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © reichel-holding
//@version=5
indicator("Impulse Times", overlay=true)
tgw1 = timestamp(year, month, dayofmonth,9,0,0)
tgw2 = timestamp(year, month, dayofmonth,16,0,0)
tgw3 = timestamp(year, month, dayofmonth,21,0,0)
black = color.rgb(0, 0, 0, 0)
green = color.new(#66bb6a, 65)
yellow = color.new(#e2a76b, 65)
if(timeframe.period == "1")
//var barUpLeftDef = int(ta.lowest(300)[1]) - 100
barUpLeft = input.int(title="Y-Position of Impulse bars", defval=14140)
if (time == tgw1 or time == tgw2 or time == tgw3)
line.new(bar_index, close, bar_index, high*2, extend = extend.both, color=black, style=line.style_dashed, width=2)
firstBarTimeStart = timestamp(year, month, dayofmonth,8,30,0)
if(time == firstBarTimeStart and not na(timeframe.period))
lastIndex= (2 * 60 / timeframe.multiplier) + bar_index
box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=green, border_width=0)
secondBarTimeStart = timestamp(year, month, dayofmonth,10,30,0)
if(time == secondBarTimeStart and not na(timeframe.period))
lastIndex= (5 * 60 / timeframe.multiplier) + bar_index
box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=yellow, border_width=0)
thirdBarTimeStart = timestamp(year, month, dayofmonth,15,30,0)
if(time == thirdBarTimeStart and not na(timeframe.period))
lastIndex= (90 / timeframe.multiplier) + bar_index
box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=green, border_width=0)
fourthBarTimeStart = timestamp(year, month, dayofmonth,17,00,0)
if(time == fourthBarTimeStart and not na(timeframe.period))
lastIndex= (210 / timeframe.multiplier) + bar_index
box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=yellow, border_width=0)
fifthBarTimeStart = timestamp(year, month, dayofmonth,20,30,0)
if(time == fifthBarTimeStart and not na(timeframe.period))
lastIndex= (90 / timeframe.multiplier) + bar_index
box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=green, border_width=0)
|
Artharjan INDIA VIX v/s Nifty Volatility Dashboard | https://www.tradingview.com/script/mfZwFDr0-Artharjan-INDIA-VIX-v-s-Nifty-Volatility-Dashboard/ | rsdesai005 | https://www.tradingview.com/u/rsdesai005/ | 170 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rsdesai005
//@version=5
indicator(title= "Artharjan INDIA VIX v/s Nifty Volatility Dashboard", shorttitle = 'AVIX', overlay=true)
comparativeTickerId = input.symbol(defval="NSE:INDIAVIX", title="Comparative Symbol")
NiftyTickerId = input.symbol(defval="NSE:NIFTY", title="NIFTY 50 Benchmark Index")
// The following built-in color variables can be used to avoid hexadecimal color literals: color.black, color.silver,
//color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange.
TableLocation = input.string("top_right", title='Select Table Position',options=["top_left","top_center","top_right","middle_left","middle_center","middle_right","bottom_left","bottom_center","bottom_right"] , tooltip="Default location is at Centre Top")
TableTextSize = input.string("Auto", title='Select Table Text Size',options=["Auto","Huge","Large","Normal","Small","Tiny"] , tooltip="Default Text Size is Auto")
thickness = 2
TableWidth = 0
pos1 = str.pos(comparativeTickerId, ":")
pos2 = str.pos(NiftyTickerId, ":")
AnnualVol = request.security(comparativeTickerId, "D", close)
AnnualVolPrev = request.security(comparativeTickerId, "D", close[1])
NiftyCurrentValue = request.security(NiftyTickerId, "D", close)
NiftyPrevValue = request.security(NiftyTickerId, "D", close[1])
VixBGColor = AnnualVol > AnnualVolPrev? #06c806 : #ff0000
VixFontColor = AnnualVol > AnnualVolPrev? color.black : color.white
NiftyBGColor = NiftyCurrentValue > NiftyPrevValue? #06c806 : #ff0000
NiftyFontColor = NiftyCurrentValue > NiftyPrevValue? color.black : color.white
QuarterlyVol = AnnualVol / math.sqrt(4)
MonthlyVol = AnnualVol / math.sqrt(12)
WeeklyVol = AnnualVol / math.sqrt(52)
DailyVol = AnnualVol / math.sqrt(252)
HourlyVol = AnnualVol / math.sqrt(252 * 375/60)
NiftyYMax = NiftyCurrentValue * ( 1 + AnnualVol/100)
NiftyYMin = NiftyCurrentValue * ( 1 - AnnualVol/100)
NiftyQMax = NiftyCurrentValue * ( 1 + QuarterlyVol/100)
NiftyQMin = NiftyCurrentValue * ( 1 - QuarterlyVol/100)
NiftyMMax = NiftyCurrentValue * ( 1 + MonthlyVol/100)
NiftyMMin = NiftyCurrentValue * ( 1 - MonthlyVol/100)
NiftyWMax = NiftyCurrentValue * ( 1 + WeeklyVol/100)
NiftyWMin = NiftyCurrentValue * ( 1 - WeeklyVol/100)
NiftyDMax = NiftyCurrentValue * ( 1 + DailyVol/100)
NiftyDMin = NiftyCurrentValue * ( 1 - DailyVol/100)
NiftyHMax = NiftyCurrentValue * ( 1 + HourlyVol/100)
NiftyHMin = NiftyCurrentValue * ( 1 - HourlyVol/100)
AssignedPosition = switch TableLocation
"top_left" => position.top_left
"top_center" => position.top_center
"top_right" => position.top_right
"middle_left" => position.middle_left
"middle_center" => position.middle_center
"middle_right" => position.middle_right
"bottom_left" => position.bottom_left
"bottom_center" => position.bottom_center
"bottom_right" => position.bottom_right
CellTextSize = switch TableTextSize
"Auto" => size.auto
"Huge" => size.huge
"Large" => size.large
"Normal" => size.normal
"Small" => size.small
"Tiny" => size.tiny
//var table t = table.new(position.bottom_center, 4, 8, border_width=thickness)
var table t = table.new(AssignedPosition, 4, 9, frame_width=thickness, border_width=thickness,frame_color=color.navy, border_color=color.white)
if barstate.islast
table.cell(t, 0, 0, 'Reference Symbol', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 0, 1, str.substring(comparativeTickerId,pos1+1), width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 0, 2, 'Forecast Period', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 0, 3, 'Yearly', width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 0, 4, 'Quarterly', width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 0, 5, 'Monthly', width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 0, 6, 'Weekly', width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 0, 7, 'Daily', width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 0, 8, 'Hourly', width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 1, 0, 'Current Value', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 1, 1, str.tostring(math.round(AnnualVol,2)) + " %", width=TableWidth, text_color=VixFontColor, bgcolor=VixBGColor, text_size=CellTextSize)
table.cell(t, 1, 2, 'Forecast Volatility', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 1, 3, "+/- " + str.tostring(math.round(AnnualVol, 2)) + " %", width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 1, 4, "+/- " + str.tostring(math.round(QuarterlyVol, 2)) + " %", width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 1, 5, "+/- " + str.tostring(math.round(MonthlyVol, 2)) + " %", width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 1, 6, "+/- " + str.tostring(math.round(WeeklyVol, 2)) + " %", width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 1, 7, "+/- " + str.tostring(math.round(DailyVol, 2)) + " %", width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 1, 8, "+/- " + str.tostring(math.round(HourlyVol, 2)) + " %", width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 2, 0, 'Benchmark Index', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 2, 1, str.substring(NiftyTickerId,pos2+1), width=TableWidth, text_color=color.white, bgcolor=#388e3c, text_size=CellTextSize)
table.cell(t, 2, 2, 'Min Range', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 2, 3, str.tostring(math.round(NiftyYMin)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 2, 4, str.tostring(math.round(NiftyQMin)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 2, 5, str.tostring(math.round(NiftyMMin)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 2, 6, str.tostring(math.round(NiftyWMin)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 2, 7, str.tostring(math.round(NiftyDMin)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 2, 8, str.tostring(math.round(NiftyHMin)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 3, 0, 'Current Value', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 3, 1, str.tostring(math.round(NiftyCurrentValue)), width=TableWidth, text_color=NiftyFontColor, bgcolor=NiftyBGColor, text_size=CellTextSize)
table.cell(t, 3, 2, 'Max Range', width=TableWidth, text_color=color.white, bgcolor=#340370, text_size=CellTextSize)
table.cell(t, 3, 3, str.tostring(math.round(NiftyYMax)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 3, 4, str.tostring(math.round(NiftyQMax)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 3, 5, str.tostring(math.round(NiftyMMax)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 3, 6, str.tostring(math.round(NiftyWMax)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 3, 7, str.tostring(math.round(NiftyDMax)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
table.cell(t, 3, 8, str.tostring(math.round(NiftyHMax)), width=TableWidth, text_color=color.navy, bgcolor=#bbd9fb, text_size=CellTextSize)
|
Recessions [TXMC] | https://www.tradingview.com/script/J141DSF0-Recessions-TXMC/ | TXMC | https://www.tradingview.com/u/TXMC/ | 78 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TXMC
//@version=5
indicator("Recessions [TXMC]", overlay=true)
src = request.quandl("FRED/USRECD") // Recession data from Federal Reserve
bool = src == 1 ? true : false // if value is 1, call True (means there is a recession)
// Band color
color band = input.color(color.new(#fe4a49,70), title="Recession Band")
// Plot
bgcolor(bool ? band : na) |
7-10 flattener trade | https://www.tradingview.com/script/8EoNZyPC-7-10-flattener-trade/ | abhishekjoshi1493 | https://www.tradingview.com/u/abhishekjoshi1493/ | 4 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © abhishekjoshi1493
//@version=5
indicator("My script")
fiveyytm = request.security(symbol = "TVC:IN05Y", timeframe = timeframe.period, expression = close)
tenyytm = request.security(symbol = "TVC:IN10Y", timeframe = timeframe.period, expression = close)
sevenyytm = request.security(symbol = "TVC:IN07Y", timeframe = timeframe.period, expression = close)
twoyytm = request.security(symbol = "TVC:IN02Y", timeframe = timeframe.period, expression = close)
//plot(tenyytm-fiveyytm)
plot(tenyytm-sevenyytm)
//plot(sevenyytm)
//plot(tenyytm-twoyytm)
|
Y/Q/M/W aVWAP Bands | https://www.tradingview.com/script/3Bsjz8h2-Y-Q-M-W-aVWAP-Bands/ | crypto_rife | https://www.tradingview.com/u/crypto_rife/ | 289 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © crypto_rife
//@version=5
indicator("VWAP Bands", overlay=true)
tf = input.timeframe("1M", "Time Frame", options=['1W', '1M', '3M', '12M'])
showVwap = input.bool(true, title="Show VWAP")
showDev = input.bool(true, title="Show VWAP St Dev Band")
stdev = input.int(1, title="St Dev")
bgColor = color.new(color.gray, 90)
borderColor = color.new(color.gray, 100)
lineColor = color.new(color.blue, 50)
t = time(tf)
start = na(t[1]) or t > t[1]
var pvwapLine = line(na)
var pvwapBox = box(na)
pvwap = float(na)
pupper = float(na)
plower = float(na)
[vwap, upper, lower] = ta.vwap(close, start, stdev)
pvwap := start ? vwap[1] : pvwap[1]
pupper := start ? upper[1] : pupper[1]
plower := start ? lower[1] : plower[1]
if (start)
line.delete(pvwapLine)
box.delete(pvwapBox)
pvwapLine := line.new(x1=bar_index-1, y1=vwap[1], x2=bar_index+1, y2=vwap[1], extend=extend.right, style=line.style_dashed, color=lineColor)
pvwapBox := box.new(bar_index, pupper, bar_index+1, (plower), extend=extend.right, border_color=borderColor, bgcolor=bgColor)
plot(vwap, title="VWAP", color=lineColor)
MU1=plot(upper, title="VWAP Upper Band", color=color.red, transp=100)
MD1=plot(lower, title="VWAP Lower Band", color=color.red, transp=100)
fill(MD1,MU1, color=bgColor, transp=93, title="Inner Band") |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.