Reputation: 502
I am trying to use the indicator CM_Williams_Vix_Fix https://www.tradingview.com/script/og7JPrRA-CM-Williams-Vix-Fix-Finds-Market-Bottoms/ and convert it to screener for 40 stocks to find stocks having a CM_Williams_Vix_Fix green bar in the latest candle of the day (1D timeframe)
I'm using this code
//@version=4
study("Screener CM_Williams_Vix_Fix", overlay=false)
// Symbols
s1 = input('MIL:PRM', type=input.symbol)
s2 = input('MIL:GO', type=input.symbol)
s3 = input('MIL:VTY', type=input.symbol)
s4 = input('MIL:SOF', type=input.symbol)
s5 = input('MIL:ECK', type=input.symbol)
s6 = input('MIL:RETI', type=input.symbol)
s7 = input('MIL:ENT', type=input.symbol)
s8 = input('MIL:ITW', type=input.symbol)
s9 = input('MIL:SOS', type=input.symbol)
s10 = input('MIL:YSFT', type=input.symbol)
s11 = input('MIL:TNXT', type=input.symbol)
s12 = input('MIL:DAL', type=input.symbol)
s13 = input('MIL:DGV', type=input.symbol)
s14 = input('MIL:WIIT', type=input.symbol)
s15 = input('MIL:LIT', type=input.symbol)
s16 = input('MIL:AVIO', type=input.symbol)
s17 = input('MIL:SICT', type=input.symbol)
s18 = input('MIL:PITE', type=input.symbol)
s19 = input('MIL:BEST', type=input.symbol)
s20 = input('MIL:ITD', type=input.symbol)
s21 = input('MIL:ETH', type=input.symbol)
s22 = input('MIL:TIS', type=input.symbol)
s23 = input('MIL:CY4', type=input.symbol)
s24 = input('MIL:EXSY', type=input.symbol)
s25 = input('MIL:BEC', type=input.symbol)
s26 = input('MIL:RLT', type=input.symbol)
s27 = input('MIL:MAIL', type=input.symbol)
s28 = input('MIL:OSA', type=input.symbol)
s29 = input('MIL:CYB', type=input.symbol)
s30 = input('MIL:OS', type=input.symbol)
s31 = input('MIL:ELES', type=input.symbol)
s32 = input('MIL:NSP', type=input.symbol)
s33 = input('MIL:DOX', type=input.symbol)
s34 = input('MIL:PLT', type=input.symbol)
s35 = input('MIL:EPR', type=input.symbol)
s36 = input('MIL:MAPS', type=input.symbol)
s37 = input('MIL:SOU', type=input.symbol)
s38 = input('MIL:PRT', type=input.symbol)
s39 = input('MIL:PIRC', type=input.symbol)
s40 = input('MIL:ENEL', type=input.symbol)
///////////////
// FUNCTIONS //
pd = input(22, title="LookBack Period Standard Deviation High")
bbl = input(20, title="Bolinger Band Length")
mult = input(2.0 , minval=1, maxval=5, title="Bollinger Band Standard Devaition Up")
lb = input(50 , title="Look Back Period Percentile High")
ph = input(.85, title="Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%")
pl = input(1.01, title="Lowest Percentile - 1.10=90%, 1.05=95%, 1.01=99%")
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100
sDev = mult * stdev(wvf, bbl)
midLine = sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (highest(wvf, lb)) * ph
rangeLow = (lowest(wvf, lb)) * pl
// Screener Function
screenerFunc() =>
cond = wvf >= upperBand or wvf >= rangeHigh
[wvf, cond]
// Rounding Function
roundn(x, n) =>
mult = 1
if n != 0
for i = 1 to abs(n)
mult := mult * 10
n >= 0 ? round(x * mult) / mult : round(x / mult) * mult
///////////////////////////////////////
// Running Functions for all sybmols //
[v1, c1] = security(s1, timeframe.period, screenerFunc())
[v2, c2] = security(s2, timeframe.period, screenerFunc())
[v3, c3] = security(s3, timeframe.period, screenerFunc())
[v4, c4] = security(s4, timeframe.period, screenerFunc())
[v5, c5] = security(s5, timeframe.period, screenerFunc())
[v6, c6] = security(s6, timeframe.period, screenerFunc())
[v7, c7] = security(s7, timeframe.period, screenerFunc())
[v8, c8] = security(s8, timeframe.period, screenerFunc())
[v9, c9] = security(s9, timeframe.period, screenerFunc())
[v10, c10] = security(s10, timeframe.period, screenerFunc())
[v11, c11] = security(s11, timeframe.period, screenerFunc())
[v12, c12] = security(s12, timeframe.period, screenerFunc())
[v13, c13] = security(s13, timeframe.period, screenerFunc())
[v14, c14] = security(s14, timeframe.period, screenerFunc())
[v15, c15] = security(s15, timeframe.period, screenerFunc())
[v16, c16] = security(s16, timeframe.period, screenerFunc())
[v17, c17] = security(s17, timeframe.period, screenerFunc())
[v18, c18] = security(s18, timeframe.period, screenerFunc())
[v19, c19] = security(s19, timeframe.period, screenerFunc())
[v20, c20] = security(s20, timeframe.period, screenerFunc())
[v21, c21] = security(s21, timeframe.period, screenerFunc())
[v22, c22] = security(s22, timeframe.period, screenerFunc())
[v23, c23] = security(s23, timeframe.period, screenerFunc())
[v24, c24] = security(s24, timeframe.period, screenerFunc())
[v25, c25] = security(s25, timeframe.period, screenerFunc())
[v26, c26] = security(s26, timeframe.period, screenerFunc())
[v27, c27] = security(s27, timeframe.period, screenerFunc())
[v28, c28] = security(s28, timeframe.period, screenerFunc())
[v29, c29] = security(s29, timeframe.period, screenerFunc())
[v30, c30] = security(s30, timeframe.period, screenerFunc())
[v31, c31] = security(s31, timeframe.period, screenerFunc())
[v32, c32] = security(s32, timeframe.period, screenerFunc())
[v33, c33] = security(s33, timeframe.period, screenerFunc())
[v34, c34] = security(s34, timeframe.period, screenerFunc())
[v35, c35] = security(s35, timeframe.period, screenerFunc())
[v36, c36] = security(s36, timeframe.period, screenerFunc())
[v37, c37] = security(s37, timeframe.period, screenerFunc())
[v38, c38] = security(s38, timeframe.period, screenerFunc())
[v39, c39] = security(s39, timeframe.period, screenerFunc())
[v40, c40] = security(s40, timeframe.period, screenerFunc())
////////////////////
// Screener label //
scr_label = ''
scr_label := c1 ? scr_label + s1 + ' ' + tostring(roundn(v1, 3)) + ' ' : scr_label
scr_label := c2 ? scr_label + s2 + ' ' + tostring(roundn(v2, 3)) + ' ' : scr_label
scr_label := c3 ? scr_label + s3 + ' ' + tostring(roundn(v3, 3)) + ' ' : scr_label
scr_label := c4 ? scr_label + s4 + ' ' + tostring(roundn(v4, 3)) + ' ' : scr_label
scr_label := c5 ? scr_label + s5 + ' ' + tostring(roundn(v5, 3)) + ' ' : scr_label
scr_label := c6 ? scr_label + s6 + ' ' + tostring(roundn(v6, 3)) + ' ' : scr_label
scr_label := c7 ? scr_label + s7 + ' ' + tostring(roundn(v7, 3)) + ' ' : scr_label
scr_label := c8 ? scr_label + s8 + ' ' + tostring(roundn(v8, 3)) + ' ' : scr_label
scr_label := c9 ? scr_label + s9 + ' ' + tostring(roundn(v9, 3)) + ' ' : scr_label
scr_label := c10 ? scr_label + s10 + ' ' + tostring(roundn(v10, 3)) + ' ' : scr_label
scr_label := c11 ? scr_label + s11 + ' ' + tostring(roundn(v11, 3)) + ' ' : scr_label
scr_label := c12 ? scr_label + s12 + ' ' + tostring(roundn(v12, 3)) + ' ' : scr_label
scr_label := c13 ? scr_label + s13 + ' ' + tostring(roundn(v13, 3)) + ' ' : scr_label
scr_label := c14 ? scr_label + s14 + ' ' + tostring(roundn(v14, 3)) + ' ' : scr_label
scr_label := c15 ? scr_label + s15 + ' ' + tostring(roundn(v15, 3)) + ' ' : scr_label
scr_label := c16 ? scr_label + s16 + ' ' + tostring(roundn(v16, 3)) + ' ' : scr_label
scr_label := c17 ? scr_label + s17 + ' ' + tostring(roundn(v17, 3)) + ' ' : scr_label
scr_label := c18 ? scr_label + s18 + ' ' + tostring(roundn(v18, 3)) + ' ' : scr_label
scr_label := c19 ? scr_label + s19 + ' ' + tostring(roundn(v19, 3)) + ' ' : scr_label
scr_label := c20 ? scr_label + s20 + ' ' + tostring(roundn(v20, 3)) + ' ' : scr_label
scr_label := c21 ? scr_label + s21 + ' ' + tostring(roundn(v21, 3)) + ' ' : scr_label
scr_label := c22 ? scr_label + s22 + ' ' + tostring(roundn(v22, 3)) + ' ' : scr_label
scr_label := c23 ? scr_label + s23 + ' ' + tostring(roundn(v23, 3)) + ' ' : scr_label
scr_label := c24 ? scr_label + s24 + ' ' + tostring(roundn(v24, 3)) + ' ' : scr_label
scr_label := c25 ? scr_label + s25 + ' ' + tostring(roundn(v25, 3)) + ' ' : scr_label
scr_label := c26 ? scr_label + s26 + ' ' + tostring(roundn(v26, 3)) + ' ' : scr_label
scr_label := c27 ? scr_label + s27 + ' ' + tostring(roundn(v27, 3)) + ' ' : scr_label
scr_label := c28 ? scr_label + s28 + ' ' + tostring(roundn(v28, 3)) + ' ' : scr_label
scr_label := c29 ? scr_label + s29 + ' ' + tostring(roundn(v29, 3)) + ' ' : scr_label
scr_label := c30 ? scr_label + s30 + ' ' + tostring(roundn(v30, 3)) + ' ' : scr_label
scr_label := c31 ? scr_label + s31 + ' ' + tostring(roundn(v31, 3)) + ' ' : scr_label
scr_label := c32 ? scr_label + s32 + ' ' + tostring(roundn(v32, 3)) + ' ' : scr_label
scr_label := c33 ? scr_label + s33 + ' ' + tostring(roundn(v33, 3)) + ' ' : scr_label
scr_label := c34 ? scr_label + s34 + ' ' + tostring(roundn(v34, 3)) + ' ' : scr_label
scr_label := c35 ? scr_label + s35 + ' ' + tostring(roundn(v35, 3)) + ' ' : scr_label
scr_label := c36 ? scr_label + s36 + ' ' + tostring(roundn(v36, 3)) + ' ' : scr_label
scr_label := c37 ? scr_label + s37 + ' ' + tostring(roundn(v37, 3)) + ' ' : scr_label
scr_label := c38 ? scr_label + s38 + ' ' + tostring(roundn(v38, 3)) + ' ' : scr_label
scr_label := c39 ? scr_label + s39 + ' ' + tostring(roundn(v39, 3)) + ' ' : scr_label
scr_label := c40 ? scr_label + s40 + ' ' + tostring(roundn(v40, 3)) + ' ' : scr_label
// Adding #telegram hashtag for alertatron
//scr_label := scr_label + "\n Ricerca titoli"
scr_label := scr_label + ""
// Plot Label
lab_l = label.new(
bar_index, 0, scr_label,
color=color.red,
textcolor=color.yellow,
style = label.style_labeldown,
yloc = yloc.price)
label.delete(lab_l[1])
Using the script above I would search using timeframe 1D , all the stocks which have a green bar (a CM_Williams_Vix_Fix green bar) in the really latest candle of the day. But it does not seem to work as expected , what is wrong ?
Upvotes: 0
Views: 675
Reputation: 6905
Your script works. It just takes some time to load because of the many security calls.
I've adjusted it so that it only draws the label on the last bar (no need to draw inbetween).
Also, I've created a function to construct the labels.
//@version=4
study("Screener CM_Williams_Vix_Fix", overlay=false)
// Symbols
s1 = input('MIL:PRM', type=input.symbol)
s2 = input('MIL:GO', type=input.symbol)
s3 = input('MIL:VTY', type=input.symbol)
s4 = input('MIL:SOF', type=input.symbol)
s5 = input('MIL:ECK', type=input.symbol)
s6 = input('MIL:RETI', type=input.symbol)
s7 = input('MIL:ENT', type=input.symbol)
s8 = input('MIL:ITW', type=input.symbol)
s9 = input('MIL:SOS', type=input.symbol)
s10 = input('MIL:YSFT', type=input.symbol)
s11 = input('MIL:TNXT', type=input.symbol)
s12 = input('MIL:DAL', type=input.symbol)
s13 = input('MIL:DGV', type=input.symbol)
s14 = input('MIL:WIIT', type=input.symbol)
s15 = input('MIL:LIT', type=input.symbol)
s16 = input('MIL:AVIO', type=input.symbol)
s17 = input('MIL:SICT', type=input.symbol)
s18 = input('MIL:PITE', type=input.symbol)
s19 = input('MIL:BEST', type=input.symbol)
s20 = input('MIL:ITD', type=input.symbol)
s21 = input('MIL:ETH', type=input.symbol)
s22 = input('MIL:TIS', type=input.symbol)
s23 = input('MIL:CY4', type=input.symbol)
s24 = input('MIL:EXSY', type=input.symbol)
s25 = input('MIL:BEC', type=input.symbol)
s26 = input('MIL:RLT', type=input.symbol)
s27 = input('MIL:MAIL', type=input.symbol)
s28 = input('MIL:OSA', type=input.symbol)
s29 = input('MIL:CYB', type=input.symbol)
s30 = input('MIL:OS', type=input.symbol)
s31 = input('MIL:ELES', type=input.symbol)
s32 = input('MIL:NSP', type=input.symbol)
s33 = input('MIL:DOX', type=input.symbol)
s34 = input('MIL:PLT', type=input.symbol)
s35 = input('MIL:EPR', type=input.symbol)
s36 = input('MIL:MAPS', type=input.symbol)
s37 = input('MIL:SOU', type=input.symbol)
s38 = input('MIL:PRT', type=input.symbol)
s39 = input('MIL:PIRC', type=input.symbol)
s40 = input('MIL:ENEL', type=input.symbol)
///////////////
// FUNCTIONS //
pd = input(22, title="LookBack Period Standard Deviation High")
bbl = input(20, title="Bolinger Band Length")
mult = input(2.0 , minval=1, maxval=5, title="Bollinger Band Standard Devaition Up")
lb = input(50 , title="Look Back Period Percentile High")
ph = input(.85, title="Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%")
pl = input(1.01, title="Lowest Percentile - 1.10=90%, 1.05=95%, 1.01=99%")
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100
sDev = mult * stdev(wvf, bbl)
midLine = sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (highest(wvf, lb)) * ph
rangeLow = (lowest(wvf, lb)) * pl
// Screener Function
screenerFunc() =>
cond = wvf >= upperBand or wvf >= rangeHigh
[wvf, cond]
// Rounding Function
roundn(x, n) =>
mult_local = 1
if n != 0
for i = 1 to abs(n)
mult_local := mult_local * 10
n >= 0 ? round(x * mult_local) / mult_local : round(x / mult_local) * mult_local
///////////////////////////////////////
// Running Functions for all sybmols //
[v1, c1] = security(s1, timeframe.period, screenerFunc())
[v2, c2] = security(s2, timeframe.period, screenerFunc())
[v3, c3] = security(s3, timeframe.period, screenerFunc())
[v4, c4] = security(s4, timeframe.period, screenerFunc())
[v5, c5] = security(s5, timeframe.period, screenerFunc())
[v6, c6] = security(s6, timeframe.period, screenerFunc())
[v7, c7] = security(s7, timeframe.period, screenerFunc())
[v8, c8] = security(s8, timeframe.period, screenerFunc())
[v9, c9] = security(s9, timeframe.period, screenerFunc())
[v10, c10] = security(s10, timeframe.period, screenerFunc())
[v11, c11] = security(s11, timeframe.period, screenerFunc())
[v12, c12] = security(s12, timeframe.period, screenerFunc())
[v13, c13] = security(s13, timeframe.period, screenerFunc())
[v14, c14] = security(s14, timeframe.period, screenerFunc())
[v15, c15] = security(s15, timeframe.period, screenerFunc())
[v16, c16] = security(s16, timeframe.period, screenerFunc())
[v17, c17] = security(s17, timeframe.period, screenerFunc())
[v18, c18] = security(s18, timeframe.period, screenerFunc())
[v19, c19] = security(s19, timeframe.period, screenerFunc())
[v20, c20] = security(s20, timeframe.period, screenerFunc())
[v21, c21] = security(s21, timeframe.period, screenerFunc())
[v22, c22] = security(s22, timeframe.period, screenerFunc())
[v23, c23] = security(s23, timeframe.period, screenerFunc())
[v24, c24] = security(s24, timeframe.period, screenerFunc())
[v25, c25] = security(s25, timeframe.period, screenerFunc())
[v26, c26] = security(s26, timeframe.period, screenerFunc())
[v27, c27] = security(s27, timeframe.period, screenerFunc())
[v28, c28] = security(s28, timeframe.period, screenerFunc())
[v29, c29] = security(s29, timeframe.period, screenerFunc())
[v30, c30] = security(s30, timeframe.period, screenerFunc())
[v31, c31] = security(s31, timeframe.period, screenerFunc())
[v32, c32] = security(s32, timeframe.period, screenerFunc())
[v33, c33] = security(s33, timeframe.period, screenerFunc())
[v34, c34] = security(s34, timeframe.period, screenerFunc())
[v35, c35] = security(s35, timeframe.period, screenerFunc())
[v36, c36] = security(s36, timeframe.period, screenerFunc())
[v37, c37] = security(s37, timeframe.period, screenerFunc())
[v38, c38] = security(s38, timeframe.period, screenerFunc())
[v39, c39] = security(s39, timeframe.period, screenerFunc())
[v40, c40] = security(s40, timeframe.period, screenerFunc())
////////////////////
// Screener label //
f_buildLabel(_c, _s, _v) =>
_c ? _s + ' ' + tostring(roundn(_v, 3)) + '\n' : ''
if barstate.islast
scr_label = ''
scr_label := scr_label + f_buildLabel(c1, s1, v1)
scr_label := scr_label + f_buildLabel(c2, s2, v2)
scr_label := scr_label + f_buildLabel(c3, s3, v3)
scr_label := scr_label + f_buildLabel(c4, s4, v4)
scr_label := scr_label + f_buildLabel(c5, s5, v5)
scr_label := scr_label + f_buildLabel(c6, s6, v6)
scr_label := scr_label + f_buildLabel(c7, s7, v7)
scr_label := scr_label + f_buildLabel(c8, s8, v8)
scr_label := scr_label + f_buildLabel(c9, s9, v9)
scr_label := scr_label + f_buildLabel(c10, s10, v10)
scr_label := scr_label + f_buildLabel(c11, s11, v11)
scr_label := scr_label + f_buildLabel(c12, s12, v12)
scr_label := scr_label + f_buildLabel(c13, s13, v13)
scr_label := scr_label + f_buildLabel(c14, s14, v14)
scr_label := scr_label + f_buildLabel(c15, s15, v15)
scr_label := scr_label + f_buildLabel(c16, s16, v16)
scr_label := scr_label + f_buildLabel(c17, s17, v17)
scr_label := scr_label + f_buildLabel(c18, s18, v18)
scr_label := scr_label + f_buildLabel(c19, s19, v19)
scr_label := scr_label + f_buildLabel(c20, s20, v20)
scr_label := scr_label + f_buildLabel(c21, s21, v21)
scr_label := scr_label + f_buildLabel(c22, s22, v22)
scr_label := scr_label + f_buildLabel(c23, s23, v23)
scr_label := scr_label + f_buildLabel(c24, s24, v24)
scr_label := scr_label + f_buildLabel(c25, s25, v25)
scr_label := scr_label + f_buildLabel(c26, s26, v26)
scr_label := scr_label + f_buildLabel(c27, s27, v27)
scr_label := scr_label + f_buildLabel(c28, s28, v28)
scr_label := scr_label + f_buildLabel(c29, s29, v29)
scr_label := scr_label + f_buildLabel(c30, s30, v30)
scr_label := scr_label + f_buildLabel(c31, s31, v31)
scr_label := scr_label + f_buildLabel(c32, s32, v32)
scr_label := scr_label + f_buildLabel(c33, s33, v33)
scr_label := scr_label + f_buildLabel(c34, s34, v34)
scr_label := scr_label + f_buildLabel(c35, s35, v35)
scr_label := scr_label + f_buildLabel(c36, s36, v36)
scr_label := scr_label + f_buildLabel(c37, s37, v37)
scr_label := scr_label + f_buildLabel(c38, s38, v38)
scr_label := scr_label + f_buildLabel(c39, s39, v39)
scr_label := scr_label + f_buildLabel(c40, s40, v40)
// Adding #telegram hashtag for alertatron
//scr_label := scr_label + "\n Ricerca titoli"
scr_label := scr_label + ""
// Plot Label
lab_l = label.new(
bar_index, 0, scr_label,
color=color.red,
textcolor=color.yellow,
style = label.style_labeldown,
yloc = yloc.price)
// label.delete(lab_l[1])
It yields this:
Update 2 feb 2012: Label now includes upperBand
, rangeHigh
, wvf
.
//@version=4
study("Screener CM_Williams_Vix_Fix", overlay=false)
// Symbols
s1 = input('MIL:PRM', type=input.symbol)
s2 = input('MIL:GO', type=input.symbol)
s3 = input('MIL:VTY', type=input.symbol)
s4 = input('MIL:SOF', type=input.symbol)
s5 = input('MIL:ECK', type=input.symbol)
s6 = input('MIL:RETI', type=input.symbol)
s7 = input('MIL:ENT', type=input.symbol)
s8 = input('MIL:ITW', type=input.symbol)
s9 = input('MIL:SOS', type=input.symbol)
s10 = input('MIL:YSFT', type=input.symbol)
s11 = input('MIL:TNXT', type=input.symbol)
s12 = input('MIL:DAL', type=input.symbol)
s13 = input('MIL:DGV', type=input.symbol)
s14 = input('MIL:WIIT', type=input.symbol)
s15 = input('MIL:LIT', type=input.symbol)
s16 = input('MIL:AVIO', type=input.symbol)
s17 = input('MIL:SICT', type=input.symbol)
s18 = input('MIL:PITE', type=input.symbol)
s19 = input('MIL:BEST', type=input.symbol)
s20 = input('MIL:ITD', type=input.symbol)
s21 = input('MIL:ETH', type=input.symbol)
s22 = input('MIL:TIS', type=input.symbol)
s23 = input('MIL:CY4', type=input.symbol)
s24 = input('MIL:EXSY', type=input.symbol)
s25 = input('MIL:BEC', type=input.symbol)
s26 = input('MIL:RLT', type=input.symbol)
s27 = input('MIL:MAIL', type=input.symbol)
s28 = input('MIL:OSA', type=input.symbol)
s29 = input('MIL:CYB', type=input.symbol)
s30 = input('MIL:OS', type=input.symbol)
s31 = input('MIL:ELES', type=input.symbol)
s32 = input('MIL:NSP', type=input.symbol)
s33 = input('MIL:DOX', type=input.symbol)
s34 = input('MIL:PLT', type=input.symbol)
s35 = input('MIL:EPR', type=input.symbol)
s36 = input('MIL:MAPS', type=input.symbol)
s37 = input('MIL:SOU', type=input.symbol)
s38 = input('MIL:PRT', type=input.symbol)
s39 = input('MIL:PIRC', type=input.symbol)
s40 = input('MIL:ENEL', type=input.symbol)
///////////////
// FUNCTIONS //
pd = input(22, title="LookBack Period Standard Deviation High")
bbl = input(20, title="Bolinger Band Length")
mult = input(2.0 , minval=1, maxval=5, title="Bollinger Band Standard Devaition Up")
lb = input(50 , title="Look Back Period Percentile High")
ph = input(.85, title="Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%")
pl = input(1.01, title="Lowest Percentile - 1.10=90%, 1.05=95%, 1.01=99%")
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100
sDev = mult * stdev(wvf, bbl)
midLine = sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (highest(wvf, lb)) * ph
rangeLow = (lowest(wvf, lb)) * pl
// Screener Function
screenerFunc() =>
cond = wvf >= upperBand or wvf >= rangeHigh
[wvf, cond]
// Rounding Function
roundn(x, n) =>
mult_local = 1
if n != 0
for i = 1 to abs(n)
mult_local := mult_local * 10
n >= 0 ? round(x * mult_local) / mult_local : round(x / mult_local) * mult_local
///////////////////////////////////////
// Running Functions for all sybmols //
[v1, c1] = security(s1, timeframe.period, screenerFunc())
[v2, c2] = security(s2, timeframe.period, screenerFunc())
[v3, c3] = security(s3, timeframe.period, screenerFunc())
[v4, c4] = security(s4, timeframe.period, screenerFunc())
[v5, c5] = security(s5, timeframe.period, screenerFunc())
[v6, c6] = security(s6, timeframe.period, screenerFunc())
[v7, c7] = security(s7, timeframe.period, screenerFunc())
[v8, c8] = security(s8, timeframe.period, screenerFunc())
[v9, c9] = security(s9, timeframe.period, screenerFunc())
[v10, c10] = security(s10, timeframe.period, screenerFunc())
[v11, c11] = security(s11, timeframe.period, screenerFunc())
[v12, c12] = security(s12, timeframe.period, screenerFunc())
[v13, c13] = security(s13, timeframe.period, screenerFunc())
[v14, c14] = security(s14, timeframe.period, screenerFunc())
[v15, c15] = security(s15, timeframe.period, screenerFunc())
[v16, c16] = security(s16, timeframe.period, screenerFunc())
[v17, c17] = security(s17, timeframe.period, screenerFunc())
[v18, c18] = security(s18, timeframe.period, screenerFunc())
[v19, c19] = security(s19, timeframe.period, screenerFunc())
[v20, c20] = security(s20, timeframe.period, screenerFunc())
[v21, c21] = security(s21, timeframe.period, screenerFunc())
[v22, c22] = security(s22, timeframe.period, screenerFunc())
[v23, c23] = security(s23, timeframe.period, screenerFunc())
[v24, c24] = security(s24, timeframe.period, screenerFunc())
[v25, c25] = security(s25, timeframe.period, screenerFunc())
[v26, c26] = security(s26, timeframe.period, screenerFunc())
[v27, c27] = security(s27, timeframe.period, screenerFunc())
[v28, c28] = security(s28, timeframe.period, screenerFunc())
[v29, c29] = security(s29, timeframe.period, screenerFunc())
[v30, c30] = security(s30, timeframe.period, screenerFunc())
[v31, c31] = security(s31, timeframe.period, screenerFunc())
[v32, c32] = security(s32, timeframe.period, screenerFunc())
[v33, c33] = security(s33, timeframe.period, screenerFunc())
[v34, c34] = security(s34, timeframe.period, screenerFunc())
[v35, c35] = security(s35, timeframe.period, screenerFunc())
[v36, c36] = security(s36, timeframe.period, screenerFunc())
[v37, c37] = security(s37, timeframe.period, screenerFunc())
[v38, c38] = security(s38, timeframe.period, screenerFunc())
[v39, c39] = security(s39, timeframe.period, screenerFunc())
[v40, c40] = security(s40, timeframe.period, screenerFunc())
////////////////////
// Screener label //
f_buildLabel(_c, _s, _v) =>
_c ? _s + ' ' + tostring(roundn(_v, 3)) + '\n' : ''
if barstate.islast
scr_label = ''
scr_label := scr_label + f_buildLabel(c1, s1, v1)
scr_label := scr_label + f_buildLabel(c2, s2, v2)
scr_label := scr_label + f_buildLabel(c3, s3, v3)
scr_label := scr_label + f_buildLabel(c4, s4, v4)
scr_label := scr_label + f_buildLabel(c5, s5, v5)
scr_label := scr_label + f_buildLabel(c6, s6, v6)
scr_label := scr_label + f_buildLabel(c7, s7, v7)
scr_label := scr_label + f_buildLabel(c8, s8, v8)
scr_label := scr_label + f_buildLabel(c9, s9, v9)
scr_label := scr_label + f_buildLabel(c10, s10, v10)
scr_label := scr_label + f_buildLabel(c11, s11, v11)
scr_label := scr_label + f_buildLabel(c12, s12, v12)
scr_label := scr_label + f_buildLabel(c13, s13, v13)
scr_label := scr_label + f_buildLabel(c14, s14, v14)
scr_label := scr_label + f_buildLabel(c15, s15, v15)
scr_label := scr_label + f_buildLabel(c16, s16, v16)
scr_label := scr_label + f_buildLabel(c17, s17, v17)
scr_label := scr_label + f_buildLabel(c18, s18, v18)
scr_label := scr_label + f_buildLabel(c19, s19, v19)
scr_label := scr_label + f_buildLabel(c20, s20, v20)
scr_label := scr_label + f_buildLabel(c21, s21, v21)
scr_label := scr_label + f_buildLabel(c22, s22, v22)
scr_label := scr_label + f_buildLabel(c23, s23, v23)
scr_label := scr_label + f_buildLabel(c24, s24, v24)
scr_label := scr_label + f_buildLabel(c25, s25, v25)
scr_label := scr_label + f_buildLabel(c26, s26, v26)
scr_label := scr_label + f_buildLabel(c27, s27, v27)
scr_label := scr_label + f_buildLabel(c28, s28, v28)
scr_label := scr_label + f_buildLabel(c29, s29, v29)
scr_label := scr_label + f_buildLabel(c30, s30, v30)
scr_label := scr_label + f_buildLabel(c31, s31, v31)
scr_label := scr_label + f_buildLabel(c32, s32, v32)
scr_label := scr_label + f_buildLabel(c33, s33, v33)
scr_label := scr_label + f_buildLabel(c34, s34, v34)
scr_label := scr_label + f_buildLabel(c35, s35, v35)
scr_label := scr_label + f_buildLabel(c36, s36, v36)
scr_label := scr_label + f_buildLabel(c37, s37, v37)
scr_label := scr_label + f_buildLabel(c38, s38, v38)
scr_label := scr_label + f_buildLabel(c39, s39, v39)
scr_label := scr_label + f_buildLabel(c40, s40, v40)
// Adding #telegram hashtag for alertatron
//scr_label := scr_label + "\n Ricerca titoli"
scr_label := scr_label + 'upperBand ' + tostring(roundn(upperBand, 3)) + '\nrangeHigh ' + tostring(roundn(rangeHigh, 3)) + '\nwvf ' + tostring(roundn(wvf, 3))
// Plot Label
lab_l = label.new(
bar_index, 0, scr_label,
color=color.red,
textcolor=color.yellow,
style = label.style_labeldown,
yloc = yloc.price)
// label.delete(lab_l[1])
Upvotes: 2