Moving Average Panel
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator(title='Moving Average Panel', 
     shorttitle='MA Panel', 
     overlay=true)   

//Settings
src = input.source(close, 'Source', inline='00', 
     group='Calculates if the moving average is increasing for the specified lengths for SMA, EMA, RMA, WMA, VWMA, HMA, EHMA, TEMA, Least Squares, Tillson T3, Arnaud Legoux MA (ALMA), Note: Resolves to "bear" if not enough data.')
string i_tableYpos = input.string('bottom', 'Table', inline='01', options=['top', 'middle', 'bottom'])
string i_tableXpos = input.string('right', '', inline='01', options=['left', 'center', 'right'])
mobilefriendly = input.bool(defval=false, title='Mobile Friendly?', inline='01')

smaon = input.bool(defval=true, title='SMA', inline='10')
emaon = input.bool(defval=true, title='EMA', inline='10')
rmaon = input.bool(defval=true, title='RMA', inline='10')
wmaon = input.bool(defval=true, title='WMA', inline='10')
vwmaon = input.bool(defval=true, title='VWMA', inline='10')
hmaon = input.bool(defval=true, title='HMA', inline='10')
ehmaon = input.bool(defval=true, title='EHMA', inline='11')
temaon = input.bool(defval=true, title='TEMA', inline='11')
linregon = input.bool(defval=true, title='Least Sq.', inline='11')
tillsonon = input.bool(defval=true, title='Tillson T3', inline='11')
almaon = input.bool(defval=true, title='ALMA', inline='11')

buycolor = input.color(color.new(#6bd673, 0), 'Bull', inline='22')
sellcolor = input.color(color.new(#FFCDD2, 0), 'Bear', inline='22')
neutralcolor = input.color(color.new(color.silver, 0), 'Neutral', inline='22')
texcolor = input.color(color.new(color.black, 0), 'Text', inline='22')

len1on = input.bool(defval=true, title='', inline='50')
len1=input(5, inline='50')
len2on = input.bool(defval=true, title='', inline='50')
len2=input(9, inline='50')
len3on = input.bool(defval=true, title='', inline='51')
len3=input(12, inline='51')
len4on = input.bool(defval=true, title='', inline='51')
len4=input(15, inline='51')
len5on = input.bool(defval=true, title='', inline='52')
len5=input(18, inline='52')
len6on = input.bool(defval=true, title='', inline='52')
len6=input(21, inline='52')
len7on = input.bool(defval=true, title='', inline='53')
len7=input(26, inline='53')
len8on = input.bool(defval=true, title='', inline='53')
len8=input(50, inline='53')
len9on = input.bool(defval=true, title='', inline='54')
len9=input(100, inline='54')
len10on = input.bool(defval=true, title='', inline='54')
len10=input(200, inline='54')

//special
linregoffset = input.int(title='Least Squares Offset', defval=0, inline='11', group='Special MA Settings')
a1 = input.float(title='Tillson T3 Volume Factor', defval=0.7, inline='21', step=0.001, group='Special MA Settings')
almaoffset = input.float(title='ALMA Offset', defval=0.85, step=0.01, inline='31', group='Special MA Settings')
almasigma = input.float(title='Sigma', defval=6, inline='31', group='Special MA Settings')

//Functions
f_ehma(_Source, _length) =>
    _return = ta.ema(2 * ta.ema(_Source, _length / 2) - ta.ema(_Source, _length), math.round(math.sqrt(_length)))
    _return

f_tema(_Source, _length) =>
    _out = 3 * (ta.ema(_Source, _length) - ta.ema(ta.ema(_Source, _length), _length)) + ta.ema(ta.ema(ta.ema(_Source, _length), _length), _length)
    _out

f_tillson(_source, _length, _a1) =>
    _output = (-_a1 * _a1 * _a1) * (ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(_source, _length), _length), _length), _length), _length), _length)) + (3 * _a1 * _a1 + 3 * _a1 * _a1 * _a1) * (ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(_source, _length), _length), _length), _length), _length)) + (-6 * _a1 * _a1 - 3 * _a1 - 3 * _a1 * _a1 * _a1) * (ta.ema(ta.ema(ta.ema(ta.ema(_source, _length), _length), _length), _length)) + (1 + 3 * _a1 + _a1 * _a1 * _a1 + 3 * _a1 * _a1) * (ta.ema(ta.ema(ta.ema(_source, _length), _length), _length))
    _output

//moving averages
sma1=ta.sma(src,len1)
sma2=ta.sma(src,len2)
sma3=ta.sma(src,len3)
sma4=ta.sma(src,len4)
sma5=ta.sma(src,len5)
sma6=ta.sma(src,len6)
sma7=ta.sma(src,len7)
sma8=ta.sma(src,len8)
sma9=ta.sma(src,len9)
sma10=ta.sma(src,len10)

ema1=ta.ema(src,len1)
ema2=ta.ema(src,len2)
ema3=ta.ema(src,len3)
ema4=ta.ema(src,len4)
ema5=ta.ema(src,len5)
ema6=ta.ema(src,len6)
ema7=ta.ema(src,len7)
ema8=ta.ema(src,len8)
ema9=ta.ema(src,len9)
ema10=ta.ema(src,len10)

rma1=ta.rma(src,len1)
rma2=ta.rma(src,len2)
rma3=ta.rma(src,len3)
rma4=ta.rma(src,len4)
rma5=ta.rma(src,len5)
rma6=ta.rma(src,len6)
rma7=ta.rma(src,len7)
rma8=ta.rma(src,len8)
rma9=ta.rma(src,len9)
rma10=ta.rma(src,len10)

wma1=ta.wma(src,len1)
wma2=ta.wma(src,len2)
wma3=ta.wma(src,len3)
wma4=ta.wma(src,len4)
wma5=ta.wma(src,len5)
wma6=ta.wma(src,len6)
wma7=ta.wma(src,len7)
wma8=ta.wma(src,len8)
wma9=ta.wma(src,len9)
wma10=ta.wma(src,len10)

vwma1=ta.vwma(src,len1)
vwma2=ta.vwma(src,len2)
vwma3=ta.vwma(src,len3)
vwma4=ta.vwma(src,len4)
vwma5=ta.vwma(src,len5)
vwma6=ta.vwma(src,len6)
vwma7=ta.vwma(src,len7)
vwma8=ta.vwma(src,len8)
vwma9=ta.vwma(src,len9)
vwma10=ta.vwma(src,len10)

hma1=ta.hma(src,len1)
hma2=ta.hma(src,len2)
hma3=ta.hma(src,len3)
hma4=ta.hma(src,len4)
hma5=ta.hma(src,len5)
hma6=ta.hma(src,len6)
hma7=ta.hma(src,len7)
hma8=ta.hma(src,len8)
hma9=ta.hma(src,len9)
hma10=ta.hma(src,len10)

ehma1=f_ehma(src,len1)
ehma2=f_ehma(src,len2)
ehma3=f_ehma(src,len3)
ehma4=f_ehma(src,len4)
ehma5=f_ehma(src,len5)
ehma6=f_ehma(src,len6)
ehma7=f_ehma(src,len7)
ehma8=f_ehma(src,len8)
ehma9=f_ehma(src,len9)
ehma10=f_ehma(src,len10)

tema1=f_tema(src,len1)
tema2=f_tema(src,len2)
tema3=f_tema(src,len3)
tema4=f_tema(src,len4)
tema5=f_tema(src,len5)
tema6=f_tema(src,len6)
tema7=f_tema(src,len7)
tema8=f_tema(src,len8)
tema9=f_tema(src,len9)
tema10=f_tema(src,len10)

tillson1=f_tillson(src,len1,a1)
tillson2=f_tillson(src,len2,a1)
tillson3=f_tillson(src,len3,a1)
tillson4=f_tillson(src,len4,a1)
tillson5=f_tillson(src,len5,a1)
tillson6=f_tillson(src,len6,a1)
tillson7=f_tillson(src,len7,a1)
tillson8=f_tillson(src,len8,a1)
tillson9=f_tillson(src,len9,a1)
tillson10=f_tillson(src,len10,a1)

