NP Screener with Alerts

indicator('NP Screener with Alerts', overlay=true)
////////////
// INPUTS //
filter_enabled = input.bool(false, "", group = "Filter", inline = "Filter")
filter_column = input.string("Price", title = "Column", options = ['Price', 'RSI', 'TSI', 'ADX', 'SuperTrend'], group = "Filter", inline = "Filter")
filter_from = input.float(-9999999, "From", group = "Filter", inline = "Filter")
filter_to = input.float(9999999, "To", group = "Filter", inline = "Filter")
// SMA
rsi_len = input.int( 14, title = "RSI Length", group = "Indicators")
rsi_os = input.float(30, title = "RSI Overbought", group = "Indicators")
rsi_ob = input.float(70, title = "RSI Oversold", group = "Indicators")
// TSI
tsi_long_len = input.int( 25, title = "TSI Long Length", group = "Indicators")
tsi_shrt_len = input.int( 13, title = "TSI Short Length", group = "Indicators")
tsi_ob = input.float( 30, title = "TSI Overbought", group = 'Indicators')
tsi_os = input.float(-30, title = "TSI Oversold", group = 'Indicators')
// ADX Params
adx_smooth = input.int( 14, title = "ADX Smoothing", group = 'Indicators')
adx_dilen = input.int( 14, title = "ADX DI Length", group = 'Indicators')
adx_level = input.float(40, title = "ADX Level", group = 'Indicators')
// SuperTrend
sup_atr_len = input.int( 10, "Supertrend ATR Length", group = 'Indicators')
sup_factor = input.float(3.0, "Supertrend Factor", group = 'Indicators')
/////////////
// SYMBOLS //
u01 = input.bool(true, title = "", group = 'Symbols', inline = 's01')
u02 = input.bool(true, title = "", group = 'Symbols', inline = 's02')
u03 = input.bool(true, title = "", group = 'Symbols', inline = 's03')
u04 = input.bool(true, title = "", group = 'Symbols', inline = 's04')
u05 = input.bool(true, title = "", group = 'Symbols', inline = 's05')
u06 = input.bool(true, title = "", group = 'Symbols', inline = 's06')
u07 = input.bool(true, title = "", group = 'Symbols', inline = 's07')
u08 = input.bool(true, title = "", group = 'Symbols', inline = 's08')
u09 = input.bool(true, title = "", group = 'Symbols', inline = 's09')
u10 = input.bool(true, title = "", group = 'Symbols', inline = 's10')
u11 = input.bool(true, title = "", group = 'Symbols', inline = 's11')
u12 = input.bool(true, title = "", group = 'Symbols', inline = 's12')
u13 = input.bool(true, title = "", group = 'Symbols', inline = 's13')
u14 = input.bool(true, title = "", group = 'Symbols', inline = 's14')
u15 = input.bool(true, title = "", group = 'Symbols', inline = 's15')
u16 = input.bool(true, title = "", group = 'Symbols', inline = 's16')
u17 = input.bool(true, title = "", group = 'Symbols', inline = 's17')
u18 = input.bool(true, title = "", group = 'Symbols', inline = 's18')
u19 = input.bool(true, title = "", group = 'Symbols', inline = 's19')
u20 = input.bool(true, title = "", group = 'Symbols', inline = 's20')
u21 = input.bool(true, title = "", group = 'Symbols', inline = 's21')
u22 = input.bool(true, title = "", group = 'Symbols', inline = 's22')
u23 = input.bool(true, title = "", group = 'Symbols', inline = 's23')
u24 = input.bool(true, title = "", group = 'Symbols', inline = 's24')
u25 = input.bool(true, title = "", group = 'Symbols', inline = 's25')
u26 = input.bool(true, title = "", group = 'Symbols', inline = 's26')
u27 = input.bool(true, title = "", group = 'Symbols', inline = 's27')
u28 = input.bool(true, title = "", group = 'Symbols', inline = 's28')
u29 = input.bool(true, title = "", group = 'Symbols', inline = 's29')
u30 = input.bool(true, title = "", group = 'Symbols', inline = 's30')
u31 = input.bool(true, title = "", group = 'Symbols', inline = 's31')
u32 = input.bool(true, title = "", group = 'Symbols', inline = 's32')
u33 = input.bool(true, title = "", group = 'Symbols', inline = 's33')
u34 = input.bool(true, title = "", group = 'Symbols', inline = 's34')
u35 = input.bool(true, title = "", group = 'Symbols', inline = 's35')
u36 = input.bool(false, title = "", group = 'Symbols', inline = 's36')
u37 = input.bool(false, title = "", group = 'Symbols', inline = 's37')
u38 = input.bool(false, title = "", group = 'Symbols', inline = 's38')
u39 = input.bool(false, title = "", group = 'Symbols', inline = 's39')
u40 = input.bool(false, title = "", group = 'Symbols', inline = 's40')
s01 = input.symbol('XRPUSDT', group = 'Symbols', inline = 's01')
s02 = input.symbol('BTCUSDT', group = 'Symbols', inline = 's02')
s03 = input.symbol('DOGEUSDT', group = 'Symbols', inline = 's03')
s04 = input.symbol('BNBUSDT', group = 'Symbols', inline = 's04')
s05 = input.symbol('ETHUSDT', group = 'Symbols', inline = 's05')
s06 = input.symbol('ADAUSDT', group = 'Symbols', inline = 's06')
s07 = input.symbol('XRPBTC', group = 'Symbols', inline = 's07')
s08 = input.symbol('DOGEBTC', group = 'Symbols', inline = 's08')
s09 = input.symbol('TRXUSDT', group = 'Symbols', inline = 's09')
s10 = input.symbol('XRPUSDT', group = 'Symbols', inline = 's10')
s11 = input.symbol('BTCUSDT', group = 'Symbols', inline = 's11')
s12 = input.symbol('DOGEUSDT', group = 'Symbols', inline = 's12')
s13 = input.symbol('VETUSDT', group = 'Symbols', inline = 's13')
s14 = input.symbol('ETHBTC', group = 'Symbols', inline = 's14')
s15 = input.symbol('BNBBTC', group = 'Symbols', inline = 's15')
s16 = input.symbol('EOSUSDT', group = 'Symbols', inline = 's16')
s17 = input.symbol('XLMUSDT', group = 'Symbols', inline = 's17')
s18 = input.symbol('LTCUSDT', group = 'Symbols', inline = 's18')
s19 = input.symbol('DOGEBTC', group = 'Symbols', inline = 's19')
s20 = input.symbol('WINUSDT', group = 'Symbols', inline = 's20')
s21 = input.symbol('DOTUSDT', group = 'Symbols', inline = 's21')
s22 = input.symbol('VETUSDT', group = 'Symbols', inline = 's22')
s23 = input.symbol('BCHUSDT', group = 'Symbols', inline = 's23')
s24 = input.symbol('ADABTC', group = 'Symbols', inline = 's24')
s25 = input.symbol('IOSTUSDT', group = 'Symbols', inline = 's25')
s26 = input.symbol('CHZUSDT', group = 'Symbols', inline = 's26')
s27 = input.symbol('LINKUSDT', group = 'Symbols', inline = 's27')
s28 = input.symbol('TRXBTC', group = 'Symbols', inline = 's28')
s29 = input.symbol('ATOMUSDT', group = 'Symbols', inline = 's29')
s30 = input.symbol('BTCEUR', group = 'Symbols', inline = 's30')
s31 = input.symbol('FILUSDT', group = 'Symbols', inline = 's31')
s32 = input.symbol('HOTUSDT', group = 'Symbols', inline = 's32')
s33 = input.symbol('SXPUSDT', group = 'Symbols', inline = 's33')
s34 = input.symbol('TRXBTC', group = 'Symbols', inline = 's34')
s35 = input.symbol('RVNUSDT', group = 'Symbols', inline = 's35')
s36 = input.symbol('ATOMUSDT', group = 'Symbols', inline = 's36')
s37 = input.symbol('XRPBNB', group = 'Symbols', inline = 's37')
s38 = input.symbol('LTCBTC', group = 'Symbols', inline = 's38')
s39 = input.symbol('IOSTBTC', group = 'Symbols', inline = 's39')
s40 = input.symbol('GRTUSDT', group = 'Symbols', inline = 's40')
//////////////////
// CALCULATIONS //
filt_col_id = switch filter_column
'Price' => 1
'RSI' => 2
'TSI' => 3
'ADX' => 4
'SuperTrend' => 5
=> 0
// Get only symbol
only_symbol(s) =>
array.get(str.split(s, ":"), 1)
id_symbol(s)=>
switch s
1 => only_symbol(s01)
2 => only_symbol(s02)
3 => only_symbol(s03)
4 => only_symbol(s04)
5 => only_symbol(s05)
6 => only_symbol(s06)
7 => only_symbol(s07)
8 => only_symbol(s08)
9 => only_symbol(s09)
10 => only_symbol(s10)
11 => only_symbol(s11)
12 => only_symbol(s12)
13 => only_symbol(s13)
14 => only_symbol(s14)
15 => only_symbol(s15)
16 => only_symbol(s16)
17 => only_symbol(s17)
18 => only_symbol(s18)
19 => only_symbol(s19)
20 => only_symbol(s20)
21 => only_symbol(s21)
22 => only_symbol(s22)
23 => only_symbol(s23)
24 => only_symbol(s24)
25 => only_symbol(s25)
26 => only_symbol(s26)
27 => only_symbol(s27)
28 => only_symbol(s28)
29 => only_symbol(s29)
30 => only_symbol(s30)
31 => only_symbol(s31)
32 => only_symbol(s32)
33 => only_symbol(s33)
34 => only_symbol(s34)
35 => only_symbol(s35)
36 => only_symbol(s36)
37 => only_symbol(s37)
38 => only_symbol(s38)
39 => only_symbol(s39)
40 => only_symbol(s40)
=> na
// for TSI
double_smooth(src, long, short) =>
fist_smooth = ta.ema(src, long)
ta.ema(fist_smooth, short)
// ADX
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx_func(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
screener_func() =>
// RSI
rsi = ta.rsi(close, rsi_len)
// TSI
pc = ta.change(close)
double_smoothed_pc = double_smooth(pc, tsi_long_len, tsi_shrt_len)
double_smoothed_abs_pc = double_smooth(math.abs(pc), tsi_long_len, tsi_shrt_len)
tsi = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
// ADX
adx = adx_func(adx_dilen, adx_smooth)
// Supertrend
[sup_value, sup_dir] = ta.supertrend(sup_factor, sup_atr_len)
[math.round_to_mintick(close), rsi, tsi, adx, sup_dir]
// Set Up Matrix
screenerMtx = matrix.new<float>(0, 6, na)
screenerFun(numSym, sym, flg) =>
[cl, rsi, tsi, adx, sup] = request.security(sym, timeframe.period, screener_func())
arr = array.from(numSym, cl, rsi, tsi, adx, sup)
if flg
matrix.add_row(screenerMtx, matrix.rows(screenerMtx), arr)
// Security call
screenerFun(01, s01, u01), screenerFun(02, s02, u02), screenerFun(03, s03, u03), screenerFun(04, s04, u04),
screenerFun(05, s05, u05), screenerFun(06, s06, u06), screenerFun(07, s07, u07), screenerFun(08, s08, u08),
screenerFun(09, s09, u09), screenerFun(10, s10, u10), screenerFun(11, s11, u11), screenerFun(12, s12, u12),
screenerFun(13, s13, u13), screenerFun(14, s14, u14), screenerFun(15, s15, u15), screenerFun(16, s16, u16),
screenerFun(17, s17, u17), screenerFun(18, s18, u18), screenerFun(19, s19, u19), screenerFun(20, s20, u20),
screenerFun(21, s21, u21), screenerFun(22, s22, u22), screenerFun(23, s23, u23), screenerFun(24, s24, u24),
screenerFun(25, s25, u25), screenerFun(26, s26, u26), screenerFun(27, s27, u27), screenerFun(28, s28, u28),
screenerFun(29, s29, u29), screenerFun(30, s30, u30), screenerFun(31, s31, u31), screenerFun(32, s32, u32),
screenerFun(33, s33, u33), screenerFun(34, s34, u34), screenerFun(35, s35, u35), screenerFun(36, s36, u36),
screenerFun(37, s37, u37), screenerFun(38, s38, u38), screenerFun(39, s39, u39), screenerFun(40, s40, u40),
///////////
// PLOTS //
var tbl = table.new(position.top_right, 6, 41, frame_color=#151715, frame_width=1, border_width=2, border_color=color.new(color.white, 100))
log.info(str.tostring(filt_col_id))
alert_msg = ''
if barstate.islast
table.clear(tbl, 0, 0, 5, 40)
table.cell(tbl, 0, 0, 'Symbol', text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.small)
table.cell(tbl, 1, 0, 'Price', text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.small)
table.cell(tbl, 2, 0, 'RSI', text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.small)
table.cell(tbl, 3, 0, 'TSI', text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.small)
table.cell(tbl, 4, 0, 'ADX', text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.small)
table.cell(tbl, 5, 0, 'Supertrend', text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.small)
if matrix.rows(screenerMtx) > 0
for i = 0 to matrix.rows(screenerMtx) - 1
is_filt = (not filter_enabled) or (matrix.get(screenerMtx, i, filt_col_id) >= filter_from and matrix.get(screenerMtx, i, filt_col_id) <= filter_to)
if is_filt
if str.length(alert_msg) > 0
alert_msg := alert_msg + ','
alert_msg := alert_msg + id_symbol(matrix.get(screenerMtx, i, 0))
rsi_col = matrix.get(screenerMtx, i, 2) > rsi_ob ? color.red : matrix.get(screenerMtx, i, 2) < rsi_os ? color.green : #aaaaaa
tsi_col = matrix.get(screenerMtx, i, 3) > tsi_ob ? color.red : matrix.get(screenerMtx, i, 3) < tsi_os ? color.green : #aaaaaa
adx_col = matrix.get(screenerMtx, i, 4) > adx_level ? color.green : #aaaaaa
sup_text = matrix.get(screenerMtx, i, 5) > 0 ? "Down" : "Up"
sup_col = matrix.get(screenerMtx, i, 5) < 0 ? color.green : color.red
table.cell(tbl, 0, i + 1, id_symbol(matrix.get(screenerMtx, i, 0)), text_halign = text.align_left, bgcolor = color.gray, text_color = color.white, text_size = size.small)
table.cell(tbl, 1, i + 1, str.tostring(matrix.get(screenerMtx, i, 1)), text_halign = text.align_center, bgcolor = #aaaaaa, text_color = color.white, text_size = size.small)
table.cell(tbl, 2, i + 1, str.tostring(matrix.get(screenerMtx, i, 2), "#.##"), text_halign = text.align_center, bgcolor = rsi_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 3, i + 1, str.tostring(matrix.get(screenerMtx, i, 3), "#.##"), text_halign = text.align_center, bgcolor = tsi_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 4, i + 1, str.tostring(matrix.get(screenerMtx, i, 4), "#.##"), text_halign = text.align_center, bgcolor = adx_col , text_color = color.white, text_size = size.small)
table.cell(tbl, 5, i + 1, sup_text, text_halign = text.align_center, bgcolor = sup_col, text_color = color.white, text_size = size.small)
if str.length(alert_msg) > 0
alert(alert_msg, freq = alert.freq_once_per_bar_close)
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi shaileshGole secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.
Penafian
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi shaileshGole secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.