0% found this document useful (0 votes)
127 views

vwap done only color left

Uploaded by

mytvtrial1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

vwap done only color left

Uploaded by

mytvtrial1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

//@version=5

indicator('MIS', overlay=true)

////////////
// INPUTS //

// SMA
rsi_len = input.int( 14, title = "RSI Length", group = "Indicators")
rsi_os = input.float(40, title = "Overbought", group = "Indicators")
rsi_ob = input.float(60, title = "Oversold", group = "Indicators")

// EMA
ema_len = input.int(5, title="EMA Length", group="Indicators")

// VWAP Params
vwap_len = input.int(14, title="VWAP Length", group="Indicators")

// SuperTrend
sup_atr_len = input.int( 9, "Supertrend ATR Length", group = 'Indicators')
sup_factor = input.float(2.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')

s01 = input.symbol('NIFTY', group = 'Symbols', inline = 's01')


s02 = input.symbol('BANKNIFTY', group = 'Symbols', inline = 's02')
s03 = input.symbol('HDFCBANK', group = 'Symbols', inline = 's03')
s04 = input.symbol('ICICIBANK', group = 'Symbols', inline = 's04')
s05 = input.symbol('KOTAKBANK', group = 'Symbols', inline = 's05')
s06 = input.symbol('AXISBANK', group = 'Symbols', inline = 's06')
s07 = input.symbol('SBIN', group = 'Symbols', inline = 's07')
s08 = input.symbol('INDUSINDBK', group = 'Symbols', inline = 's08')

//////////////////
// CALCULATIONS //

// 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)
=> na

// VWAP
vwap_func(len) =>
sum = 0.0
sumvol = 0.0
for i = 0 to len - 1
sum := sum + close[i] * volume[i]
sumvol := sumvol + volume[i]
vwap = sum / sumvol

screener_func() =>

// RSI
rsi = ta.rsi(close, rsi_len)

// EMA of High
ema_high = ta.ema(high, ema_len)

// VWAP
vwap_val = vwap_func(vwap_len)

// Supertrend
[sup_value, sup_dir] = ta.supertrend(sup_factor, sup_atr_len)

[math.round_to_mintick(close), rsi, ema_high, vwap_val, sup_dir]

// Set Up Matrix
screenerMtx = matrix.new<float>(0, 6, na)

screenerFun(numSym, sym, flg) =>

[cl, rsi, ema_high, vwap_val, sup] = request.security(sym, timeframe.period,


screener_func())

arr = array.from(numSym, cl, rsi, ema_high, vwap_val, 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),

///////////
// 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))

if barstate.islast
table.clear(tbl, 0, 0, 5, 40)

table.cell(tbl, 0, 0, 'Symbol', text_halign = text.align_center, bgcolor =


color.rgb(10, 10, 10), text_color = color.white, text_size = size.small)
table.cell(tbl, 1, 0, 'Price', text_halign = text.align_center, bgcolor =
color.rgb(10, 10, 10), text_color = color.white, text_size = size.small)
table.cell(tbl, 2, 0, 'RSI', text_halign = text.align_center, bgcolor =
color.rgb(10, 10, 10), text_color = color.white, text_size = size.small)
table.cell(tbl, 3, 0, 'EMA', text_halign = text.align_center, bgcolor =
color.rgb(10, 10, 10), text_color = color.white, text_size = size.small)
table.cell(tbl, 4, 0, 'VWAP', text_halign = text.align_center, bgcolor =
color.rgb(10, 10, 10), text_color = color.white, text_size = size.small)
table.cell(tbl, 5, 0, 'ST', text_halign = text.align_center, bgcolor =
color.rgb(10, 10, 10), text_color = color.white, text_size = size.small)

if matrix.rows(screenerMtx) > 0
for i = 0 to matrix.rows(screenerMtx) - 1

rsi_col = matrix.get(screenerMtx, i, 2) > rsi_ob ? color.red :


matrix.get(screenerMtx, i, 2) < rsi_os ? color.green : color.blue
ema_high_value = matrix.get(screenerMtx, i, 3)
vwap_col = matrix.get(screenerMtx, i, 1) > matrix.get(screenerMtx, i,
4) ? color.green : color.red
sup_text = matrix.get(screenerMtx, i, 5) > 0 ? "Down" : "Up"
sup_col = matrix.get(screenerMtx, i, 5) < 0 ? color.green : color.red

// Check if Price > EMA for background color of EMA column


ema_col = matrix.get(screenerMtx, i, 1) > ema_high_value ?
color.green : color.red

table.cell(tbl, 0, i + 1, id_symbol(matrix.get(screenerMtx, i, 0)),


text_halign = text.align_left, bgcolor = color.rgb(10, 10, 10), text_color =
color.blue, text_size = size.small)
table.cell(tbl, 1, i + 1, str.tostring(matrix.get(screenerMtx, i, 1)),
text_halign = text.align_right, bgcolor = vwap_col, 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(ema_high_value, "#.##"),
text_halign = text.align_center, bgcolor=ema_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 = color.rgb(10, 10, 10),
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)

You might also like