linreg1=ta.linreg(src,len1,linregoffset)
linreg2=ta.linreg(src,len2,linregoffset)
linreg3=ta.linreg(src,len3,linregoffset)
linreg4=ta.linreg(src,len4,linregoffset)
linreg5=ta.linreg(src,len5,linregoffset)
linreg6=ta.linreg(src,len6,linregoffset)
linreg7=ta.linreg(src,len7,linregoffset)
linreg8=ta.linreg(src,len8,linregoffset)
linreg9=ta.linreg(src,len9,linregoffset)
linreg10=ta.linreg(src,len10,linregoffset)

alma1=ta.alma(src,len1,almaoffset,almasigma)
alma2=ta.alma(src,len2,almaoffset,almasigma)
alma3=ta.alma(src,len3,almaoffset,almasigma)
alma4=ta.alma(src,len4,almaoffset,almasigma)
alma5=ta.alma(src,len5,almaoffset,almasigma)
alma6=ta.alma(src,len6,almaoffset,almasigma)
alma7=ta.alma(src,len7,almaoffset,almasigma)
alma8=ta.alma(src,len8,almaoffset,almasigma)
alma9=ta.alma(src,len9,almaoffset,almasigma)
alma10=ta.alma(src,len10,almaoffset,almasigma)

//logic
smacounter1 = sma1 >= sma1[1] ? '+' : '-'
smacounter2 = sma2 >= sma2[1] ? '+' : '-'
smacounter3 = sma3 >= sma3[1] ? '+' : '-'
smacounter4 = sma4 >= sma4[1] ? '+' : '-'
smacounter5 = sma5 >= sma5[1] ? '+' : '-'
smacounter6 = sma6 >= sma6[1] ? '+' : '-'
smacounter7 = sma7 >= sma7[1] ? '+' : '-'
smacounter8 = sma8 >= sma8[1] ? '+' : '-'
smacounter9 = sma9 >= sma9[1] ? '+' : '-'
smacounter10 = sma10 >= sma10[1] ? '+' : '-'
smacolor1 = smacounter1 == '+' ? buycolor : sellcolor
smacolor2 = smacounter2 == '+' ? buycolor : sellcolor
smacolor3 = smacounter3 == '+' ? buycolor : sellcolor
smacolor4 = smacounter4 == '+' ? buycolor : sellcolor
smacolor5 = smacounter5 == '+' ? buycolor : sellcolor
smacolor6 = smacounter6 == '+' ? buycolor : sellcolor
smacolor7 = smacounter7 == '+' ? buycolor : sellcolor
smacolor8 = smacounter8 == '+' ? buycolor : sellcolor
smacolor9 = smacounter9 == '+' ? buycolor : sellcolor
smacolor10 = smacounter10 == '+' ? buycolor : sellcolor

emacounter1 = ema1 >= ema1[1] ? '+' : '-'
emacounter2 = ema2 >= ema2[1] ? '+' : '-'
emacounter3 = ema3 >= ema3[1] ? '+' : '-'
emacounter4 = ema4 >= ema4[1] ? '+' : '-'
emacounter5 = ema5 >= ema5[1] ? '+' : '-'
emacounter6 = ema6 >= ema6[1] ? '+' : '-'
emacounter7 = ema7 >= ema7[1] ? '+' : '-'
emacounter8 = ema8 >= ema8[1] ? '+' : '-'
emacounter9 = ema9 >= ema9[1] ? '+' : '-'
emacounter10 = ema10 >= ema10[1] ? '+' : '-'
emacolor1 = emacounter1 == '+' ? buycolor : sellcolor
emacolor2 = emacounter2 == '+' ? buycolor : sellcolor
emacolor3 = emacounter3 == '+' ? buycolor : sellcolor
emacolor4 = emacounter4 == '+' ? buycolor : sellcolor
emacolor5 = emacounter5 == '+' ? buycolor : sellcolor
emacolor6 = emacounter6 == '+' ? buycolor : sellcolor
emacolor7 = emacounter7 == '+' ? buycolor : sellcolor
emacolor8 = emacounter8 == '+' ? buycolor : sellcolor
emacolor9 = emacounter9 == '+' ? buycolor : sellcolor
emacolor10 = emacounter10 == '+' ? buycolor : sellcolor

rmacounter1 = rma1 >= rma1[1] ? '+' : '-'
rmacounter2 = rma2 >= rma2[1] ? '+' : '-'
rmacounter3 = rma3 >= rma3[1] ? '+' : '-'
rmacounter4 = rma4 >= rma4[1] ? '+' : '-'
rmacounter5 = rma5 >= rma5[1] ? '+' : '-'
rmacounter6 = rma6 >= rma6[1] ? '+' : '-'
rmacounter7 = rma7 >= rma7[1] ? '+' : '-'
rmacounter8 = rma8 >= rma8[1] ? '+' : '-'
rmacounter9 = rma9 >= rma9[1] ? '+' : '-'
rmacounter10 = rma10 >= rma10[1] ? '+' : '-'
rmacolor1 = rmacounter1 == '+' ? buycolor : sellcolor
rmacolor2 = rmacounter2 == '+' ? buycolor : sellcolor
rmacolor3 = rmacounter3 == '+' ? buycolor : sellcolor
rmacolor4 = rmacounter4 == '+' ? buycolor : sellcolor
rmacolor5 = rmacounter5 == '+' ? buycolor : sellcolor
rmacolor6 = rmacounter6 == '+' ? buycolor : sellcolor
rmacolor7 = rmacounter7 == '+' ? buycolor : sellcolor
rmacolor8 = rmacounter8 == '+' ? buycolor : sellcolor
rmacolor9 = rmacounter9 == '+' ? buycolor : sellcolor
rmacolor10 = rmacounter10 == '+' ? buycolor : sellcolor

wmacounter1 = wma1 >= wma1[1] ? '+' : '-'
wmacounter2 = wma2 >= wma2[1] ? '+' : '-'
wmacounter3 = wma3 >= wma3[1] ? '+' : '-'
wmacounter4 = wma4 >= wma4[1] ? '+' : '-'
wmacounter5 = wma5 >= wma5[1] ? '+' : '-'
wmacounter6 = wma6 >= wma6[1] ? '+' : '-'
wmacounter7 = wma7 >= wma7[1] ? '+' : '-'
wmacounter8 = wma8 >= wma8[1] ? '+' : '-'
wmacounter9 = wma9 >= wma9[1] ? '+' : '-'
wmacounter10 = wma10 >= wma10[1] ? '+' : '-'
wmacolor1 = wmacounter1 == '+' ? buycolor : sellcolor
wmacolor2 = wmacounter2 == '+' ? buycolor : sellcolor
wmacolor3 = wmacounter3 == '+' ? buycolor : sellcolor
wmacolor4 = wmacounter4 == '+' ? buycolor : sellcolor
wmacolor5 = wmacounter5 == '+' ? buycolor : sellcolor
wmacolor6 = wmacounter6 == '+' ? buycolor : sellcolor
wmacolor7 = wmacounter7 == '+' ? buycolor : sellcolor
wmacolor8 = wmacounter8 == '+' ? buycolor : sellcolor
wmacolor9 = wmacounter9 == '+' ? buycolor : sellcolor
wmacolor10 = wmacounter10 == '+' ? buycolor : sellcolor

vwmacounter1 = vwma1 >= vwma1[1] ? '+' : '-'
vwmacounter2 = vwma2 >= vwma2[1] ? '+' : '-'
vwmacounter3 = vwma3 >= vwma3[1] ? '+' : '-'
vwmacounter4 = vwma4 >= vwma4[1] ? '+' : '-'
vwmacounter5 = vwma5 >= vwma5[1] ? '+' : '-'
vwmacounter6 = vwma6 >= vwma6[1] ? '+' : '-'
vwmacounter7 = vwma7 >= vwma7[1] ? '+' : '-'
vwmacounter8 = vwma8 >= vwma8[1] ? '+' : '-'
vwmacounter9 = vwma9 >= vwma9[1] ? '+' : '-'
vwmacounter10 = vwma10 >= vwma10[1] ? '+' : '-'
vwmacolor1 = vwmacounter1 == '+' ? buycolor : sellcolor
vwmacolor2 = vwmacounter2 == '+' ? buycolor : sellcolor
vwmacolor3 = vwmacounter3 == '+' ? buycolor : sellcolor
vwmacolor4 = vwmacounter4 == '+' ? buycolor : sellcolor
vwmacolor5 = vwmacounter5 == '+' ? buycolor : sellcolor
vwmacolor6 = vwmacounter6 == '+' ? buycolor : sellcolor
vwmacolor7 = vwmacounter7 == '+' ? buycolor : sellcolor
vwmacolor8 = vwmacounter8 == '+' ? buycolor : sellcolor
vwmacolor9 = vwmacounter9 == '+' ? buycolor : sellcolor
vwmacolor10 = vwmacounter10 == '+' ? buycolor : sellcolor

