10X Market Direction
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Beardy_Fred

//@version=5
indicator(title="10X Market", overlay = false)

//LENGTH INPUTS
len = input(14, "Directional Length")
ADX_T = input(20, "ADX Length")
vol_len = input(20, "Volume Length")

//TICKER INPUTS
Ticker1= input.symbol(title="Symbol_1", defval="CME_MINI:ES1!")
Ticker2= input.symbol(title="Symbol_2", defval="CME_MINI:NQ1!")
Ticker3= input.symbol(title="Symbol_3", defval="AMEX:SPY")
Ticker4= input.symbol(title="Symbol_4", defval="NASDAQ:QQQ")
Ticker5= input.symbol(title="Symbol_5", defval="AMEX:IWM")
Ticker6= input.symbol(title="Symbol_6", defval="AMEX:XLC")
Ticker7= input.symbol(title="Symbol_7", defval="AMEX:XLY")
Ticker8= input.symbol(title="Symbol_8", defval="AMEX:XLP")
Ticker9= input.symbol(title="Symbol_9", defval="AMEX:XLE")
Ticker10= input.symbol(title="Symbol_10", defval="AMEX:XLF")
Ticker11= input.symbol(title="Symbol_11", defval="AMEX:XLV")
Ticker12= input.symbol(title="Symbol_12", defval="AMEX:XLI")
Ticker13= input.symbol(title="Symbol_13", defval="AMEX:XLB")
Ticker14= input.symbol(title="Symbol_14", defval="AMEX:XLRE")
Ticker15= input.symbol(title="Symbol_15", defval="AMEX:XLK")
Ticker16= input.symbol(title="Symbol_16", defval="AMEX:XLU")

// DMI CALCULATIONS
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)
trur = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / trur)
minus = fixnan(100 * ta.rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), len)

//10X CALCULATIONS
D_Up = (plus > minus) and (adx > ADX_T)
D_Down = (minus > plus) and (adx > ADX_T)
uptrend = D_Up 
downtrend = D_Down
sideways = (adx < ADX_T)
Bar_Color = sideways ? color.yellow : uptrend ? color.green : downtrend ? color.red :  na

[SC_1] = request.security(Ticker1, timeframe.period, [Bar_Color])
[SC_2] = request.security(Ticker2, timeframe.period, [Bar_Color])
[SC_3] = request.security(Ticker3, timeframe.period, [Bar_Color])
[SC_4] = request.security(Ticker4, timeframe.period, [Bar_Color])
[SC_5] = request.security(Ticker5, timeframe.period, [Bar_Color])
[SC_6] = request.security(Ticker6, timeframe.period, [Bar_Color])
[SC_7] = request.security(Ticker7, timeframe.period, [Bar_Color])
[SC_8] = request.security(Ticker8, timeframe.period, [Bar_Color])
[SC_9] = request.security(Ticker9, timeframe.period, [Bar_Color])
[SC_10] = request.security(Ticker10, timeframe.period, [Bar_Color])
[SC_11] = request.security(Ticker11, timeframe.period, [Bar_Color])
[SC_12] = request.security(Ticker12, timeframe.period, [Bar_Color])
[SC_13] = request.security(Ticker13, timeframe.period, [Bar_Color])
[SC_14] = request.security(Ticker14, timeframe.period, [Bar_Color])
[SC_15] = request.security(Ticker15, timeframe.period, [Bar_Color])
[SC_16] = request.security(Ticker16, timeframe.period, [Bar_Color])

// PLOTS //
l_width = 2
shape = plot.style_circles

hline(19, color=color.gray, linestyle = hline.style_dotted)
plot(18, color=SC_1, style=shape, linewidth=l_width)
plot(17, color=SC_2, style=shape, linewidth=l_width)
hline(16, color=color.gray, linestyle = hline.style_dotted)
plot(15, color=SC_3, style=shape, linewidth=l_width)
plot(14, color=SC_4, style=shape, linewidth=l_width)
plot(13, color=SC_5, style=shape, linewidth=l_width)
hline(12, color=color.gray, linestyle = hline.style_dotted)
plot(11, color=SC_6, style=shape, linewidth=l_width)
plot(10, color=SC_7, style=shape, linewidth=l_width)
plot(9, color=SC_8, style=shape, linewidth=l_width)
plot(8, color=SC_9, style=shape, linewidth=l_width)
plot(7, color=SC_10, style=shape, linewidth=l_width)
plot(6, color=SC_11, style=shape, linewidth=l_width)
plot(5, color=SC_12, style=shape, linewidth=l_width)
plot(4, color=SC_13, style=shape, linewidth=l_width)
plot(3, color=SC_14, style=shape, linewidth=l_width)
plot(2, color=SC_15, style=shape, linewidth=l_width)
plot(1, color=SC_16, style=shape, linewidth=l_width)
hline(0, color=color.gray, linestyle = hline.style_dotted)

//TICKER LABELS//
Tick_Style = label.style_none
Tick_Color = color.new(color.white, 0)
Tick_Size = size.small
Tick_Pos = bar_index + 2 // distance label is from 1st dot

getName(_str) =>
    string[] _pair = str.split(_str, ":")
    string[] _chars = str.split(array.get(_pair, 1), "")
    int _len = array.size(_chars) - 0
    string[] _substr = array.new_string(0)
    _substr := array.slice(_chars, 0, _len)
    string _return = array.join(_substr, "")

L1= label.new(Tick_Pos, 17.75, text=getName(Ticker1), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L1[1])
L2= label.new(Tick_Pos, 16.75, text=getName(Ticker2), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L2[1])
L3= label.new(Tick_Pos, 14.75, text=getName(Ticker3), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L3[1])
L4= label.new(Tick_Pos, 13.75, text=getName(Ticker4), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L4[1])
L5= label.new(Tick_Pos, 12.75, text=getName(Ticker5), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L5[1])
L6= label.new(Tick_Pos, 10.75, text=getName(Ticker6), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L6[1])
L7= label.new(Tick_Pos, 9.75, text=getName(Ticker7), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L7[1])
L8= label.new(Tick_Pos, 8.75, text=getName(Ticker8), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L8[1])
L9= label.new(Tick_Pos, 7.75, text=getName(Ticker9), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L9[1])
L10= label.new(Tick_Pos, 6.75, text=getName(Ticker10), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L10[1])
L11= label.new(Tick_Pos, 5.75, text=getName(Ticker11), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L11[1])
L12= label.new(Tick_Pos, 4.75, text=getName(Ticker12), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L12[1])
L13= label.new(Tick_Pos, 3.75, text=getName(Ticker13), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L13[1])
L14= label.new(Tick_Pos, 2.75, text=getName(Ticker14), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L14[1])
L15= label.new(Tick_Pos, 1.75, text=getName(Ticker15), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L15[1])
L16= label.new(Tick_Pos, 0.75, text=getName(Ticker16), style=Tick_Style, textcolor=Tick_Color, size=Tick_Size)
label.delete(L16[1])



