// © goodgains
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator("Market View++", overlay = true)
// @keywords: multi-symbol-dashboard, relative-volume-table, daily-percent-change, range-percent-score, price-action-trend-dot, ten-symbol-watchlist, session-background, sydney-euro-ny-sessions, five-minute-security, overnight-rvol, rth-rvol, cumulative-volume-ratio, normalized-move-plot, group-symbol-composite, market-overview-table, symbol-root-labels, trend-direction-cell, day-change-cell, range-score-cell, cross-asset-comparison
import TradingView/RelativeValue/2 as rv
// input indvidual Symbols
sym1_color = input.color(color.new(#4caf50,0), group = 'Individual Symbols', inline = '1', title = '')
sym2_color = input.color(color.new(#00ff0a,0), group = 'Individual Symbols', inline = '2', title = '')
sym3_color = input.color(color.new(#00dbb7,0), group = 'Individual Symbols', inline = '3', title = '')
sym4_color = input.color(color.new(#489a8c,0), group = 'Individual Symbols', inline = '4', title = '')
sym5_color = input.color(color.new(#b2b5be,0), group = 'Individual Symbols', inline = '5', title = '')
sym6_color = input.color(color.new(#f77c80,0), group = 'Individual Symbols', inline = '6', title = '')
sym7_color = input.color(color.new(#b22833,0), group = 'Individual Symbols', inline = '7', title = '')
sym8_color = input.color(color.new(#5b9cf6,0), group = 'Individual Symbols', inline = '8', title = '')
sym9_color = input.color(color.new(#f3e090,0), group = 'Individual Symbols', inline = '9', title = '')
sym10_color = input.color(color.new(#c6b18b,0), group = 'Individual Symbols', inline = '10', title = '')
symbol1 = input.symbol('CME_MINI:ES1!', group = 'Individual Symbols', inline = "1")
symbol2 = input.symbol('CME_MINI:NQ1!', group = 'Individual Symbols', inline = "2")
symbol3 = input.symbol('CME_MINI:RTY1!', group = 'Individual Symbols', inline = "3")
symbol4 = input.symbol('CBOT:YM1!', group = 'Individual Symbols', inline = "4")
symbol5 = input.symbol('TVC:VIX', group = 'Individual Symbols', inline = "5")
symbol6 = input.symbol('CAPITALCOM:DXY', group = 'Individual Symbols', inline = "6")
symbol7 = input.symbol('CBOT:UB1!', group = 'Individual Symbols', inline = "7")
symbol8 = input.symbol('BINANCE:BTCUSDT', group = 'Individual Symbols', inline = "8")
symbol9 = input.symbol('COMEX:GC1!', group = 'Individual Symbols', inline = "9")
symbol10 = input.symbol('NYMEX:CL1!', group = 'Individual Symbols', inline = "10")
// input grouped Symbols
groupsym1_color = input.color(color.new(#4caf50,0), group = 'Group Symbols', inline = '1', title = '')
groupsym2_color = input.color(color.new(#00ff0a,0), group = 'Group Symbols', inline = '2', title = '')
groupsym3_color = input.color(color.new(#00dbb7,0), group = 'Group Symbols', inline = '3', title = '')
groupsym4_color = input.color(color.new(#489a8c,0), group = 'Group Symbols', inline = '4', title = '')
groupsym5_color = input.color(color.new(#b2b5be,0), group = 'Group Symbols', inline = '5', title = '')
groupsymbol1 = input.symbol('CME_MINI:ES1!+CME_MINI:NQ1!+CME_MINI:RTY1!+CBOT:YM1!', group = 'Group Symbols', inline = "1")
groupsymbol2 = input.symbol('CME_MINI:NQ1!', group = 'Group Symbols', inline = "2")
groupsymbol3 = input.symbol('CME_MINI:RTY1!', group = 'Group Symbols', inline = "3")
groupsymbol4 = input.symbol('CBOT:YM1!', group = 'Group Symbols', inline = "4")
groupsymbol5 = input.symbol('TVC:VIX', group = 'Group Symbols', inline = "5")
// session times
is_sydney_session = time == time(timeframe.period, str.format('{0}:1234567', '1800-0259'), 'America/New_York')
is_euro_session = time == time(timeframe.period, str.format('{0}:1234567', '0300-0829'), 'America/New_York')
is_ny_session = time == time(timeframe.period, str.format('{0}:1234567', '0930-1759'), 'America/New_York')
session_color = is_sydney_session ? color.new(#ff5252, 80) : is_euro_session ? #ffe60033 : #008cff33
is_on_session = not is_ny_session
bgcolor(session_color, title = 'Upper Overnight BG', force_overlay = true)
bgcolor(session_color, title = 'Lower Overnight BG', force_overlay = false)
// calculate rvol
f_calculate_rvol(sess_type) =>
is_rvol = time == time(timeframe.period, str.format('{0}:1234567', '0930-1700'), 'America/New_York')
bool anchor = sess_type == 1 ? (is_rvol and not is_rvol[1]) : (not is_rvol and is_rvol[1])
bool useCumulative = true
float currVol = rv.calcCumulativeSeries(volume, anchor, useCumulative)
float pastVol = rv.averageAtTime(volume, 20, anchor, useCumulative)
float volRatio = math.round(currVol / pastVol * 100,0)
volRatio[1]
// calc PA trend
f_calculate_paCandles(sdLength, offset) =>
sh = ta.pivothigh(high, sdLength, sdLength)
sl = ta.pivotlow(low, sdLength, sdLength)
csh = ta.valuewhen(not na(sh), high[sdLength], 0)
csl = ta.valuewhen(not na(sl), low[sdLength], 0)
psh = ta.valuewhen(not na(sh), high[sdLength], 1)
psl = ta.valuewhen(not na(sl), low[sdLength], 1)
hh = sh >= psh
lh = sh < psh
ll = sl <= psl
hl = sl > psl
var int trend = na
trend := ((hh and high >= psh) or close > csh) ? 1 : ((ll and low <= psl) or close < csl) ? -1 : lh or hl ? 0 : trend[1]
var int last_signal = na
last_signal := hh ? 2 : lh ? -1 : ll ? -2 : hl ? 1 : last_signal[1]
trend[offset]
// 5min data
f_5minute_data(symbol) =>
if not barstate.islast
[close, na, na, na, syminfo.root]
[close5, rvol_rth, rvol_on, pa_trend, symbol_str] =
request.security(symbol, "5", [
close,
f_calculate_rvol(1),
f_calculate_rvol(0),
f_calculate_paCandles(10, 0),
syminfo.root
]
)
// daily data
f_daily_data(symbol) =>
if not barstate.islast
[na, na, na]
[pdc, pct_range, avg_pct_change] =
request.security(symbol, "D", [
close[1],
math.round((high-low) / ta.sma(high[1] - low[1], 20) * 100, 0),
math.round( ta.sma( math.abs(close[1] - close[2])/close[2] * 100, 20), 2)
],
lookahead = barmerge.lookahead_on
)
f_calc_pct_color(pct) =>
pct_color = pct > 0 ? #16c000 : color.rgb(192, 0, 0)
f_calc_pct_range(pct) =>
pct_color = pct > 80 ? color.new(#0084ff, 0)
: pct > 55 ? #3891e4
: pct > 30 ? #6ca6dd
: #93b7d8
f_calc_rvol_color(rvol) =>
rvol_color = rvol > 250 ? #16c000
: rvol > 150 ? #11aaaa
: rvol > 80 ? color.new(#0084ff, 0)
: rvol > 50 ? #c3ac27cc
: color.rgb(86, 0, 0)
f_calc_pa_trend_color(pa_trend) =>
pa_color = pa_trend == 1 ? #16c000
: pa_trend == -1 ? color.rgb(192, 0, 0)
: #c3ac27cc
// 5 min data
[close1, rvol1_rth, rvol_on1, pa_trend1, symbol1_str] = f_5minute_data(symbol1)
[close2, rvol2_rth, rvol_on2, pa_trend2, symbol2_str] = f_5minute_data(symbol2)
[close3, rvol3_rth, rvol_on3, pa_trend3, symbol3_str] = f_5minute_data(symbol3)
[close4, rvol4_rth, rvol_on4, pa_trend4, symbol4_str] = f_5minute_data(symbol4)
[close5, rvol5_rth, rvol_on5, pa_trend5, symbol5_str] = f_5minute_data(symbol5)
[close6, rvol6_rth, rvol_on6, pa_trend6, symbol6_str] = f_5minute_data(symbol6)
[close7, rvol7_rth, rvol_on7, pa_trend7, symbol7_str] = f_5minute_data(symbol7)
[close8, rvol8_rth, rvol_on8, pa_trend8, symbol8_str] = f_5minute_data(symbol8)
[close9, rvol9_rth, rvol_on9, pa_trend9, symbol9_str] = f_5minute_data(symbol9)
[close10, rvol10_rth, rvol_on10, pa_trend10, symbol10_str] = f_5minute_data(symbol10)
[closeg1, rvolg1_rth, rvol_ong1, pa_trendg1, symbolg1_str] = f_5minute_data(groupsymbol1)
rvol1 = is_on_session ? rvol1_rth : rvol_on1
rvol2 = is_on_session ? rvol2_rth : rvol_on2
rvol3 = is_on_session ? rvol3_rth : rvol_on3
rvol4 = is_on_session ? rvol4_rth : rvol_on4
rvol5 = is_on_session ? rvol5_rth : rvol_on5
rvol6 = is_on_session ? rvol6_rth : rvol_on6
rvol7 = is_on_session ? rvol7_rth : rvol_on7
rvol8 = is_on_session ? rvol8_rth : rvol_on8
rvol9 = is_on_session ? rvol9_rth : rvol_on9
rvol10 = is_on_session ? rvol10_rth : rvol_on10
rvolg1 = is_on_session ? rvolg1_rth : rvol_ong1
// daily data
[pdc1, rrange1, avg_pctchange1] = f_daily_data(symbol1)
[pdc2, rrange2, avg_pctchange2] = f_daily_data(symbol2)
[pdc3, rrange3, avg_pctchange3] = f_daily_data(symbol3)
[pdc4, rrange4, avg_pctchange4] = f_daily_data(symbol4)
[pdc5, rrange5, avg_pctchange5] = f_daily_data(symbol5)
[pdc6, rrange6, avg_pctchange6] = f_daily_data(symbol6)
[pdc7, rrange7, avg_pctchange7] = f_daily_data(symbol7)
[pdc8, rrange8, avg_pctchange8] = f_daily_data(symbol8)
[pdc9, rrange9, avg_pctchange9] = f_daily_data(symbol9)
[pdc10, rrange10, avg_pctchange10] = f_daily_data(symbol10)
[pdcg1, rrangeg1, avg_pctchangeg1] = f_daily_data(groupsymbol1)
// calculate daily % change
pct1 = math.round((close1 - pdc1) / pdc1 * 100, 2)
pct2 = math.round((close2 - pdc2) / pdc2 * 100, 2)
pct3 = math.round((close3 - pdc3) / pdc3 * 100, 2)
pct4 = math.round((close4 - pdc4) / pdc4 * 100, 2)
pct5 = math.round((close5 - pdc5) / pdc5 * 100, 2)
pct6 = math.round((close6 - pdc6) / pdc6 * 100, 2)
pct7 = math.round((close7 - pdc7) / pdc7 * 100, 2)
pct8 = math.round((close8 - pdc8) / pdc8 * 100, 2)
pct9 = math.round((close9 - pdc9) / pdc9 * 100, 2)
pct10 = math.round((close10 - pdc10) / pdc10 * 100, 2)
pctg1 = math.round((closeg1 - pdcg1) / pdcg1 * 100, 2)
//plot pct
plot(math.abs(pct1)/avg_pctchange1, style = plot.style_steplinebr, color = sym1_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct2)/avg_pctchange2, style = plot.style_steplinebr, color = sym2_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct3)/avg_pctchange3, style = plot.style_steplinebr, color = sym3_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct4)/avg_pctchange4, style = plot.style_steplinebr, color = sym4_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct5)/avg_pctchange5, style = plot.style_steplinebr, color = sym5_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct6)/avg_pctchange6, style = plot.style_steplinebr, color = sym6_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct7)/avg_pctchange7, style = plot.style_steplinebr, color = sym7_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct8)/avg_pctchange8, style = plot.style_steplinebr, color = sym8_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct9)/avg_pctchange9, style = plot.style_steplinebr, color = sym9_color, linewidth = 2, force_overlay = true)
plot(math.abs(pct10)/avg_pctchange10, style = plot.style_steplinebr, color = sym10_color, linewidth = 2, force_overlay = true)
// plot(math.abs(pctg1)/avg_pctchangeg1, style = plot.style_steplinebr, color = sym10_color, linewidth = 2, force_overlay = false)
// table
market_view = table.new(position = position.middle_right, columns = 5, rows = 15, force_overlay = true, frame_width = 1, frame_color = color.new(#000000,0), border_color = color.black, border_width = 1)
if barstate.islast
// row 1
table.cell(market_view, 0,0, text = "Market View 📈", text_color = chart.fg_color, bgcolor = color.new(#000000, 0 ))
table.merge_cells(market_view,0,0,4,0)
// row 2
table.cell(market_view, 0,1, text = "", text_color = chart.fg_color, bgcolor = color.new(#000000, 0 ), text_size = size.normal)
table.cell(market_view, 1,1, text = "🧭", text_color = chart.fg_color, bgcolor = color.new(#000000, 0 ), text_size = size.normal)
table.cell(market_view, 2,1, text = "Day%", text_color = chart.fg_color, bgcolor = color.new(#000000, 0 ), text_size = size.normal)
table.cell(market_view, 3,1, text = "Range%", text_color = chart.fg_color, bgcolor = color.new(#000000, 0 ), text_size = size.normal)
table.cell(market_view, 4,1, text = "📊", text_color = chart.fg_color, bgcolor = color.new(#000000, 0 ), text_size = size.normal)
// symbol column
table.cell(market_view, 0,2, text = symbol1_str, bgcolor = color.new(#000000, 0 ), text_color = sym1_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,3, text = symbol2_str, bgcolor = color.new(#000000, 0 ), text_color = sym2_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,4, text = symbol3_str, bgcolor = color.new(#000000, 0 ), text_color = sym3_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,5, text = symbol4_str, bgcolor = color.new(#000000, 0 ), text_color = sym4_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,6, text = symbol5_str, bgcolor = color.new(#000000, 0 ), text_color = sym5_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,7, text = symbol6_str, bgcolor = color.new(#000000, 0 ), text_color = sym6_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,8, text = symbol7_str, bgcolor = color.new(#000000, 0 ), text_color = sym7_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,9, text = symbol8_str, bgcolor = color.new(#000000, 0 ), text_color = sym8_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,10, text = symbol9_str, bgcolor = color.new(#000000, 0 ), text_color = sym9_color, text_halign = text.align_left, text_size = size.normal)
table.cell(market_view, 0,11, text = symbol10_str, bgcolor = color.new(#000000, 0 ), text_color = sym10_color, text_halign = text.align_left, text_size = size.normal)
// trend column
table.cell(market_view, 1,2, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend1), text_size = size.normal)
table.cell(market_view, 1,3, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend2), text_size = size.normal)
table.cell(market_view, 1,4, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend3), text_size = size.normal)
table.cell(market_view, 1,5, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend4), text_size = size.normal)
table.cell(market_view, 1,6, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend5), text_size = size.normal)
table.cell(market_view, 1,7, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend6), text_size = size.normal)
table.cell(market_view, 1,8, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend7), text_size = size.normal)
table.cell(market_view, 1,9, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend8), text_size = size.normal)
table.cell(market_view, 1,10, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend9), text_size = size.normal)
table.cell(market_view, 1,11, text = " ", text_color = chart.fg_color, bgcolor = f_calc_pa_trend_color(pa_trend10), text_size = size.normal)
// chg column
table.cell(market_view, 2,2, text = str.tostring(pct1) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct1), text_size = size.normal)
table.cell(market_view, 2,3, text = str.tostring(pct2) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct2), text_size = size.normal)
table.cell(market_view, 2,4, text = str.tostring(pct3) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct3), text_size = size.normal)
table.cell(market_view, 2,5, text = str.tostring(pct4) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct4), text_size = size.normal)
table.cell(market_view, 2,6, text = str.tostring(pct5) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct5), text_size = size.normal)
table.cell(market_view, 2,7, text = str.tostring(pct6) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct6), text_size = size.normal)
table.cell(market_view, 2,8, text = str.tostring(pct7) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct7), text_size = size.normal)
table.cell(market_view, 2,9, text = str.tostring(pct8) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct8), text_size = size.normal)
table.cell(market_view, 2,10, text = str.tostring(pct9) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct9), text_size = size.normal)
table.cell(market_view, 2,11, text = str.tostring(pct10) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_color(pct10), text_size = size.normal)
// rrange column
table.cell(market_view, 3,2, text = str.tostring(rrange1) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange1), text_size = size.normal)
table.cell(market_view, 3,3, text = str.tostring(rrange2) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange2), text_size = size.normal)
table.cell(market_view, 3,4, text = str.tostring(rrange3) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange3), text_size = size.normal)
table.cell(market_view, 3,5, text = str.tostring(rrange4) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange4), text_size = size.normal)
table.cell(market_view, 3,6, text = str.tostring(rrange5) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange5), text_size = size.normal)
table.cell(market_view, 3,7, text = str.tostring(rrange6) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange6), text_size = size.normal)
table.cell(market_view, 3,8, text = str.tostring(rrange7) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange7), text_size = size.normal)
table.cell(market_view, 3,9, text = str.tostring(rrange8) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange8), text_size = size.normal)
table.cell(market_view, 3,10, text = str.tostring(rrange9) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange9), text_size = size.normal)
table.cell(market_view, 3,11, text = str.tostring(rrange10) + "%", text_color = chart.fg_color, bgcolor = f_calc_pct_range(rrange10), text_size = size.normal)
// rvol column
table.cell(market_view, 4,2, text = str.tostring(rvol1[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol1), text_size = size.normal)
table.cell(market_view, 4,3, text = str.tostring(rvol2[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol2), text_size = size.normal)
table.cell(market_view, 4,4, text = str.tostring(rvol3[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol3), text_size = size.normal)
table.cell(market_view, 4,5, text = str.tostring(rvol4[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol4), text_size = size.normal)
table.cell(market_view, 4,6, text = "-", text_color = chart.fg_color, bgcolor = #9d9d9d, text_size = size.normal)
table.cell(market_view, 4,7, text = str.tostring(rvol6[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol6), text_size = size.normal)
table.cell(market_view, 4,8, text = str.tostring(rvol7[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol7), text_size = size.normal)
table.cell(market_view, 4,9, text = str.tostring(rvol8[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol8), text_size = size.normal)
table.cell(market_view, 4,10, text = str.tostring(rvol9[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol9), text_size = size.normal)
table.cell(market_view, 4,11, text = str.tostring(rvol10[1]), text_color = chart.fg_color, bgcolor = f_calc_rvol_color(rvol10), text_size = size.normal)
Show all 306 lines