hmacounter1 = hma1 >= hma1[1] ? '+' : '-'
hmacounter2 = hma2 >= hma2[1] ? '+' : '-'
hmacounter3 = hma3 >= hma3[1] ? '+' : '-'
hmacounter4 = hma4 >= hma4[1] ? '+' : '-'
hmacounter5 = hma5 >= hma5[1] ? '+' : '-'
hmacounter6 = hma6 >= hma6[1] ? '+' : '-'
hmacounter7 = hma7 >= hma7[1] ? '+' : '-'
hmacounter8 = hma8 >= hma8[1] ? '+' : '-'
hmacounter9 = hma9 >= hma9[1] ? '+' : '-'
hmacounter10 = hma10 >= hma10[1] ? '+' : '-'
hmacolor1 = hmacounter1 == '+' ? buycolor : sellcolor
hmacolor2 = hmacounter2 == '+' ? buycolor : sellcolor
hmacolor3 = hmacounter3 == '+' ? buycolor : sellcolor
hmacolor4 = hmacounter4 == '+' ? buycolor : sellcolor
hmacolor5 = hmacounter5 == '+' ? buycolor : sellcolor
hmacolor6 = hmacounter6 == '+' ? buycolor : sellcolor
hmacolor7 = hmacounter7 == '+' ? buycolor : sellcolor
hmacolor8 = hmacounter8 == '+' ? buycolor : sellcolor
hmacolor9 = hmacounter9 == '+' ? buycolor : sellcolor
hmacolor10 = hmacounter10 == '+' ? buycolor : sellcolor

ehmacounter1 = ehma1 >= ehma1[1] ? '+' : '-'
ehmacounter2 = ehma2 >= ehma2[1] ? '+' : '-'
ehmacounter3 = ehma3 >= ehma3[1] ? '+' : '-'
ehmacounter4 = ehma4 >= ehma4[1] ? '+' : '-'
ehmacounter5 = ehma5 >= ehma5[1] ? '+' : '-'
ehmacounter6 = ehma6 >= ehma6[1] ? '+' : '-'
ehmacounter7 = ehma7 >= ehma7[1] ? '+' : '-'
ehmacounter8 = ehma8 >= ehma8[1] ? '+' : '-'
ehmacounter9 = ehma9 >= ehma9[1] ? '+' : '-'
ehmacounter10 = ehma10 >= ehma10[1] ? '+' : '-'
ehmacolor1 = ehmacounter1 == '+' ? buycolor : sellcolor
ehmacolor2 = ehmacounter2 == '+' ? buycolor : sellcolor
ehmacolor3 = ehmacounter3 == '+' ? buycolor : sellcolor
ehmacolor4 = ehmacounter4 == '+' ? buycolor : sellcolor
ehmacolor5 = ehmacounter5 == '+' ? buycolor : sellcolor
ehmacolor6 = ehmacounter6 == '+' ? buycolor : sellcolor
ehmacolor7 = ehmacounter7 == '+' ? buycolor : sellcolor
ehmacolor8 = ehmacounter8 == '+' ? buycolor : sellcolor
ehmacolor9 = ehmacounter9 == '+' ? buycolor : sellcolor
ehmacolor10 = ehmacounter10 == '+' ? buycolor : sellcolor

temacounter1 = tema1 >= tema1[1] ? '+' : '-'
temacounter2 = tema2 >= tema2[1] ? '+' : '-'
temacounter3 = tema3 >= tema3[1] ? '+' : '-'
temacounter4 = tema4 >= tema4[1] ? '+' : '-'
temacounter5 = tema5 >= tema5[1] ? '+' : '-'
temacounter6 = tema6 >= tema6[1] ? '+' : '-'
temacounter7 = tema7 >= tema7[1] ? '+' : '-'
temacounter8 = tema8 >= tema8[1] ? '+' : '-'
temacounter9 = tema9 >= tema9[1] ? '+' : '-'
temacounter10 = tema10 >= tema10[1] ? '+' : '-'
temacolor1 = temacounter1 == '+' ? buycolor : sellcolor
temacolor2 = temacounter2 == '+' ? buycolor : sellcolor
temacolor3 = temacounter3 == '+' ? buycolor : sellcolor
temacolor4 = temacounter4 == '+' ? buycolor : sellcolor
temacolor5 = temacounter5 == '+' ? buycolor : sellcolor
temacolor6 = temacounter6 == '+' ? buycolor : sellcolor
temacolor7 = temacounter7 == '+' ? buycolor : sellcolor
temacolor8 = temacounter8 == '+' ? buycolor : sellcolor
temacolor9 = temacounter9 == '+' ? buycolor : sellcolor
temacolor10 = temacounter10 == '+' ? buycolor : sellcolor

tillsoncounter1 = tillson1 >= tillson1[1] ? '+' : '-'
tillsoncounter2 = tillson2 >= tillson2[1] ? '+' : '-'
tillsoncounter3 = tillson3 >= tillson3[1] ? '+' : '-'
tillsoncounter4 = tillson4 >= tillson4[1] ? '+' : '-'
tillsoncounter5 = tillson5 >= tillson5[1] ? '+' : '-'
tillsoncounter6 = tillson6 >= tillson6[1] ? '+' : '-'
tillsoncounter7 = tillson7 >= tillson7[1] ? '+' : '-'
tillsoncounter8 = tillson8 >= tillson8[1] ? '+' : '-'
tillsoncounter9 = tillson9 >= tillson9[1] ? '+' : '-'
tillsoncounter10 = tillson10 >= tillson10[1] ? '+' : '-'
tillsoncolor1 = tillsoncounter1 == '+' ? buycolor : sellcolor
tillsoncolor2 = tillsoncounter2 == '+' ? buycolor : sellcolor
tillsoncolor3 = tillsoncounter3 == '+' ? buycolor : sellcolor
tillsoncolor4 = tillsoncounter4 == '+' ? buycolor : sellcolor
tillsoncolor5 = tillsoncounter5 == '+' ? buycolor : sellcolor
tillsoncolor6 = tillsoncounter6 == '+' ? buycolor : sellcolor
tillsoncolor7 = tillsoncounter7 == '+' ? buycolor : sellcolor
tillsoncolor8 = tillsoncounter8 == '+' ? buycolor : sellcolor
tillsoncolor9 = tillsoncounter9 == '+' ? buycolor : sellcolor
tillsoncolor10 = tillsoncounter10 == '+' ? buycolor : sellcolor

linregcounter1 = linreg1 >= linreg1[1] ? '+' : '-'
linregcounter2 = linreg2 >= linreg2[1] ? '+' : '-'
linregcounter3 = linreg3 >= linreg3[1] ? '+' : '-'
linregcounter4 = linreg4 >= linreg4[1] ? '+' : '-'
linregcounter5 = linreg5 >= linreg5[1] ? '+' : '-'
linregcounter6 = linreg6 >= linreg6[1] ? '+' : '-'
linregcounter7 = linreg7 >= linreg7[1] ? '+' : '-'
linregcounter8 = linreg8 >= linreg8[1] ? '+' : '-'
linregcounter9 = linreg9 >= linreg9[1] ? '+' : '-'
linregcounter10 = linreg10 >= linreg10[1] ? '+' : '-'
linregcolor1 = linregcounter1 == '+' ? buycolor : sellcolor
linregcolor2 = linregcounter2 == '+' ? buycolor : sellcolor
linregcolor3 = linregcounter3 == '+' ? buycolor : sellcolor
linregcolor4 = linregcounter4 == '+' ? buycolor : sellcolor
linregcolor5 = linregcounter5 == '+' ? buycolor : sellcolor
linregcolor6 = linregcounter6 == '+' ? buycolor : sellcolor
linregcolor7 = linregcounter7 == '+' ? buycolor : sellcolor
linregcolor8 = linregcounter8 == '+' ? buycolor : sellcolor
linregcolor9 = linregcounter9 == '+' ? buycolor : sellcolor
linregcolor10 = linregcounter10 == '+' ? buycolor : sellcolor

almacounter1 = alma1 >= alma1[1] ? '+' : '-'
almacounter2 = alma2 >= alma2[1] ? '+' : '-'
almacounter3 = alma3 >= alma3[1] ? '+' : '-'
almacounter4 = alma4 >= alma4[1] ? '+' : '-'
almacounter5 = alma5 >= alma5[1] ? '+' : '-'
almacounter6 = alma6 >= alma6[1] ? '+' : '-'
almacounter7 = alma7 >= alma7[1] ? '+' : '-'
almacounter8 = alma8 >= alma8[1] ? '+' : '-'
almacounter9 = alma9 >= alma9[1] ? '+' : '-'
almacounter10 = alma10 >= alma10[1] ? '+' : '-'
almacolor1 = almacounter1 == '+' ? buycolor : sellcolor
almacolor2 = almacounter2 == '+' ? buycolor : sellcolor
almacolor3 = almacounter3 == '+' ? buycolor : sellcolor
almacolor4 = almacounter4 == '+' ? buycolor : sellcolor
almacolor5 = almacounter5 == '+' ? buycolor : sellcolor
almacolor6 = almacounter6 == '+' ? buycolor : sellcolor
almacolor7 = almacounter7 == '+' ? buycolor : sellcolor
almacolor8 = almacounter8 == '+' ? buycolor : sellcolor
almacolor9 = almacounter9 == '+' ? buycolor : sellcolor
almacolor10 = almacounter10 == '+' ? buycolor : sellcolor

//counting mobile
smamobilecounter1 = 0.0
emamobilecounter1 = 0.0
rmamobilecounter1 = 0.0
wmamobilecounter1 = 0.0
vwmamobilecounter1 = 0.0
hmamobilecounter1 = 0.0
ehmamobilecounter1 = 0.0
temamobilecounter1 = 0.0
tillsonmobilecounter1 = 0.0
linregmobilecounter1 = 0.0
almamobilecounter1 = 0.0

smamobilecounter2 = sma2 >= sma2[1] ? smamobilecounter1 + 1 : smamobilecounter1 - 1
smamobilecounter3 = sma3 >= sma3[1] ? smamobilecounter2 + 1 : smamobilecounter2 - 1
smamobilecounter4 = sma4 >= sma4[1] ? smamobilecounter3 + 1 : smamobilecounter3 - 1
smamobilecounter5 = sma5 >= sma5[1] ? smamobilecounter4 + 1 : smamobilecounter4 - 1
smamobilecounter6 = sma6 >= sma6[1] ? smamobilecounter5 + 1 : smamobilecounter5 - 1
smamobilecounter7 = sma7 >= sma7[1] ? smamobilecounter6 + 1 : smamobilecounter6 - 1
smamobilecounter8 = sma8 >= sma8[1] ? smamobilecounter7 + 1 : smamobilecounter7 - 1
smamobilecounter9 = sma9 >= sma9[1] ? smamobilecounter8 + 1 : smamobilecounter8 - 1
smamobilecounter10 = sma10 >= sma10[1] ? smamobilecounter9 + 1 : smamobilecounter9 - 1
smamobilecounter11 = sma1 >= sma1[1] ? smamobilecounter10 + 1 : smamobilecounter10 - 1

emamobilecounter2 = ema2 >= ema2[1] ? emamobilecounter1 + 1 : emamobilecounter1 - 1
emamobilecounter3 = ema3 >= ema3[1] ? emamobilecounter2 + 1 : emamobilecounter2 - 1
emamobilecounter4 = ema4 >= ema4[1] ? emamobilecounter3 + 1 : emamobilecounter3 - 1
emamobilecounter5 = ema5 >= ema5[1] ? emamobilecounter4 + 1 : emamobilecounter4 - 1
emamobilecounter6 = ema6 >= ema6[1] ? emamobilecounter5 + 1 : emamobilecounter5 - 1
emamobilecounter7 = ema7 >= ema7[1] ? emamobilecounter6 + 1 : emamobilecounter6 - 1
emamobilecounter8 = ema8 >= ema8[1] ? emamobilecounter7 + 1 : emamobilecounter7 - 1
emamobilecounter9 = ema9 >= ema9[1] ? emamobilecounter8 + 1 : emamobilecounter8 - 1
emamobilecounter10 = ema10 >= ema10[1] ? emamobilecounter9 + 1 : emamobilecounter9 - 1
emamobilecounter11 = ema1 >= ema1[1] ? emamobilecounter10 + 1 : emamobilecounter10 - 1

rmamobilecounter2 = rma2 >= rma2[1] ? rmamobilecounter1 + 1 : rmamobilecounter1 - 1
rmamobilecounter3 = rma3 >= rma3[1] ? rmamobilecounter2 + 1 : rmamobilecounter2 - 1
rmamobilecounter4 = rma4 >= rma4[1] ? rmamobilecounter3 + 1 : rmamobilecounter3 - 1
rmamobilecounter5 = rma5 >= rma5[1] ? rmamobilecounter4 + 1 : rmamobilecounter4 - 1
rmamobilecounter6 = rma6 >= rma6[1] ? rmamobilecounter5 + 1 : rmamobilecounter5 - 1
rmamobilecounter7 = rma7 >= rma7[1] ? rmamobilecounter6 + 1 : rmamobilecounter6 - 1
rmamobilecounter8 = rma8 >= rma8[1] ? rmamobilecounter7 + 1 : rmamobilecounter7 - 1
rmamobilecounter9 = rma9 >= rma9[1] ? rmamobilecounter8 + 1 : rmamobilecounter8 - 1
rmamobilecounter10 = rma10 >= rma10[1] ? rmamobilecounter9 + 1 : rmamobilecounter9 - 1
rmamobilecounter11 = rma1 >= rma1[1] ? rmamobilecounter10 + 1 : rmamobilecounter10 - 1

wmamobilecounter2 = wma2 >= wma2[1] ? wmamobilecounter1 + 1 : wmamobilecounter1 - 1
wmamobilecounter3 = wma3 >= wma3[1] ? wmamobilecounter2 + 1 : wmamobilecounter2 - 1
wmamobilecounter4 = wma4 >= wma4[1] ? wmamobilecounter3 + 1 : wmamobilecounter3 - 1
wmamobilecounter5 = wma5 >= wma5[1] ? wmamobilecounter4 + 1 : wmamobilecounter4 - 1
wmamobilecounter6 = wma6 >= wma6[1] ? wmamobilecounter5 + 1 : wmamobilecounter5 - 1
wmamobilecounter7 = wma7 >= wma7[1] ? wmamobilecounter6 + 1 : wmamobilecounter6 - 1
wmamobilecounter8 = wma8 >= wma8[1] ? wmamobilecounter7 + 1 : wmamobilecounter7 - 1
wmamobilecounter9 = wma9 >= wma9[1] ? wmamobilecounter8 + 1 : wmamobilecounter8 - 1
wmamobilecounter10 = wma10 >= wma10[1] ? wmamobilecounter9 + 1 : wmamobilecounter9 - 1
wmamobilecounter11 = wma1 >= wma1[1] ? wmamobilecounter10 + 1 : wmamobilecounter10 - 1

vwmamobilecounter2 = vwma2 >= vwma2[1] ? vwmamobilecounter1 + 1 : vwmamobilecounter1 - 1
vwmamobilecounter3 = vwma3 >= vwma3[1] ? vwmamobilecounter2 + 1 : vwmamobilecounter2 - 1
vwmamobilecounter4 = vwma4 >= vwma4[1] ? vwmamobilecounter3 + 1 : vwmamobilecounter3 - 1
vwmamobilecounter5 = vwma5 >= vwma5[1] ? vwmamobilecounter4 + 1 : vwmamobilecounter4 - 1
vwmamobilecounter6 = vwma6 >= vwma6[1] ? vwmamobilecounter5 + 1 : vwmamobilecounter5 - 1
vwmamobilecounter7 = vwma7 >= vwma7[1] ? vwmamobilecounter6 + 1 : vwmamobilecounter6 - 1
vwmamobilecounter8 = vwma8 >= vwma8[1] ? vwmamobilecounter7 + 1 : vwmamobilecounter7 - 1
vwmamobilecounter9 = vwma9 >= vwma9[1] ? vwmamobilecounter8 + 1 : vwmamobilecounter8 - 1
vwmamobilecounter10 = vwma10 >= vwma10[1] ? vwmamobilecounter9 + 1 : vwmamobilecounter9 - 1
vwmamobilecounter11 = vwma1 >= vwma1[1] ? vwmamobilecounter10 + 1 : vwmamobilecounter10 - 1

hmamobilecounter2 = hma2 >= hma2[1] ? hmamobilecounter1 + 1 : hmamobilecounter1 - 1
hmamobilecounter3 = hma3 >= hma3[1] ? hmamobilecounter2 + 1 : hmamobilecounter2 - 1
hmamobilecounter4 = hma4 >= hma4[1] ? hmamobilecounter3 + 1 : hmamobilecounter3 - 1
hmamobilecounter5 = hma5 >= hma5[1] ? hmamobilecounter4 + 1 : hmamobilecounter4 - 1
hmamobilecounter6 = hma6 >= hma6[1] ? hmamobilecounter5 + 1 : hmamobilecounter5 - 1
hmamobilecounter7 = hma7 >= hma7[1] ? hmamobilecounter6 + 1 : hmamobilecounter6 - 1
hmamobilecounter8 = hma8 >= hma8[1] ? hmamobilecounter7 + 1 : hmamobilecounter7 - 1
hmamobilecounter9 = hma9 >= hma9[1] ? hmamobilecounter8 + 1 : hmamobilecounter8 - 1
hmamobilecounter10 = hma10 >= hma10[1] ? hmamobilecounter9 + 1 : hmamobilecounter9 - 1
hmamobilecounter11 = hma1 >= hma1[1] ? hmamobilecounter10 + 1 : hmamobilecounter10 - 1

ehmamobilecounter2 = ehma2 >= ehma2[1] ? ehmamobilecounter1 + 1 : ehmamobilecounter1 - 1
ehmamobilecounter3 = ehma3 >= ehma3[1] ? ehmamobilecounter2 + 1 : ehmamobilecounter2 - 1
ehmamobilecounter4 = ehma4 >= ehma4[1] ? ehmamobilecounter3 + 1 : ehmamobilecounter3 - 1
ehmamobilecounter5 = ehma5 >= ehma5[1] ? ehmamobilecounter4 + 1 : ehmamobilecounter4 - 1
ehmamobilecounter6 = ehma6 >= ehma6[1] ? ehmamobilecounter5 + 1 : ehmamobilecounter5 - 1
ehmamobilecounter7 = ehma7 >= ehma7[1] ? ehmamobilecounter6 + 1 : ehmamobilecounter6 - 1
ehmamobilecounter8 = ehma8 >= ehma8[1] ? ehmamobilecounter7 + 1 : ehmamobilecounter7 - 1
ehmamobilecounter9 = ehma9 >= ehma9[1] ? ehmamobilecounter8 + 1 : ehmamobilecounter8 - 1
ehmamobilecounter10 = ehma10 >= ehma10[1] ? ehmamobilecounter9 + 1 : ehmamobilecounter9 - 1
ehmamobilecounter11 = ehma1 >= ehma1[1] ? ehmamobilecounter10 + 1 : ehmamobilecounter10 - 1

temamobilecounter2 = tema2 >= tema2[1] ? temamobilecounter1 + 1 : temamobilecounter1 - 1
temamobilecounter3 = tema3 >= tema3[1] ? temamobilecounter2 + 1 : temamobilecounter2 - 1
temamobilecounter4 = tema4 >= tema4[1] ? temamobilecounter3 + 1 : temamobilecounter3 - 1
temamobilecounter5 = tema5 >= tema5[1] ? temamobilecounter4 + 1 : temamobilecounter4 - 1
temamobilecounter6 = tema6 >= tema6[1] ? temamobilecounter5 + 1 : temamobilecounter5 - 1
temamobilecounter7 = tema7 >= tema7[1] ? temamobilecounter6 + 1 : temamobilecounter6 - 1
temamobilecounter8 = tema8 >= tema8[1] ? temamobilecounter7 + 1 : temamobilecounter7 - 1
temamobilecounter9 = tema9 >= tema9[1] ? temamobilecounter8 + 1 : temamobilecounter8 - 1
temamobilecounter10 = tema10 >= tema10[1] ? temamobilecounter9 + 1 : temamobilecounter9 - 1
temamobilecounter11 = tema1 >= tema1[1] ? temamobilecounter10 + 1 : temamobilecounter10 - 1

tillsonmobilecounter2 = tillson2 >= tillson2[1] ? tillsonmobilecounter1 + 1 : tillsonmobilecounter1 - 1
tillsonmobilecounter3 = tillson3 >= tillson3[1] ? tillsonmobilecounter2 + 1 : tillsonmobilecounter2 - 1
tillsonmobilecounter4 = tillson4 >= tillson4[1] ? tillsonmobilecounter3 + 1 : tillsonmobilecounter3 - 1
tillsonmobilecounter5 = tillson5 >= tillson5[1] ? tillsonmobilecounter4 + 1 : tillsonmobilecounter4 - 1
tillsonmobilecounter6 = tillson6 >= tillson6[1] ? tillsonmobilecounter5 + 1 : tillsonmobilecounter5 - 1
tillsonmobilecounter7 = tillson7 >= tillson7[1] ? tillsonmobilecounter6 + 1 : tillsonmobilecounter6 - 1
tillsonmobilecounter8 = tillson8 >= tillson8[1] ? tillsonmobilecounter7 + 1 : tillsonmobilecounter7 - 1
tillsonmobilecounter9 = tillson9 >= tillson9[1] ? tillsonmobilecounter8 + 1 : tillsonmobilecounter8 - 1
tillsonmobilecounter10 = tillson10 >= tillson10[1] ? tillsonmobilecounter9 + 1 : tillsonmobilecounter9 - 1
tillsonmobilecounter11 = tillson1 >= tillson1[1] ? tillsonmobilecounter10 + 1 : tillsonmobilecounter10 - 1

linregmobilecounter2 = linreg2 >= linreg2[1] ? linregmobilecounter1 + 1 : linregmobilecounter1 - 1
linregmobilecounter3 = linreg3 >= linreg3[1] ? linregmobilecounter2 + 1 : linregmobilecounter2 - 1
linregmobilecounter4 = linreg4 >= linreg4[1] ? linregmobilecounter3 + 1 : linregmobilecounter3 - 1
linregmobilecounter5 = linreg5 >= linreg5[1] ? linregmobilecounter4 + 1 : linregmobilecounter4 - 1
linregmobilecounter6 = linreg6 >= linreg6[1] ? linregmobilecounter5 + 1 : linregmobilecounter5 - 1
linregmobilecounter7 = linreg7 >= linreg7[1] ? linregmobilecounter6 + 1 : linregmobilecounter6 - 1
linregmobilecounter8 = linreg8 >= linreg8[1] ? linregmobilecounter7 + 1 : linregmobilecounter7 - 1
linregmobilecounter9 = linreg9 >= linreg9[1] ? linregmobilecounter8 + 1 : linregmobilecounter8 - 1
linregmobilecounter10 = linreg10 >= linreg10[1] ? linregmobilecounter9 + 1 : linregmobilecounter9 - 1
linregmobilecounter11 = linreg1 >= linreg1[1] ? linregmobilecounter10 + 1 : linregmobilecounter10 - 1

almamobilecounter2 = alma2 >= alma2[1] ? almamobilecounter1 + 1 : almamobilecounter1 - 1
almamobilecounter3 = alma3 >= alma3[1] ? almamobilecounter2 + 1 : almamobilecounter2 - 1
almamobilecounter4 = alma4 >= alma4[1] ? almamobilecounter3 + 1 : almamobilecounter3 - 1
almamobilecounter5 = alma5 >= alma5[1] ? almamobilecounter4 + 1 : almamobilecounter4 - 1
almamobilecounter6 = alma6 >= alma6[1] ? almamobilecounter5 + 1 : almamobilecounter5 - 1
almamobilecounter7 = alma7 >= alma7[1] ? almamobilecounter6 + 1 : almamobilecounter6 - 1
almamobilecounter8 = alma8 >= alma8[1] ? almamobilecounter7 + 1 : almamobilecounter7 - 1
almamobilecounter9 = alma9 >= alma9[1] ? almamobilecounter8 + 1 : almamobilecounter8 - 1
almamobilecounter10 = alma10 >= alma10[1] ? almamobilecounter9 + 1 : almamobilecounter9 - 1
almamobilecounter11 = alma1 >= alma1[1] ? almamobilecounter10 + 1 : almamobilecounter10 - 1

//mobilescores
smamobilescore = smamobilecounter11
emamobilescore = emamobilecounter11
rmamobilescore = rmamobilecounter11
wmamobilescore = wmamobilecounter11
vwmamobilescore = vwmamobilecounter11
hmamobilescore = hmamobilecounter11
ehmamobilescore = ehmamobilecounter11
temamobilescore = temamobilecounter11
tillsonmobilescore = tillsonmobilecounter11
linregmobilescore = linregmobilecounter11
almamobilescore = almamobilecounter11

//mobile table color logic
smacolor = if smamobilescore > 0
    buycolor
else if smamobilescore < 0
    sellcolor
else
    neutralcolor
emacolor = if emamobilescore > 0
    buycolor
else if emamobilescore < 0
    sellcolor
else
    neutralcolor
rmacolor = if rmamobilescore > 0
    buycolor
else if rmamobilescore < 0
    sellcolor
else
    neutralcolor
wmacolor = if wmamobilescore > 0
    buycolor
else if wmamobilescore < 0
    sellcolor
else
    neutralcolor
vwmacolor = if vwmamobilescore > 0
    buycolor
else if vwmamobilescore < 0
    sellcolor
else
    neutralcolor
hmacolor = if hmamobilescore > 0
    buycolor
else if hmamobilescore < 0
    sellcolor
else
    neutralcolor
ehmacolor = if ehmamobilescore > 0
    buycolor
else if ehmamobilescore < 0
    sellcolor
else
    neutralcolor
temacolor = if temamobilescore > 0
    buycolor
else if temamobilescore < 0
    sellcolor
else
    neutralcolor
tillsoncolor = if tillsonmobilescore > 0
    buycolor
else if tillsonmobilescore < 0
    sellcolor
else
    neutralcolor
linregcolor = if linregmobilescore > 0
    buycolor
else if linregmobilescore < 0
    sellcolor
else
    neutralcolor
almacolor = if almamobilescore > 0
    buycolor
else if almamobilescore < 0
    sellcolor
else
    neutralcolor
    
//table panel mobile
ncolumns = mobilefriendly == true ? 2 : 11
var table panel = table.new(i_tableYpos + '_' + i_tableXpos, ncolumns, 12)
if barstate.islast and mobilefriendly == true
    table.cell(panel, 0, 0, 'MA', text_color=texcolor, bgcolor=neutralcolor)
    table.cell(panel, 1, 0, '# Bull', text_color=texcolor, bgcolor=neutralcolor)
    if smaon == true
        table.cell(panel, 0, 1, 'SMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 1, str.tostring(smamobilescore), text_color=texcolor, bgcolor = smacolor)
    if emaon == true
        table.cell(panel, 0, 2, 'EMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 2, str.tostring(emamobilescore), text_color=texcolor, bgcolor = emacolor)
    if rmaon == true
        table.cell(panel, 0, 3, 'RMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 3, str.tostring(rmamobilescore), text_color=texcolor, bgcolor = rmacolor)
    if wmaon == true
        table.cell(panel, 0, 4, 'WMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 4, str.tostring(wmamobilescore), text_color=texcolor, bgcolor = wmacolor)
    if vwmaon == true
        table.cell(panel, 0, 5, 'VWMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 5, str.tostring(vwmamobilescore), text_color=texcolor, bgcolor = vwmacolor)
    if hmaon == true
        table.cell(panel, 0, 6, 'HMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 6, str.tostring(hmamobilescore), text_color=texcolor, bgcolor = hmacolor)
    if ehmaon == true
        table.cell(panel, 0, 7, 'EHMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 7, str.tostring(ehmamobilescore), text_color=texcolor, bgcolor = ehmacolor)
    if temaon == true
        table.cell(panel, 0, 8, 'TEMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 8, str.tostring(temamobilescore), text_color=texcolor, bgcolor = temacolor)
    if tillsonon == true
        table.cell(panel, 0, 9, 'Tillson T3', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 9, str.tostring(tillsonmobilescore), text_color=texcolor, bgcolor = tillsoncolor)
    if linregon == true
        table.cell(panel, 0, 10, 'LSMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 10, str.tostring(linregmobilescore), text_color=texcolor, bgcolor = linregcolor)
    if almaon == true
        table.cell(panel, 0, 11, 'ALMA', text_color=texcolor, bgcolor=neutralcolor)
        table.cell(panel, 1, 11, str.tostring(almamobilescore), text_color=texcolor, bgcolor = almacolor)
else if barstate.islast and mobilefriendly == false
    table.cell(panel, 0, 0, 'MA', text_color=texcolor, bgcolor=neutralcolor)
    if len1on == true
        table.cell(panel, 1, 0, str.tostring(len1), text_color=texcolor, bgcolor=neutralcolor)
    if len2on == true
        table.cell(panel, 2, 0, str.tostring(len2), text_color=texcolor, bgcolor=neutralcolor)
    if len3on == true    
        table.cell(panel, 3, 0, str.tostring(len3), text_color=texcolor, bgcolor=neutralcolor)
    if len4on == true    
        table.cell(panel, 4, 0, str.tostring(len4), text_color=texcolor, bgcolor=neutralcolor)
    if len5on == true    
        table.cell(panel, 5, 0, str.tostring(len5), text_color=texcolor, bgcolor=neutralcolor)
    if len6on == true    
        table.cell(panel, 6, 0, str.tostring(len6), text_color=texcolor, bgcolor=neutralcolor)
    if len7on == true    
        table.cell(panel, 7, 0, str.tostring(len7), text_color=texcolor, bgcolor=neutralcolor)
    if len8on == true    
        table.cell(panel, 8, 0, str.tostring(len8), text_color=texcolor, bgcolor=neutralcolor)
    if len9on == true    
        table.cell(panel, 9, 0, str.tostring(len9), text_color=texcolor, bgcolor=neutralcolor)
    if len10on == true    
        table.cell(panel, 10, 0, str.tostring(len10), text_color=texcolor, bgcolor=neutralcolor)    
    if smaon == true
        table.cell(panel, 0,1, 'SMA', text_color=texcolor, bgcolor=neutralcolor)
    if smaon == true and len1on == true
        table.cell(panel, 1,1, str.tostring(smacounter1), text_color=texcolor, bgcolor = smacolor1)
    if smaon == true and len2on == true
        table.cell(panel, 2,1, str.tostring(smacounter2), text_color=texcolor, bgcolor = smacolor2)
    if smaon == true and len3on == true
        table.cell(panel, 3,1, str.tostring(smacounter3), text_color=texcolor, bgcolor = smacolor3)
    if smaon == true and len4on == true
        table.cell(panel, 4,1, str.tostring(smacounter4), text_color=texcolor, bgcolor = smacolor4)
    if smaon == true and len5on == true
        table.cell(panel, 5,1, str.tostring(smacounter5), text_color=texcolor, bgcolor = smacolor5)
    if smaon == true and len6on == true
        table.cell(panel, 6,1, str.tostring(smacounter6), text_color=texcolor, bgcolor = smacolor6)
    if smaon == true and len7on == true
        table.cell(panel, 7,1, str.tostring(smacounter7), text_color=texcolor, bgcolor = smacolor7)
    if smaon == true and len8on == true
        table.cell(panel, 8,1, str.tostring(smacounter8), text_color=texcolor, bgcolor = smacolor8)
    if smaon == true and len9on == true
        table.cell(panel, 9,1, str.tostring(smacounter9), text_color=texcolor, bgcolor = smacolor9)
    if smaon == true and len10on == true
        table.cell(panel, 10,1, str.tostring(smacounter10), text_color=texcolor, bgcolor = smacolor10)
    if emaon == true
        table.cell(panel, 0,2, 'EMA', text_color=texcolor, bgcolor=neutralcolor)
    if emaon == true and len1on == true
        table.cell(panel, 1,2, str.tostring(emacounter1), text_color=texcolor, bgcolor = emacolor1)
    if emaon == true and len2on == true
        table.cell(panel, 2,2, str.tostring(emacounter2), text_color=texcolor, bgcolor = emacolor2)
    if emaon == true and len3on == true
        table.cell(panel, 3,2, str.tostring(emacounter3), text_color=texcolor, bgcolor = emacolor3)
    if emaon == true and len4on == true
        table.cell(panel, 4,2, str.tostring(emacounter4), text_color=texcolor, bgcolor = emacolor4)
    if emaon == true and len5on == true
        table.cell(panel, 5,2, str.tostring(emacounter5), text_color=texcolor, bgcolor = emacolor5)
    if emaon == true and len6on == true
        table.cell(panel, 6,2, str.tostring(emacounter6), text_color=texcolor, bgcolor = emacolor6)
    if emaon == true and len7on == true
        table.cell(panel, 7,2, str.tostring(emacounter7), text_color=texcolor, bgcolor = emacolor7)
    if emaon == true and len8on == true
        table.cell(panel, 8,2, str.tostring(emacounter8), text_color=texcolor, bgcolor = emacolor8)
    if emaon == true and len9on == true
        table.cell(panel, 9,2, str.tostring(emacounter9), text_color=texcolor, bgcolor = emacolor9)
    if emaon == true and len10on == true
        table.cell(panel, 10,2, str.tostring(emacounter10), text_color=texcolor, bgcolor = emacolor10)
    if rmaon == true
        table.cell(panel, 0,3, 'RMA/SMMA', text_color=texcolor, bgcolor=neutralcolor)
    if rmaon == true and len1on == true
        table.cell(panel, 1,3, str.tostring(rmacounter1), text_color=texcolor, bgcolor = rmacolor1)
    if rmaon == true and len2on == true
        table.cell(panel, 2,3, str.tostring(rmacounter2), text_color=texcolor, bgcolor = rmacolor2)
    if rmaon == true and len3on == true
        table.cell(panel, 3,3, str.tostring(rmacounter3), text_color=texcolor, bgcolor = rmacolor3)
    if rmaon == true and len4on == true
        table.cell(panel, 4,3, str.tostring(rmacounter4), text_color=texcolor, bgcolor = rmacolor4)
    if rmaon == true and len5on == true
        table.cell(panel, 5,3, str.tostring(rmacounter5), text_color=texcolor, bgcolor = rmacolor5)
    if rmaon == true and len6on == true
        table.cell(panel, 6,3, str.tostring(rmacounter6), text_color=texcolor, bgcolor = rmacolor6)
    if rmaon == true and len7on == true
        table.cell(panel, 7,3, str.tostring(rmacounter7), text_color=texcolor, bgcolor = rmacolor7)
    if rmaon == true and len8on == true
        table.cell(panel, 8,3, str.tostring(rmacounter8), text_color=texcolor, bgcolor = rmacolor8)
    if rmaon == true and len9on == true
        table.cell(panel, 9,3, str.tostring(rmacounter9), text_color=texcolor, bgcolor = rmacolor9)
    if rmaon == true and len10on == true
        table.cell(panel, 10,3, str.tostring(rmacounter10), text_color=texcolor, bgcolor = rmacolor10)
    if wmaon == true
        table.cell(panel, 0,4, 'WMA', text_color=texcolor, bgcolor=neutralcolor)
    if wmaon == true and len1on == true
        table.cell(panel, 1,4, str.tostring(wmacounter1), text_color=texcolor, bgcolor = wmacolor1)
    if wmaon == true and len2on == true
        table.cell(panel, 2,4, str.tostring(wmacounter2), text_color=texcolor, bgcolor = wmacolor2)
    if wmaon == true and len3on == true
        table.cell(panel, 3,4, str.tostring(wmacounter3), text_color=texcolor, bgcolor = wmacolor3)
    if wmaon == true and len4on == true
        table.cell(panel, 4,4, str.tostring(wmacounter4), text_color=texcolor, bgcolor = wmacolor4)
    if wmaon == true and len5on == true
        table.cell(panel, 5,4, str.tostring(wmacounter5), text_color=texcolor, bgcolor = wmacolor5)
    if wmaon == true and len6on == true
        table.cell(panel, 6,4, str.tostring(wmacounter6), text_color=texcolor, bgcolor = wmacolor6)
    if wmaon == true and len7on == true
        table.cell(panel, 7,4, str.tostring(wmacounter7), text_color=texcolor, bgcolor = wmacolor7)
    if wmaon == true and len8on == true
        table.cell(panel, 8,4, str.tostring(wmacounter8), text_color=texcolor, bgcolor = wmacolor8)
    if wmaon == true and len9on == true
        table.cell(panel, 9,4, str.tostring(wmacounter9), text_color=texcolor, bgcolor = wmacolor9)
    if wmaon == true and len10on == true
        table.cell(panel, 10,4, str.tostring(wmacounter10), text_color=texcolor, bgcolor = wmacolor10)
    if vwmaon == true
        table.cell(panel, 0,5, 'VWMA', text_color=texcolor, bgcolor=neutralcolor)
    if vwmaon == true and len1on == true
        table.cell(panel, 1,5, str.tostring(vwmacounter1), text_color=texcolor, bgcolor = vwmacolor1)
    if vwmaon == true and len2on == true
        table.cell(panel, 2,5, str.tostring(vwmacounter2), text_color=texcolor, bgcolor = vwmacolor2)
    if vwmaon == true and len3on == true
        table.cell(panel, 3,5, str.tostring(vwmacounter3), text_color=texcolor, bgcolor = vwmacolor3)
    if vwmaon == true and len4on == true
        table.cell(panel, 4,5, str.tostring(vwmacounter4), text_color=texcolor, bgcolor = vwmacolor4)
    if vwmaon == true and len5on == true
        table.cell(panel, 5,5, str.tostring(vwmacounter5), text_color=texcolor, bgcolor = vwmacolor5)
    if vwmaon == true and len6on == true
        table.cell(panel, 6,5, str.tostring(vwmacounter6), text_color=texcolor, bgcolor = vwmacolor6)
    if vwmaon == true and len7on == true
        table.cell(panel, 7,5, str.tostring(vwmacounter7), text_color=texcolor, bgcolor = vwmacolor7)
    if vwmaon == true and len8on == true
        table.cell(panel, 8,5, str.tostring(vwmacounter8), text_color=texcolor, bgcolor = vwmacolor8)
    if vwmaon == true and len9on == true
        table.cell(panel, 9,5, str.tostring(vwmacounter9), text_color=texcolor, bgcolor = vwmacolor9)
    if vwmaon == true and len10on == true
        table.cell(panel, 10,5, str.tostring(vwmacounter10), text_color=texcolor, bgcolor = vwmacolor10)
    if hmaon == true
        table.cell(panel, 0,6, 'HMA', text_color=texcolor, bgcolor=neutralcolor)
    if hmaon == true and len1on == true
        table.cell(panel, 1,6, str.tostring(hmacounter1), text_color=texcolor, bgcolor = hmacolor1)
    if hmaon == true and len2on == true
        table.cell(panel, 2,6, str.tostring(hmacounter2), text_color=texcolor, bgcolor = hmacolor2)
    if hmaon == true and len3on == true
        table.cell(panel, 3,6, str.tostring(hmacounter3), text_color=texcolor, bgcolor = hmacolor3)
    if hmaon == true and len4on == true
        table.cell(panel, 4,6, str.tostring(hmacounter4), text_color=texcolor, bgcolor = hmacolor4)
    if hmaon == true and len5on == true
        table.cell(panel, 5,6, str.tostring(hmacounter5), text_color=texcolor, bgcolor = hmacolor5)
    if hmaon == true and len6on == true
        table.cell(panel, 6,6, str.tostring(hmacounter6), text_color=texcolor, bgcolor = hmacolor6)
    if hmaon == true and len7on == true
        table.cell(panel, 7,6, str.tostring(hmacounter7), text_color=texcolor, bgcolor = hmacolor7)
    if hmaon == true and len8on == true
        table.cell(panel, 8,6, str.tostring(hmacounter8), text_color=texcolor, bgcolor = hmacolor8)
    if hmaon == true and len9on == true
        table.cell(panel, 9,6, str.tostring(hmacounter9), text_color=texcolor, bgcolor = hmacolor9)
    if hmaon == true and len10on == true
        table.cell(panel, 10,6, str.tostring(hmacounter10), text_color=texcolor, bgcolor = hmacolor10)
    if ehmaon == true
        table.cell(panel, 0,7, 'EHMA', text_color=texcolor, bgcolor=neutralcolor)
    if ehmaon == true and len1on == true
        table.cell(panel, 1,7, str.tostring(ehmacounter1), text_color=texcolor, bgcolor = ehmacolor1)
    if ehmaon == true and len2on == true
        table.cell(panel, 2,7, str.tostring(ehmacounter2), text_color=texcolor, bgcolor = ehmacolor2)
    if ehmaon == true and len3on == true
        table.cell(panel, 3,7, str.tostring(ehmacounter3), text_color=texcolor, bgcolor = ehmacolor3)
    if ehmaon == true and len4on == true
        table.cell(panel, 4,7, str.tostring(ehmacounter4), text_color=texcolor, bgcolor = ehmacolor4)
    if ehmaon == true and len5on == true
        table.cell(panel, 5,7, str.tostring(ehmacounter5), text_color=texcolor, bgcolor = ehmacolor5)
    if ehmaon == true and len6on == true
        table.cell(panel, 6,7, str.tostring(ehmacounter6), text_color=texcolor, bgcolor = ehmacolor6)
    if ehmaon == true and len7on == true
        table.cell(panel, 7,7, str.tostring(ehmacounter7), text_color=texcolor, bgcolor = ehmacolor7)
    if ehmaon == true and len8on == true
        table.cell(panel, 8,7, str.tostring(ehmacounter8), text_color=texcolor, bgcolor = ehmacolor8)
    if ehmaon == true and len9on == true
        table.cell(panel, 9,7, str.tostring(ehmacounter9), text_color=texcolor, bgcolor = ehmacolor9)
    if ehmaon == true and len10on == true
        table.cell(panel, 10,7, str.tostring(ehmacounter10), text_color=texcolor, bgcolor = ehmacolor10)
    if temaon == true
        table.cell(panel, 0,8, 'TEMA', text_color=texcolor, bgcolor=neutralcolor)
    if temaon == true and len1on == true
        table.cell(panel, 1,8, str.tostring(temacounter1), text_color=texcolor, bgcolor = temacolor1)
    if temaon == true and len2on == true
        table.cell(panel, 2,8, str.tostring(temacounter2), text_color=texcolor, bgcolor = temacolor2)
    if temaon == true and len3on == true
        table.cell(panel, 3,8, str.tostring(temacounter3), text_color=texcolor, bgcolor = temacolor3)
    if temaon == true and len4on == true
        table.cell(panel, 4,8, str.tostring(temacounter4), text_color=texcolor, bgcolor = temacolor4)
    if temaon == true and len5on == true
        table.cell(panel, 5,8, str.tostring(temacounter5), text_color=texcolor, bgcolor = temacolor5)
    if temaon == true and len6on == true
        table.cell(panel, 6,8, str.tostring(temacounter6), text_color=texcolor, bgcolor = temacolor6)
    if temaon == true and len7on == true
        table.cell(panel, 7,8, str.tostring(temacounter7), text_color=texcolor, bgcolor = temacolor7)
    if temaon == true and len8on == true
        table.cell(panel, 8,8, str.tostring(temacounter8), text_color=texcolor, bgcolor = temacolor8)
    if temaon == true and len9on == true
        table.cell(panel, 9,8, str.tostring(temacounter9), text_color=texcolor, bgcolor = temacolor9)
    if temaon == true and len10on == true
        table.cell(panel, 10,8, str.tostring(temacounter10), text_color=texcolor, bgcolor = temacolor10)
    if tillsonon == true
        table.cell(panel, 0,9, 'Tillson T3', text_color=texcolor, bgcolor=neutralcolor)
    if tillsonon == true and len1on == true
        table.cell(panel, 1,9, str.tostring(tillsoncounter1), text_color=texcolor, bgcolor = tillsoncolor1)
    if tillsonon == true and len2on == true
        table.cell(panel, 2,9, str.tostring(tillsoncounter2), text_color=texcolor, bgcolor = tillsoncolor2)
    if tillsonon == true and len3on == true
        table.cell(panel, 3,9, str.tostring(tillsoncounter3), text_color=texcolor, bgcolor = tillsoncolor3)
    if tillsonon == true and len4on == true
        table.cell(panel, 4,9, str.tostring(tillsoncounter4), text_color=texcolor, bgcolor = tillsoncolor4)
    if tillsonon == true and len5on == true
        table.cell(panel, 5,9, str.tostring(tillsoncounter5), text_color=texcolor, bgcolor = tillsoncolor5)
    if tillsonon == true and len6on == true
        table.cell(panel, 6,9, str.tostring(tillsoncounter6), text_color=texcolor, bgcolor = tillsoncolor6)
    if tillsonon == true and len7on == true
        table.cell(panel, 7,9, str.tostring(tillsoncounter7), text_color=texcolor, bgcolor = tillsoncolor7)
    if tillsonon == true and len8on == true
        table.cell(panel, 8,9, str.tostring(tillsoncounter8), text_color=texcolor, bgcolor = tillsoncolor8)
    if tillsonon == true and len9on == true
        table.cell(panel, 9,9, str.tostring(tillsoncounter9), text_color=texcolor, bgcolor = tillsoncolor9)
    if tillsonon == true and len10on == true
        table.cell(panel, 10,9, str.tostring(tillsoncounter10), text_color=texcolor, bgcolor = tillsoncolor10)
    if linregon == true
        table.cell(panel, 0,10, 'Least Sq.', text_color=texcolor, bgcolor=neutralcolor)
    if linregon == true and len1on == true
        table.cell(panel, 1,10, str.tostring(linregcounter1), text_color=texcolor, bgcolor = linregcolor1)
    if linregon == true and len2on == true
        table.cell(panel, 2,10, str.tostring(linregcounter2), text_color=texcolor, bgcolor = linregcolor2)
    if linregon == true and len3on == true
        table.cell(panel, 3,10, str.tostring(linregcounter3), text_color=texcolor, bgcolor = linregcolor3)
    if linregon == true and len4on == true
        table.cell(panel, 4,10, str.tostring(linregcounter4), text_color=texcolor, bgcolor = linregcolor4)
    if linregon == true and len5on == true
        table.cell(panel, 5,10, str.tostring(linregcounter5), text_color=texcolor, bgcolor = linregcolor5)
    if linregon == true and len6on == true
        table.cell(panel, 6,10, str.tostring(linregcounter6), text_color=texcolor, bgcolor = linregcolor6)
    if linregon == true and len7on == true
        table.cell(panel, 7,10, str.tostring(linregcounter7), text_color=texcolor, bgcolor = linregcolor7)
    if linregon == true and len8on == true
        table.cell(panel, 8,10, str.tostring(linregcounter8), text_color=texcolor, bgcolor = linregcolor8)
    if linregon == true and len9on == true
        table.cell(panel, 9,10, str.tostring(linregcounter9), text_color=texcolor, bgcolor = linregcolor9)
    if linregon == true and len10on == true
        table.cell(panel, 10,10, str.tostring(linregcounter10), text_color=texcolor, bgcolor = linregcolor10)
    if almaon == true
        table.cell(panel, 0,11, 'ALMA', text_color=texcolor, bgcolor=neutralcolor)
    if almaon == true and len1on == true
        table.cell(panel, 1,11, str.tostring(almacounter1), text_color=texcolor, bgcolor = almacolor1)
    if almaon == true and len2on == true
        table.cell(panel, 2,11, str.tostring(almacounter2), text_color=texcolor, bgcolor = almacolor2)
    if almaon == true and len3on == true
        table.cell(panel, 3,11, str.tostring(almacounter3), text_color=texcolor, bgcolor = almacolor3)
    if almaon == true and len4on == true
        table.cell(panel, 4,11, str.tostring(almacounter4), text_color=texcolor, bgcolor = almacolor4)
    if almaon == true and len5on == true
        table.cell(panel, 5,11, str.tostring(almacounter5), text_color=texcolor, bgcolor = almacolor5)
    if almaon == true and len6on == true
        table.cell(panel, 6,11, str.tostring(almacounter6), text_color=texcolor, bgcolor = almacolor6)
    if almaon == true and len7on == true
        table.cell(panel, 7,11, str.tostring(almacounter7), text_color=texcolor, bgcolor = almacolor7)
    if almaon == true and len8on == true
        table.cell(panel, 8,11, str.tostring(almacounter8), text_color=texcolor, bgcolor = almacolor8)
    if almaon == true and len9on == true
        table.cell(panel, 9,11, str.tostring(almacounter9), text_color=texcolor, bgcolor = almacolor9)
    if almaon == true and len10on == true
        table.cell(panel, 10,11, str.tostring(almacounter10), text_color=texcolor, bgcolor = almacolor10)