40 crypto screener [LUPOWN]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lupown

//@version=4
study("40 crypto screener [LUPOWN]","40 crypto screener [LPWN]" , false)



show_label = input(false,title="--------Show label-----------")
show_tabla = input (true,title="--------Show Tables---------")
show_tabla1 = input(true,title = "Show table 1")
show_tabla2 = input(true,title = "Show table 2")

// STEP 1. Make an input with drop-down menu
sizeOption = input(title="Label Size", type=input.string,
     options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"],
     defval="Normal")

// STEP 2. Convert the input to valid label sizes
labelSize = (sizeOption == "Huge") ? size.huge :
     (sizeOption == "Large") ? size.large :
     (sizeOption == "Small") ? size.small :
     (sizeOption == "Tiny") ? size.tiny :
     (sizeOption == "Auto") ? size.auto :
         size.normal
color   colorN = input(color.new(color.black, 30), "Color")
color colorT = input(color.white, "Color Texto")

string type0 = input('precio',title = 'precio/cambio/rsi', options = ['precio','cambio','rsi'])
string type1 = input('TL', title='Columna 1', options=["TL", "Momentum", "ADX", "Cipher", "LuxAlgo", "DivergenciaM","Whale","cambio"])
string type2 = input('Momentum', title='Columna 2', options=["TL", "Momentum", "ADX", "Cipher", "LuxAlgo", "DivergenciaM","Whale","cambio"])
string type3 = input('ADX', title='Columna 3', options=["TL", "Momentum", "ADX", "Cipher", "LuxAlgo", "DivergenciaM","Whale","cambio"])
string type4 = input('Cipher', title='Columna 4', options=["TL", "Momentum", "ADX", "Cipher", "LuxAlgo", "DivergenciaM","Whale","cambio"])



color colorA = input(color.new(#00FF00,20),"Color alcista")
color colorRS = input(color.new(#4db6ac,20),"Color rango subida")// 800000
color colorRC = input(color.new(#ef9a9a,20),"Color rango caida") //   008000
color colorB = input(color.new(#FF0000,20),"Color bajista")
color colorAdxP = input(color.new(color.white,40),"Color ADX positiva")
color colorAdxN = input(color.new(color.gray,20),"Color ADX negativa")
color colorsell = input (color.new(color.red,10),"Color Sell")
color colorbuy = input (color.new(color.green,10),"Color Sell")

// ————— Produces a string format usable with `tostring()` to restrict precision to ticks.



//////////////////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////screeener
//////////////////////////////////////////////////////////////////////////////////////////



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




// Symbols 
// There is a limit of 40 security calls so only 40 symbols at the same time is possible

// Symbols 
// There is a limit of 40 security calls so only 40 symbols at the same time is possible
s01 = input('XRPUSDTPERP',  type=input.symbol, group = "Symbols")
s02 = input('BTCUSDTPERP',  type=input.symbol, group = "Symbols")
s03 = input('DOGEUSDTPERP', type=input.symbol, group = "Symbols")
s04 = input('BNBUSDTPERP',  type=input.symbol, group = "Symbols")
s05 = input('ETHUSDTPERP',  type=input.symbol, group = "Symbols")
s06 = input('ADAUSDTPERP',  type=input.symbol, group = "Symbols")
s07 = input('BAKEUSDTPERP',   type=input.symbol, group = "Symbols")
s08 = input('SOLUSDTPERP',  type=input.symbol, group = "Symbols")
s09 = input('GTCUSDTPERP',  type=input.symbol, group = "Symbols")
s10 = input('ALGOUSDTPERP',  type=input.symbol, group = "Symbols")
s11 = input('FLMUSDTPERP',  type=input.symbol, group = "Symbols")
s12 = input('ICPUSDTPERP',  type=input.symbol, group = "Symbols")
s13 = input('VETUSDTPERP',  type=input.symbol, group = "Symbols")
s14 = input('1INCHUSDTPERP',   type=input.symbol, group = "Symbols")
s15 = input('TRXUSDTPERP',   type=input.symbol, group = "Symbols")
s16 = input('THETAUSDTPERP',  type=input.symbol, group = "Symbols")
s17 = input('EGLDUSDTPERP',  type=input.symbol, group = "Symbols")
s18 = input('LTCUSDTPERP',  type=input.symbol, group = "Symbols")
s19 = input('UNIUSDTPERP',  type=input.symbol, group = "Symbols")
s20 = input('SUSHIUSDTPERP',  type=input.symbol, group = "Symbols")
s21 = input('DOTUSDTPERP',  type=input.symbol, group = "Symbols")
s22 = input('XTZUSDTPERP',  type=input.symbol, group = "Symbols")
s23 = input('RENUSDTPERP',  type=input.symbol, group = "Symbols")
s24 = input('LINKUSDTPERP',   type=input.symbol, group = "Symbols")
s25 = input('FILUSDTPERP', type=input.symbol, group = "Symbols")
s26 = input('KSMUSDTPERP',  type=input.symbol, group = "Symbols")
s27 = input('BCHUSDT', type=input.symbol, group = "Symbols")
s28 = input('FTMUSDTPERP',   type=input.symbol, group = "Symbols")
s29 = input('AXSUSDTPERP', type=input.symbol, group = "Symbols")
s30 = input('SANDUSDTPERP',   type=input.symbol, group = "Symbols")
s31 = input('ALICEUSDTPERP',  type=input.symbol, group = "Symbols")
s32 = input('COTIUSDTPERP',  type=input.symbol, group = "Symbols")
s33 = input('CHRUSDTPERP',  type=input.symbol, group = "Symbols")
s34 = input('LINAUSDTPERP',  type=input.symbol, group = "Symbols")
s35 = input('CHZUSDTPERP',  type=input.symbol, group = "Symbols")
s36 = input('MASKUSDTPERP', type=input.symbol, group = "Symbols")
s37 = input('MATICUSDTPERP',   type=input.symbol, group = "Symbols")
s38 = input('EOSUSDTPERP',   type=input.symbol, group = "Symbols")
s39 = input('ROSEUSDT',  type=input.symbol, group = "Symbols")
s40 = input('TOMOUSDTPERP',  type=input.symbol, group = "Symbols")

///RSI IMPUT


rsiP = input(14,title = "RSI period")
//SQUEEZE MOMOENUTM PARAMS

//show_Momen = input(true, title="-----------Show squeeze momentum-------")
int lengthM = input(20,    title="MOM Length", minval=1, step=1)
srcM            = input(close, title="MOM Source", type=input.source)
int length  = input(20,    title="SQZ Length",  minval=1, step=1)
src = input(close, title="SQZ Source",  type=input.source)
lbR = input(title="Pivot Lookback Right", defval=1)
lbL = input(title="Pivot Lookback Left", defval=1)

///ADX PARAMS

adxlen   = input(14,    title = "ADX Smoothing")
dilen    = input(14,    title = "DI Length") 
keyLevel = input(23,    title = "Key level for ADX")

//CIPHER PARAMS

//WT
n1       = input(9,  title = "Channel Length")
n2       = input(12, title = "Average Length")
smooth   = input(3,  title = "Smooth Factor")



//////DIVERGENCIAS
//lbR = input(title="Pivot Lookback Right", defval=5)
//lbL = input(title="Pivot Lookback Left", defval=5)
rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)



// % cambio
tf = input(title="Timeframe %", type=input.resolution, defval="1")

//LuxAlgo
n11 = input(10, "Channel Length")
n22 = input(21, "Average Length")
///////////////
// FUNCTIONS //

// Rounding Function
roundn(x, n) => 
    mult = 1 
    if n != 0
        for i = 1 to abs(n)
            mult := mult * 10
    
    n >= 0 ? round(x * mult) / mult : round(x / mult) * mult 


//FUNCTION FOR CIPHER


	//wt
CALC(n1, n2, smooth) =>
	ap  = hlc3 
	esa = ema(ap, n1)
	dw  = ema(abs(ap - esa), n1)
	ci  = (ap - esa) / (0.015 * dw)
	tci = ema(ci, n2)
 
	wt1 = tci
	wt2 = sma(wt1,smooth)
	wave = wt1 - wt2
	wavecolor = wave >=0? color.lime : color.red
	[wave, wavecolor]


// Function for ADX


// ADX
dirmov(len) =>
	up = change(high)
	down = -change(low)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
	minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) => 
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
	[adx, plus, minus]

[adxValue, diplus, diminus] = adx(dilen, adxlen)

//PIVOTES

plFound(osc) => na(pivotlow(osc, lbL, lbR)) ? false : true
phFound(osc) => na(pivothigh(osc, lbL, lbR)) ? false : true

//DIVERGENCIAS 


/////////////////////////////////////////////
//////////////Whale detector by blackcat
////////////////////////////////////

//functions
xrf(values, length) =>
    r_val = float(na)
    if length >= 1
        for i = 0 to length by 1
            if na(r_val) or not na(values[i])
                r_val  :=  values[i]
                r_val
    r_val

xsa(src,len,wei) =>
    sumf = 0.0
    ma = 0.0
    out = 0.0
    sumf  :=  nz(sumf[1]) - nz(src[len]) + src
    ma  :=  na(src[len]) ? na : sumf/len
    out  :=  na(out[1]) ? ma : (src*wei+out[1]*(len-wei))/len
    out



//plotshape(whale and show_whale ?true :na,style=shape.triangleup,text="🐳",color=color.blue,location=location.belowbar)





_inRange(cond) =>
    bars = barssince(cond == true)
    rangeLower <= bars and bars <= rangeUpper
    
    
_findDivRB(osc)=>
    // Osc: Higher Low
    oscHL = osc[lbR] > valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1])

    // Price: Lower Low
    priceLL = low[lbR] < valuewhen(plFound(osc), low[lbR], 1)

    bullCond =  priceLL and oscHL and plFound(osc)


    //------------------------------------------------------------------------------
    // Hidden Bullish

    // Osc: Lower Low
    oscLL = osc[lbR] < valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1])

    // Price: Higher Low
    priceHL = low[lbR] > valuewhen(plFound(osc), low[lbR], 1)

    hiddenBullCond =  priceHL and oscLL and plFound(osc)



    //------------------------------------------------------------------------------
    // Regular Bearish

    // Osc: Lower High
    oscLH = osc[lbR] < valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1])

    // Price: Higher High
    priceHH = high[lbR] > valuewhen(phFound(osc), high[lbR], 1)

    bearCond = priceHH and oscLH and phFound(osc)



    //------------------------------------------------------------------------------
    // Hidden Bearish

    // Osc: Higher High
    oscHH = osc[lbR] > valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1])

    // Price: Lower High
    priceLH = high[lbR] < valuewhen(phFound(osc), high[lbR], 1)

    hiddenBearCond =  priceLH and oscHH and phFound(osc)
    
    [bullCond,hiddenBullCond,bearCond,hiddenBearCond]
    

eleccion(type_1,value)=>
    t=''
    c=color.gray
    if type_1 == "TL"
        t := value==1 ? '\t|SELL|\t' : value==2 ? '\tBUY\t' : '\t| |\t'
        c := value==1 ? colorsell : value==2 ? colorbuy : color.gray
    else
        if type_1 == "Momentum"
            
            t := value==1 ? '\t|Direccionalidad ALCISTA|' : value==2 ? '| RANGO O CAIDA |' : 
               value==3 ? '\t|Direccionalidad BAJISTA|' : value==4 ? '| RANGO O SUBIDA |' : '-'
            
            c := value==1 ? colorA : value==2 ? colorRC : 
               value==3 ? colorB : value==4 ? colorRS : color.gray
        else
            if type_1 == "ADX"
                t := value==1 ? '\t|Pendiente POSITIVA ↑ 23|' : value==2 ? '\t|Pendiente NEGATIVA ↑ 23|' : 
                   value==3 ? '\t|Pendiente NEGATIVA ↓ 23 |' : value==4? '\t|Pendiente POSITIVA ↓ 23|' : '-'
                   
                c := value==1 ? colorAdxP : value==2 ? colorAdxN : 
                   value==3 ? colorAdxN : value==4? colorAdxP : color.gray
            else
                if  type_1 == "Cipher"
                    t := value==1 ? '\t|SELL|\t' : value==2 ? '\tBUY\t' : '| |'
                    c := value==1 ? colorsell : value==2 ? colorbuy : color.gray
                else
                    if type_1 == "LuxAlgo"
                        t := value==1 ? '\t|SELL|\t' : value==2 ? '\tBUY\t' : '| |'
                        c := value==1 ? colorsell : value==2 ? colorbuy : color.gray
                    else 
                        if type_1 == "DivergenciaM"
                            t := value==1 ? '\t|DIVERGENCIA oculta ↓|' : value==2 ? '| DIVERGENCIA ↓ |' : 
                               value==3 ? '\t|DIVERGENCIA  oculta ↑|' : value==4 ? '| DIVERGENCIA ↑ |' : '-'
            
                            c := value==1 ? colorRC : value==2 ?  colorB: 
                               value==3 ?  colorRS: value==4 ? colorA : color.gray
                        else 
                            if type_1 == "cambio"
                                t := tostring(roundn(value,2))
                                c := value > 0 ? colorbuy : value < 0 ? colorsell : color.gray
                            else
                                if type_1 == "Whale"
                                    t := value == 1 ? '🐳' : '-'
                                    c := value == 1 ? #CCF6FD : color.gray
    [t,c]
    
    
///// numeber to string function and color
convert(bsf,mf,af,cf)=>
    
    [tbs,cbs] = eleccion(type1,bsf)
    [tm,cm] = eleccion(type2,mf)
    [ta,ca] = eleccion (type3,af)
    [tcond,ccond] = eleccion (type4,cf)
   
    [tbs,tm,ta,cbs,cm,ca,tcond,ccond]


// RSI Screener Function (overbought / orvesold)
// Function outputs only 2 values
// * Value - Numeric value you want to display in screener
// * Cindition - True/False variable that shows if current symbol should be displayed in the screener


screenerFunc() => 


    //TRADING LATINO
    
    
    sz  = linreg(srcM - avg(avg(highest(high, lengthM), lowest(low, lengthM)), sma(close, lengthM)), lengthM, 0)
    [adxValue, diplus, diminus] = adx(dilen, adxlen)
    ///////c CONDICIONES
    a1=adxValue >= 23
    a2=adxValue < 23
    a3=adxValue >= adxValue[1]
    a4=adxValue < adxValue[1]
    sc1 = sz >= 0
    sc2 = sz < 0
    sc3 = sz >= sz[1]
    sc4 = sz < sz[1]
    
    buy_cond1= plFound(sz) and adxValue < adxValue[1] ? true : false
    buy_cond2=  phFound(adxValue) and sz >= sz[1] and sz<0 ? true : false

    sell_cond1=phFound(sz) and adxValue < adxValue[1] ? true : false
    sell_cond2=phFound(adxValue) and sz < sz[1] and sz>0? true : false
    
    bs = sell_cond1 or sell_cond2 ? 1 : buy_cond1 or buy_cond2 ? 2 : na
   // buysell= sell_cond1 or sell_cond2 ? 'Sell' : buy_cond1 or buy_cond2 ? 'Buy' : na ORIGINAL
    //bs = sell_cond1 or sell_cond2 ? 1 : buy_cond1 or buy_cond2 ? 2 : na
    //[bs1]=eleccion(type1,sz,adxValue)
    //bs=bs1
    
    
    //ADX
    
    //iAdx = a1 and a3 ? '\tPendiente positiva ↑ 23' : a1 and a4 ? '\tPendiente negativa ↑ 23' : 
      //a2 and a4 ? '\tPendiente negativa ↓ 23' : a2 and a3 ? '\tPendiente positiva ↓ 23' : '-' //ORIGINAL
      
      

    a = a1 and a3 ? 1 : a1 and a4 ? 2 : 
       a2 and a4 ? 3 : a2 and a3 ? 4 : na
       
       
   //MOMENTUM
    //iMom = sc1 and sc3 ? 'Direccionalidad alcista' : sc1 and sc4 ? 'Direccionalidad bajista' : 
       //sc2 and sc4 ? 'Direccionalidad bajista' : sc2 and sc3 ? 'Direccinalidad alcista' : '-'  //ORIGNAL
       
       
    m = sc1 and sc3 ? 1 : sc1 and sc4 ? 2 : 
       sc2 and sc4 ? 3 : sc2 and sc3 ? 4 : na
       
    price=close
    
    
    //CIPHERR
    [wave, wavecolor] = CALC(n1, n2, smooth)

    middle = 0
    cond = crossover(wave,middle) ? 2 : crossunder(wave,middle) ? 1 : na
    
    
    // Divergencias
    
    [sz_bullCond,sz_hiddenBullCond,sz_bearCond,sz_hiddenBearCond]=_findDivRB(sz)
    
    dv= sz_bullCond ? 4 : sz_hiddenBullCond ? 3 : sz_bearCond ? 2 : sz_hiddenBearCond ? 1 : na
    
     // % cambio
    //((price - price[input_barsback]) * 100)/ xPrice[input_barsback]) maybe
    ch=((price-price[1])*100)/price
    
    //LUX ALGO (LAZY BEAR)
    
    ap = hlc3 
    esa = ema(ap, n11)
    d = ema(abs(ap - esa), n11)
    ci = (ap - esa) / (0.015 * d)
    tci = ema(ci, n22)
 
    wt1 = tci
    wt2 = sma(wt1,4)
    
    la = crossover(wt1,wt2) ? 2 : crossunder(wt1,wt2) ? 1 : na
    
    
    //trend follower algorithm
    var2 = xrf(low,1)
    var3 = xsa(abs(low-var2),3,1)/xsa(max(low-var2,0),3,1)*100
    var4 = ema(iff(close*1.2,var3*10,var3/10),3)
    var5 = lowest(low,30)
    var6 = highest(var4,30)
    var7 = iff(lowest(low,58),1,0)
    var8 = ema(iff(low<=var5,(var4+var6*2)/2,0),3)/618*var7

    //whale pump detector


    whale = phFound(var8) ? 1 : 0
    
    rsi = rsi(close,rsiP)


    // cond adx m bs
    
    c1 = type1 == "TL" ? bs: type1 == "Momentum" ? m : type1 == "ADX" ? a : type1 == "Cipher" ? cond : type1 == "LuxAlgo" ? la : type1 == "DivergenciaM" ? dv : type1 == "cambio" ? ch : type1 == "Whale" ? whale : na
    c2 = type2 == "TL" ? bs: type2 == "Momentum" ? m : type2 == "ADX" ? a : type2 == "Cipher" ? cond : type2 == "LuxAlgo" ? la : type2 == "DivergenciaM" ? dv : type2 == "cambio" ? ch : type2 == "Whale" ? whale : na
    c3 = type3 == "TL" ? bs: type3 == "Momentum" ? m : type3 == "ADX" ? a : type3 == "Cipher" ? cond : type3 == "LuxAlgo" ? la : type3 == "DivergenciaM" ? dv : type3 == "cambio" ? ch : type3 == "Whale" ? whale : na
    c4 = type4 == "TL" ? bs: type4 == "Momentum" ? m : type4 == "ADX" ? a : type4 == "Cipher" ? cond : type4 == "LuxAlgo" ? la : type4 == "DivergenciaM" ? dv : type4 == "cambio" ? ch : type4 == "Whale" ? whale : na
    
    val = type0 == 'precio' ? price : type0 == 'cambio' ? ch : type0 == 'rsi' ? rsi : na
    
    [val , c4 , c3, c2, c1]

   

aS=array.new_string(41)

array.set(	aS,	0	,	s01	)
array.set(	aS,	1	,	s02	)
array.set(	aS,	2	,	s03	)
array.set(	aS,	3	,	s04	)
array.set(	aS,	4	,	s05	)
array.set(	aS,	5	,	s06	)
array.set(	aS,	6	,	s07	)
array.set(	aS,	7	,	s08	)
array.set(	aS,	8	,	s09	)
array.set(	aS,	9	,	s10	)
array.set(	aS,	10	,	s11	)
array.set(	aS,	11	,	s12	)
array.set(	aS,	12	,	s13	)
array.set(	aS,	13	,	s14	)
array.set(	aS,	14	,	s15	)
array.set(	aS,	15	,	s16	)
array.set(	aS,	16	,	s17	)
array.set(	aS,	17	,	s18	)
array.set(	aS,	18	,	s19	)
array.set(	aS,	19	,	s20	)
array.set(	aS,	20	,	s21	)
array.set(	aS,	21	,	s22	)
array.set(	aS,	22	,	s23	)
array.set(	aS,	23	,	s24	)
array.set(	aS,	24	,	s25	)
array.set(	aS,	25	,	s26	)
array.set(	aS,	26	,	s27	)
array.set(	aS,	27	,	s28	)
array.set(	aS,	28	,	s29	)
array.set(	aS,	29	,	s30	)
array.set(	aS,	30	,	s31	)
array.set(	aS,	31	,	s32	)
array.set(	aS,	32	,	s33	)
array.set(	aS,	33	,	s34	)
array.set(	aS,	34	,	s35	)
array.set(	aS,	35	,	s36	)
array.set(	aS,	36	,	s37	)
array.set(	aS,	37	,	s38	)
array.set(	aS,	38	,	s39	)
array.set(	aS,	39	,	s40	)

aPrice = array.new_float(41)
aCond= array.new_float(41)
aA = array.new_float(41)
aM = array.new_float(41)
aBs = array.new_float(41)


///////////////////////////////////////
// Running Functions for all sybmols //

[v01, c01,a01,m01,bs01] = security(s01, timeframe.period, screenerFunc())
[v02, c02,a02,m02,bs02] = security(s02, timeframe.period, screenerFunc())
[v03, c03,a03,m03,bs03] = security(s03, timeframe.period, screenerFunc())
[v04, c04,a04,m04,bs04] = security(s04, timeframe.period, screenerFunc())
[v05, c05,a05,m05,bs05] = security(s05, timeframe.period, screenerFunc())
[v06, c06,a06,m06,bs06] = security(s06, timeframe.period, screenerFunc())
[v07, c07,a07,m07,bs07] = security(s07, timeframe.period, screenerFunc())
[v08, c08,a08,m08,bs08] = security(s08, timeframe.period, screenerFunc())
[v09, c09,a09,m09,bs09] = security(s09, timeframe.period, screenerFunc())
[v10, c10,a10,m10,bs10] = security(s10, timeframe.period, screenerFunc())
[v11, c11,a11,m11,bs11] = security(s11, timeframe.period, screenerFunc())
[v12, c12,a12,m12,bs12] = security(s12, timeframe.period, screenerFunc())
[v13, c13,a13,m13,bs13] = security(s13, timeframe.period, screenerFunc())
[v14, c14,a14,m14,bs14] = security(s14, timeframe.period, screenerFunc())
[v15, c15,a15,m15,bs15] = security(s15, timeframe.period, screenerFunc())
[v16, c16,a16,m16,bs16] = security(s16, timeframe.period, screenerFunc())
[v17, c17,a17,m17,bs17] = security(s17, timeframe.period, screenerFunc())
[v18, c18,a18,m18,bs18] = security(s18, timeframe.period, screenerFunc())
[v19, c19,a19,m19,bs19] = security(s19, timeframe.period, screenerFunc())
[v20, c20,a20,m20,bs20] = security(s20, timeframe.period, screenerFunc())
[v21, c21,a21,m21,bs21] = security(s21, timeframe.period, screenerFunc())
[v22, c22,a22,m22,bs22] = security(s22, timeframe.period, screenerFunc())
[v23, c23,a23,m23,bs23] = security(s23, timeframe.period, screenerFunc())
[v24, c24,a24,m24,bs24] = security(s24, timeframe.period, screenerFunc())
[v25, c25,a25,m25,bs25] = security(s25, timeframe.period, screenerFunc())
[v26, c26,a26,m26,bs26] = security(s26, timeframe.period, screenerFunc())
[v27, c27,a27,m27,bs27] = security(s27, timeframe.period, screenerFunc())
[v28, c28,a28,m28,bs28] = security(s28, timeframe.period, screenerFunc())
[v29, c29,a29,m29,bs29] = security(s29, timeframe.period, screenerFunc())
[v30, c30,a30,m30,bs30] = security(s30, timeframe.period, screenerFunc())
[v31, c31,a31,m31,bs31] = security(s31, timeframe.period, screenerFunc())
[v32, c32,a32,m32,bs32] = security(s32, timeframe.period, screenerFunc())
[v33, c33,a33,m33,bs33] = security(s33, timeframe.period, screenerFunc())
[v34, c34,a34,m34,bs34] = security(s34, timeframe.period, screenerFunc())
[v35, c35,a35,m35,bs35] = security(s35, timeframe.period, screenerFunc())
[v36, c36,a36,m36,bs36] = security(s36, timeframe.period, screenerFunc())
[v37, c37,a37,m37,bs37] = security(s37, timeframe.period, screenerFunc())
[v38, c38,a38,m38,bs38] = security(s38, timeframe.period, screenerFunc())
[v39, c39,a39,m39,bs39] = security(s39, timeframe.period, screenerFunc())
[v40, c40,a40,m40,bs40] = security(s40, timeframe.period, screenerFunc())

/////////////////////////////VALORES A ARRAY 
array.set(	aPrice,	0	,	v01	)
array.set(	aPrice,	1	,	v02	)
array.set(	aPrice,	2	,	v03	)
array.set(	aPrice,	3	,	v04	)
array.set(	aPrice,	4	,	v05	)
array.set(	aPrice,	5	,	v06	)
array.set(	aPrice,	6	,	v07	)
array.set(	aPrice,	7	,	v08	)
array.set(	aPrice,	8	,	v09	)
array.set(	aPrice,	9	,	v10	)
array.set(	aPrice,	10	,	v11	)
array.set(	aPrice,	11	,	v12	)
array.set(	aPrice,	12	,	v13	)
array.set(	aPrice,	13	,	v14	)
array.set(	aPrice,	14	,	v15	)
array.set(	aPrice,	15	,	v16	)
array.set(	aPrice,	16	,	v17	)
array.set(	aPrice,	17	,	v18	)
array.set(	aPrice,	18	,	v19	)
array.set(	aPrice,	19	,	v20	)
array.set(	aPrice,	20	,	v21	)
array.set(	aPrice,	21	,	v22	)
array.set(	aPrice,	22	,	v23	)
array.set(	aPrice,	23	,	v24	)
array.set(	aPrice,	24	,	v25	)
array.set(	aPrice,	25	,	v26	)
array.set(	aPrice,	26	,	v27	)
array.set(	aPrice,	27	,	v28	)
array.set(	aPrice,	28	,	v29	)
array.set(	aPrice,	29	,	v30	)
array.set(	aPrice,	30	,	v31	)
array.set(	aPrice,	31	,	v32	)
array.set(	aPrice,	32	,	v33	)
array.set(	aPrice,	33	,	v34	)
array.set(	aPrice,	34	,	v35	)
array.set(	aPrice,	35	,	v36	)
array.set(	aPrice,	36	,	v37	)
array.set(	aPrice,	37	,	v38	)
array.set(	aPrice,	38	,	v39	)
array.set(	aPrice,	39	,	v40	)






/// To STRING


asA = array.new_string(41)
asM = array.new_string(41)
asBs = array.new_string(41)
asCond = array.new_string(41)





//////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////

[	tbs01	,	tm01	,	ta01	,	cbs01	,	cm01	,	ca01	,	tcond01	,	ccond01	]	= convert(	bs01	,	m01	,	a01	,	c01	)
[	tbs02	,	tm02	,	ta02	,	cbs02	,	cm02	,	ca02	,	tcond02	,	ccond02	]	= convert(	bs02	,	m02	,	a02	,	c02	)
[	tbs03	,	tm03	,	ta03	,	cbs03	,	cm03	,	ca03	,	tcond03	,	ccond03	]	= convert(	bs03	,	m03	,	a03	,	c03	)
[	tbs04	,	tm04	,	ta04	,	cbs04	,	cm04	,	ca04	,	tcond04	,	ccond04	]	= convert(	bs04	,	m04	,	a04	,	c04	)
[	tbs05	,	tm05	,	ta05	,	cbs05	,	cm05	,	ca05	,	tcond05	,	ccond05	]	= convert(	bs05	,	m05	,	a05	,	c05	)
[	tbs06	,	tm06	,	ta06	,	cbs06	,	cm06	,	ca06	,	tcond06	,	ccond06	]	= convert(	bs06	,	m06	,	a06	,	c06	)
[	tbs07	,	tm07	,	ta07	,	cbs07	,	cm07	,	ca07	,	tcond07	,	ccond07	]	= convert(	bs07	,	m07	,	a07	,	c07	)
[	tbs08	,	tm08	,	ta08	,	cbs08	,	cm08	,	ca08	,	tcond08	,	ccond08	]	= convert(	bs08	,	m08	,	a08	,	c08	)
[	tbs09	,	tm09	,	ta09	,	cbs09	,	cm09	,	ca09	,	tcond09	,	ccond09	]	= convert(	bs09	,	m09	,	a09	,	c09	)
[	tbs10	,	tm10	,	ta10	,	cbs10	,	cm10	,	ca10	,	tcond10	,	ccond10	]	= convert(	bs10	,	m10	,	a10	,	c10	)
[	tbs11	,	tm11	,	ta11	,	cbs11	,	cm11	,	ca11	,	tcond11	,	ccond11	]	= convert(	bs11	,	m11	,	a11	,	c11	)
[	tbs12	,	tm12	,	ta12	,	cbs12	,	cm12	,	ca12	,	tcond12	,	ccond12	]	= convert(	bs12	,	m12	,	a12	,	c12	)
[	tbs13	,	tm13	,	ta13	,	cbs13	,	cm13	,	ca13	,	tcond13	,	ccond13	]	= convert(	bs13	,	m13	,	a13	,	c13	)
[	tbs14	,	tm14	,	ta14	,	cbs14	,	cm14	,	ca14	,	tcond14	,	ccond14	]	= convert(	bs14	,	m14	,	a14	,	c14	)
[	tbs15	,	tm15	,	ta15	,	cbs15	,	cm15	,	ca15	,	tcond15	,	ccond15	]	= convert(	bs15	,	m15	,	a15	,	c15	)
[	tbs16	,	tm16	,	ta16	,	cbs16	,	cm16	,	ca16	,	tcond16	,	ccond16	]	= convert(	bs16	,	m16	,	a16	,	c16	)
[	tbs17	,	tm17	,	ta17	,	cbs17	,	cm17	,	ca17	,	tcond17	,	ccond17	]	= convert(	bs17	,	m17	,	a17	,	c17	)
[	tbs18	,	tm18	,	ta18	,	cbs18	,	cm18	,	ca18	,	tcond18	,	ccond18	]	= convert(	bs18	,	m18	,	a18	,	c18	)
[	tbs19	,	tm19	,	ta19	,	cbs19	,	cm19	,	ca19	,	tcond19	,	ccond19	]	= convert(	bs19	,	m19	,	a19	,	c19	)
[	tbs20	,	tm20	,	ta20	,	cbs20	,	cm20	,	ca20	,	tcond20	,	ccond20	]	= convert(	bs20	,	m20	,	a20	,	c20	)
[	tbs21	,	tm21	,	ta21	,	cbs21	,	cm21	,	ca21	,	tcond21	,	ccond21	]	= convert(	bs21	,	m21	,	a21	,	c21	)
[	tbs22	,	tm22	,	ta22	,	cbs22	,	cm22	,	ca22	,	tcond22	,	ccond22	]	= convert(	bs22	,	m22	,	a22	,	c22	)
[	tbs23	,	tm23	,	ta23	,	cbs23	,	cm23	,	ca23	,	tcond23	,	ccond23	]	= convert(	bs23	,	m23	,	a23	,	c23	)
[	tbs24	,	tm24	,	ta24	,	cbs24	,	cm24	,	ca24	,	tcond24	,	ccond24	]	= convert(	bs24	,	m24	,	a24	,	c24	)
[	tbs25	,	tm25	,	ta25	,	cbs25	,	cm25	,	ca25	,	tcond25	,	ccond25	]	= convert(	bs25	,	m25	,	a25	,	c25	)
[	tbs26	,	tm26	,	ta26	,	cbs26	,	cm26	,	ca26	,	tcond26	,	ccond26	]	= convert(	bs26	,	m26	,	a26	,	c26	)
[	tbs27	,	tm27	,	ta27	,	cbs27	,	cm27	,	ca27	,	tcond27	,	ccond27	]	= convert(	bs27	,	m27	,	a27	,	c27	)
[	tbs28	,	tm28	,	ta28	,	cbs28	,	cm28	,	ca28	,	tcond28	,	ccond28	]	= convert(	bs28	,	m28	,	a28	,	c28	)
[	tbs29	,	tm29	,	ta29	,	cbs29	,	cm29	,	ca29	,	tcond29	,	ccond29	]	= convert(	bs29	,	m29	,	a29	,	c29	)
[	tbs30	,	tm30	,	ta30	,	cbs30	,	cm30	,	ca30	,	tcond30	,	ccond30	]	= convert(	bs30	,	m30	,	a30	,	c30	)
[	tbs31	,	tm31	,	ta31	,	cbs31	,	cm31	,	ca31	,	tcond31	,	ccond31	]	= convert(	bs31	,	m31	,	a31	,	c31	)
[	tbs32	,	tm32	,	ta32	,	cbs32	,	cm32	,	ca32	,	tcond32	,	ccond32	]	= convert(	bs32	,	m32	,	a32	,	c32	)
[	tbs33	,	tm33	,	ta33	,	cbs33	,	cm33	,	ca33	,	tcond33	,	ccond33	]	= convert(	bs33	,	m33	,	a33	,	c33	)
[	tbs34	,	tm34	,	ta34	,	cbs34	,	cm34	,	ca34	,	tcond34	,	ccond34	]	= convert(	bs34	,	m34	,	a34	,	c34	)
[	tbs35	,	tm35	,	ta35	,	cbs35	,	cm35	,	ca35	,	tcond35	,	ccond35	]	= convert(	bs35	,	m35	,	a35	,	c35	)
[	tbs36	,	tm36	,	ta36	,	cbs36	,	cm36	,	ca36	,	tcond36	,	ccond36	]	= convert(	bs36	,	m36	,	a36	,	c36	)
[	tbs37	,	tm37	,	ta37	,	cbs37	,	cm37	,	ca37	,	tcond37	,	ccond37	]	= convert(	bs37	,	m37	,	a37	,	c37	)
[	tbs38	,	tm38	,	ta38	,	cbs38	,	cm38	,	ca38	,	tcond38	,	ccond38	]	= convert(	bs38	,	m38	,	a38	,	c38	)
[	tbs39	,	tm39	,	ta39	,	cbs39	,	cm39	,	ca39	,	tcond39	,	ccond39	]	= convert(	bs39	,	m39	,	a39	,	c39	)
[	tbs40	,	tm40	,	ta40	,	cbs40	,	cm40	,	ca40	,	tcond40	,	ccond40	]	= convert(	bs40	,	m40	,	a40	,	c40	)





//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

acA = array.new_color(41)
acM = array.new_color(41)
acBs = array.new_color(41)
accond = array.new_color(41)

array.set(	accond,	0	,	ccond01	)
array.set(	accond,	1	,	ccond02	)
array.set(	accond,	2	,	ccond03	)
array.set(	accond,	3	,	ccond04	)
array.set(	accond,	4	,	ccond05	)
array.set(	accond,	5	,	ccond06	)
array.set(	accond,	6	,	ccond07	)
array.set(	accond,	7	,	ccond08	)
array.set(	accond,	8	,	ccond09	)
array.set(	accond,	9	,	ccond10	)
array.set(	accond,	10	,	ccond11	)
array.set(	accond,	11	,	ccond12	)
array.set(	accond,	12	,	ccond13	)
array.set(	accond,	13	,	ccond14	)
array.set(	accond,	14	,	ccond15	)
array.set(	accond,	15	,	ccond16	)
array.set(	accond,	16	,	ccond17	)
array.set(	accond,	17	,	ccond18	)
array.set(	accond,	18	,	ccond19	)
array.set(	accond,	19	,	ccond20	)
array.set(	accond,	20	,	ccond21	)
array.set(	accond,	21	,	ccond22	)
array.set(	accond,	22	,	ccond23	)
array.set(	accond,	23	,	ccond24	)
array.set(	accond,	24	,	ccond25	)
array.set(	accond,	25	,	ccond26	)
array.set(	accond,	26	,	ccond27	)
array.set(	accond,	27	,	ccond28	)
array.set(	accond,	28	,	ccond29	)
array.set(	accond,	29	,	ccond30	)
array.set(	accond,	30	,	ccond31	)
array.set(	accond,	31	,	ccond32	)
array.set(	accond,	32	,	ccond33	)
array.set(	accond,	33	,	ccond34	)
array.set(	accond,	34	,	ccond35	)
array.set(	accond,	35	,	ccond36	)
array.set(	accond,	36	,	ccond37	)
array.set(	accond,	37	,	ccond38	)
array.set(	accond,	38	,	ccond39	)
array.set(	accond,	39	,	ccond40	)
//array.set(	accond,	40	,	ccond41	)



array.set(	acBs,	0	,	cbs01	)
array.set(	acBs,	1	,	cbs02	)
array.set(	acBs,	2	,	cbs03	)
array.set(	acBs,	3	,	cbs04	)
array.set(	acBs,	4	,	cbs05	)
array.set(	acBs,	5	,	cbs06	)
array.set(	acBs,	6	,	cbs07	)
array.set(	acBs,	7	,	cbs08	)
array.set(	acBs,	8	,	cbs09	)
array.set(	acBs,	9	,	cbs10	)
array.set(	acBs,	10	,	cbs11	)
array.set(	acBs,	11	,	cbs12	)
array.set(	acBs,	12	,	cbs13	)
array.set(	acBs,	13	,	cbs14	)
array.set(	acBs,	14	,	cbs15	)
array.set(	acBs,	15	,	cbs16	)
array.set(	acBs,	16	,	cbs17	)
array.set(	acBs,	17	,	cbs18	)
array.set(	acBs,	18	,	cbs19	)
array.set(	acBs,	19	,	cbs20	)
array.set(	acBs,	20	,	cbs21	)
array.set(	acBs,	21	,	cbs22	)
array.set(	acBs,	22	,	cbs23	)
array.set(	acBs,	23	,	cbs24	)
array.set(	acBs,	24	,	cbs25	)
array.set(	acBs,	25	,	cbs26	)
array.set(	acBs,	26	,	cbs27	)
array.set(	acBs,	27	,	cbs28	)
array.set(	acBs,	28	,	cbs29	)
array.set(	acBs,	29	,	cbs30	)
array.set(	acBs,	30	,	cbs31	)
array.set(	acBs,	31	,	cbs32	)
array.set(	acBs,	32	,	cbs33	)
array.set(	acBs,	33	,	cbs34	)
array.set(	acBs,	34	,	cbs35	)
array.set(	acBs,	35	,	cbs36	)
array.set(	acBs,	36	,	cbs37	)
array.set(	acBs,	37	,	cbs38	)
array.set(	acBs,	38	,	cbs39	)
array.set(	acBs,	39	,	cbs40	)


array.set(	acA,	0	,	ca01	)
array.set(	acA,	1	,	ca02	)
array.set(	acA,	2	,	ca03	)
array.set(	acA,	3	,	ca04	)
array.set(	acA,	4	,	ca05	)
array.set(	acA,	5	,	ca06	)
array.set(	acA,	6	,	ca07	)
array.set(	acA,	7	,	ca08	)
array.set(	acA,	8	,	ca09	)
array.set(	acA,	9	,	ca10	)
array.set(	acA,	10	,	ca11	)
array.set(	acA,	11	,	ca12	)
array.set(	acA,	12	,	ca13	)
array.set(	acA,	13	,	ca14	)
array.set(	acA,	14	,	ca15	)
array.set(	acA,	15	,	ca16	)
array.set(	acA,	16	,	ca17	)
array.set(	acA,	17	,	ca18	)
array.set(	acA,	18	,	ca19	)
array.set(	acA,	19	,	ca20	)
array.set(	acA,	20	,	ca21	)
array.set(	acA,	21	,	ca22	)
array.set(	acA,	22	,	ca23	)
array.set(	acA,	23	,	ca24	)
array.set(	acA,	24	,	ca25	)
array.set(	acA,	25	,	ca26	)
array.set(	acA,	26	,	ca27	)
array.set(	acA,	27	,	ca28	)
array.set(	acA,	28	,	ca29	)
array.set(	acA,	29	,	ca30	)
array.set(	acA,	30	,	ca31	)
array.set(	acA,	31	,	ca32	)
array.set(	acA,	32	,	ca33	)
array.set(	acA,	33	,	ca34	)
array.set(	acA,	34	,	ca35	)
array.set(	acA,	35	,	ca36	)
array.set(	acA,	36	,	ca37	)
array.set(	acA,	37	,	ca38	)
array.set(	acA,	38	,	ca39	)
array.set(	acA,	39	,	ca40	)



array.set(	acM,	0	,	cm01	)
array.set(	acM,	1	,	cm02	)
array.set(	acM,	2	,	cm03	)
array.set(	acM,	3	,	cm04	)
array.set(	acM,	4	,	cm05	)
array.set(	acM,	5	,	cm06	)
array.set(	acM,	6	,	cm07	)
array.set(	acM,	7	,	cm08	)
array.set(	acM,	8	,	cm09	)
array.set(	acM,	9	,	cm10	)
array.set(	acM,	10	,	cm11	)
array.set(	acM,	11	,	cm12	)
array.set(	acM,	12	,	cm13	)
array.set(	acM,	13	,	cm14	)
array.set(	acM,	14	,	cm15	)
array.set(	acM,	15	,	cm16	)
array.set(	acM,	16	,	cm17	)
array.set(	acM,	17	,	cm18	)
array.set(	acM,	18	,	cm19	)
array.set(	acM,	19	,	cm20	)
array.set(	acM,	20	,	cm21	)
array.set(	acM,	21	,	cm22	)
array.set(	acM,	22	,	cm23	)
array.set(	acM,	23	,	cm24	)
array.set(	acM,	24	,	cm25	)
array.set(	acM,	25	,	cm26	)
array.set(	acM,	26	,	cm27	)
array.set(	acM,	27	,	cm28	)
array.set(	acM,	28	,	cm29	)
array.set(	acM,	29	,	cm30	)
array.set(	acM,	30	,	cm31	)
array.set(	acM,	31	,	cm32	)
array.set(	acM,	32	,	cm33	)
array.set(	acM,	33	,	cm34	)
array.set(	acM,	34	,	cm35	)
array.set(	acM,	35	,	cm36	)
array.set(	acM,	36	,	cm37	)
array.set(	acM,	37	,	cm38	)
array.set(	acM,	38	,	cm39	)
array.set(	acM,	39	,	cm40	)



//////////////////////////////////////////////////////////////////////////////


array.set(	asBs,	0	,	tbs01	)
array.set(	asBs,	1	,	tbs02	)
array.set(	asBs,	2	,	tbs03	)
array.set(	asBs,	3	,	tbs04	)
array.set(	asBs,	4	,	tbs05	)
array.set(	asBs,	5	,	tbs06	)
array.set(	asBs,	6	,	tbs07	)
array.set(	asBs,	7	,	tbs08	)
array.set(	asBs,	8	,	tbs09	)
array.set(	asBs,	9	,	tbs10	)
array.set(	asBs,	10	,	tbs11	)
array.set(	asBs,	11	,	tbs12	)
array.set(	asBs,	12	,	tbs13	)
array.set(	asBs,	13	,	tbs14	)
array.set(	asBs,	14	,	tbs15	)
array.set(	asBs,	15	,	tbs16	)
array.set(	asBs,	16	,	tbs17	)
array.set(	asBs,	17	,	tbs18	)
array.set(	asBs,	18	,	tbs19	)
array.set(	asBs,	19	,	tbs20	)
array.set(	asBs,	20	,	tbs21	)
array.set(	asBs,	21	,	tbs22	)
array.set(	asBs,	22	,	tbs23	)
array.set(	asBs,	23	,	tbs24	)
array.set(	asBs,	24	,	tbs25	)
array.set(	asBs,	25	,	tbs26	)
array.set(	asBs,	26	,	tbs27	)
array.set(	asBs,	27	,	tbs28	)
array.set(	asBs,	28	,	tbs29	)
array.set(	asBs,	29	,	tbs30	)
array.set(	asBs,	30	,	tbs31	)
array.set(	asBs,	31	,	tbs32	)
array.set(	asBs,	32	,	tbs33	)
array.set(	asBs,	33	,	tbs34	)
array.set(	asBs,	34	,	tbs35	)
array.set(	asBs,	35	,	tbs36	)
array.set(	asBs,	36	,	tbs37	)
array.set(	asBs,	37	,	tbs38	)
array.set(	asBs,	38	,	tbs39	)
array.set(	asBs,	39	,	tbs40	)


array.set(	asM,	0	,	tm01	)
array.set(	asM,	1	,	tm02	)
array.set(	asM,	2	,	tm03	)
array.set(	asM,	3	,	tm04	)
array.set(	asM,	4	,	tm05	)
array.set(	asM,	5	,	tm06	)
array.set(	asM,	6	,	tm07	)
array.set(	asM,	7	,	tm08	)
array.set(	asM,	8	,	tm09	)
array.set(	asM,	9	,	tm10	)
array.set(	asM,	10	,	tm11	)
array.set(	asM,	11	,	tm12	)
array.set(	asM,	12	,	tm13	)
array.set(	asM,	13	,	tm14	)
array.set(	asM,	14	,	tm15	)
array.set(	asM,	15	,	tm16	)
array.set(	asM,	16	,	tm17	)
array.set(	asM,	17	,	tm18	)
array.set(	asM,	18	,	tm19	)
array.set(	asM,	19	,	tm20	)
array.set(	asM,	20	,	tm21	)
array.set(	asM,	21	,	tm22	)
array.set(	asM,	22	,	tm23	)
array.set(	asM,	23	,	tm24	)
array.set(	asM,	24	,	tm25	)
array.set(	asM,	25	,	tm26	)
array.set(	asM,	26	,	tm27	)
array.set(	asM,	27	,	tm28	)
array.set(	asM,	28	,	tm29	)
array.set(	asM,	29	,	tm30	)
array.set(	asM,	30	,	tm31	)
array.set(	asM,	31	,	tm32	)
array.set(	asM,	32	,	tm33	)
array.set(	asM,	33	,	tm34	)
array.set(	asM,	34	,	tm35	)
array.set(	asM,	35	,	tm36	)
array.set(	asM,	36	,	tm37	)
array.set(	asM,	37	,	tm38	)
array.set(	asM,	38	,	tm39	)
array.set(	asM,	39	,	tm40	)



array.set(	asA,	0	,	ta01	)
array.set(	asA,	1	,	ta02	)
array.set(	asA,	2	,	ta03	)
array.set(	asA,	3	,	ta04	)
array.set(	asA,	4	,	ta05	)
array.set(	asA,	5	,	ta06	)
array.set(	asA,	6	,	ta07	)
array.set(	asA,	7	,	ta08	)
array.set(	asA,	8	,	ta09	)
array.set(	asA,	9	,	ta10	)
array.set(	asA,	10	,	ta11	)
array.set(	asA,	11	,	ta12	)
array.set(	asA,	12	,	ta13	)
array.set(	asA,	13	,	ta14	)
array.set(	asA,	14	,	ta15	)
array.set(	asA,	15	,	ta16	)
array.set(	asA,	16	,	ta17	)
array.set(	asA,	17	,	ta18	)
array.set(	asA,	18	,	ta19	)
array.set(	asA,	19	,	ta20	)
array.set(	asA,	20	,	ta21	)
array.set(	asA,	21	,	ta22	)
array.set(	asA,	22	,	ta23	)
array.set(	asA,	23	,	ta24	)
array.set(	asA,	24	,	ta25	)
array.set(	asA,	25	,	ta26	)
array.set(	asA,	26	,	ta27	)
array.set(	asA,	27	,	ta28	)
array.set(	asA,	28	,	ta29	)
array.set(	asA,	29	,	ta30	)
array.set(	asA,	30	,	ta31	)
array.set(	asA,	31	,	ta32	)
array.set(	asA,	32	,	ta33	)
array.set(	asA,	33	,	ta34	)
array.set(	asA,	34	,	ta35	)
array.set(	asA,	35	,	ta36	)
array.set(	asA,	36	,	ta37	)
array.set(	asA,	37	,	ta38	)
array.set(	asA,	38	,	ta39	)
array.set(	asA,	39	,	ta40	)


array.set(	asCond,	0	,	tcond01	)
array.set(	asCond,	1	,	tcond02	)
array.set(	asCond,	2	,	tcond03	)
array.set(	asCond,	3	,	tcond04	)
array.set(	asCond,	4	,	tcond05	)
array.set(	asCond,	5	,	tcond06	)
array.set(	asCond,	6	,	tcond07	)
array.set(	asCond,	7	,	tcond08	)
array.set(	asCond,	8	,	tcond09	)
array.set(	asCond,	9	,	tcond10	)
array.set(	asCond,	10	,	tcond11	)
array.set(	asCond,	11	,	tcond12	)
array.set(	asCond,	12	,	tcond13	)
array.set(	asCond,	13	,	tcond14	)
array.set(	asCond,	14	,	tcond15	)
array.set(	asCond,	15	,	tcond16	)
array.set(	asCond,	16	,	tcond17	)
array.set(	asCond,	17	,	tcond18	)
array.set(	asCond,	18	,	tcond19	)
array.set(	asCond,	19	,	tcond20	)
array.set(	asCond,	20	,	tcond21	)
array.set(	asCond,	21	,	tcond22	)
array.set(	asCond,	22	,	tcond23	)
array.set(	asCond,	23	,	tcond24	)
array.set(	asCond,	24	,	tcond25	)
array.set(	asCond,	25	,	tcond26	)
array.set(	asCond,	26	,	tcond27	)
array.set(	asCond,	27	,	tcond28	)
array.set(	asCond,	28	,	tcond29	)
array.set(	asCond,	29	,	tcond30	)
array.set(	asCond,	30	,	tcond31	)
array.set(	asCond,	31	,	tcond32	)
array.set(	asCond,	32	,	tcond33	)
array.set(	asCond,	33	,	tcond34	)
array.set(	asCond,	34	,	tcond35	)
array.set(	asCond,	35	,	tcond36	)
array.set(	asCond,	36	,	tcond37	)
array.set(	asCond,	37	,	tcond38	)
array.set(	asCond,	38	,	tcond39	)
array.set(	asCond,	39	,	tcond40	)
//array.set(	asCond,	40	,	tcond41	)




//////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
var table panel = table.new( position.top_left, 6, 23)
if barstate.islast and show_tabla and show_tabla1
    // Table header.
    table.cell(panel, 0, 0, "Activo",text_color = colorT,  bgcolor = colorN, text_size =  labelSize)
    table.cell(panel, 1, 0, type0, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel, 2, 0, type1, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel, 3, 0, type2, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel, 4, 0, type3, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel, 5, 0, type4, text_color = colorT, bgcolor = colorN, text_size =  labelSize)

for _i = 0 to 19
    // ————— Only execute table code on last bar.
    if barstate.islast and show_tabla and show_tabla1
        // Period in left column.
        table.cell(panel, 0, _i + 1, array.get(aS, _i), text_color = colorT, bgcolor = colorN , text_size =  labelSize)
        table.cell(panel, 1, _i + 1,tostring(roundn(array.get(aPrice, _i),2)), text_color =colorT, bgcolor = type0 == 'cambio' and array.get(aPrice, _i) > 0 ? colorbuy : type0 == 'cambio' and array.get(aPrice, _i) < 0 ? colorsell : colorN , text_size =  labelSize)
        table.cell(panel, 2, _i + 1,array.get(asBs, _i), text_color = colorT, bgcolor = array.get(acBs, _i), text_size =  labelSize)
        table.cell(panel, 3, _i + 1,array.get(asM, _i), text_color = colorT, bgcolor = array.get(acM, _i), text_size =  labelSize)
        table.cell(panel, 4, _i + 1,array.get(asA, _i), text_color = colorT, bgcolor = array.get(acA, _i), text_size =  labelSize)
        table.cell(panel, 5, _i + 1,array.get(asCond, _i), text_color = colorT, bgcolor = array.get(accond, _i), text_size =  labelSize)
        
        


var table panel2 = table.new( position.top_right, 6, 23)
if barstate.islast and show_tabla and show_tabla2
    // Table header.
    table.cell(panel2, 0, 0, "Activo", text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel2, 1, 0, type0, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel2, 2, 0, type1, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel2, 3, 0, type2, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel2, 4, 0, type3, text_color = colorT, bgcolor = colorN, text_size =  labelSize)
    table.cell(panel2, 5, 0, type4, text_color = colorT, bgcolor = colorN, text_size =  labelSize)


for _i = 0 to 20

    // ————— Only execute table code on last bar.
    if barstate.islast and show_tabla and show_tabla2

        table.cell(panel2, 0, _i + 1, array.get(aS, _i + 20), text_color = colorT, bgcolor = colorN, text_size =  labelSize)
        table.cell(panel2, 1, _i + 1,tostring(roundn(array.get(aPrice, _i + 20),2)), text_color = colorT, bgcolor = type0 == 'cambio' and array.get(aPrice, _i) > 0 ? colorbuy : type0 == 'cambio' and array.get(aPrice, _i) < 0 ? colorsell : colorN , text_size =  labelSize)
        table.cell(panel2, 2, _i + 1,array.get(asBs, _i + 20), text_color = colorT, bgcolor = array.get(acBs, _i + 20), text_size =  labelSize)
        table.cell(panel2, 3, _i + 1,array.get(asM, _i + 20), text_color = colorT, bgcolor = array.get(acM, _i + 20), text_size =  labelSize)
        table.cell(panel2, 4, _i + 1,array.get(asA, _i + 20), text_color = colorT, bgcolor = array.get(acA, _i + 20), text_size =  labelSize)
        table.cell(panel2, 5, _i + 1,array.get(asCond, _i + 20), text_color = colorT, bgcolor = array.get(accond, _i + 20), text_size =  labelSize)

////////////////////
// Screener label // main idea from @ QuantNomad

scr_label = ''

// Compose a screener message
scr_label := show_label  ? scr_label + s01 + ' ' + tostring(roundn(v01, 2)) + ' ' + tbs01 + ' ' + tm01 + ' ' + ta01 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s02 + ' ' + tostring(roundn(v02, 2)) + ' ' + tbs02 + ' ' + tm02 + ' ' + ta02 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s03 + ' ' + tostring(roundn(v03, 2)) + ' ' + tbs03 + ' ' + tm03 + ' ' + ta04 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s04 + ' ' + tostring(roundn(v04, 2)) + ' ' + tbs04 + ' ' + tm04 + ' ' + ta04 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s05 + ' ' + tostring(roundn(v05, 2)) + ' ' + tbs05 + ' ' + tm05 + ' ' + ta05 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s06 + ' ' + tostring(roundn(v06, 2)) + ' ' + tbs06 + ' ' + tm06 + ' ' + ta06 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s03 + ' ' + tostring(roundn(v03, 2)) + ' ' + tbs03 + ' ' + tm03 + ' ' + ta04 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s04 + ' ' + tostring(roundn(v04, 2)) + ' ' + tbs04 + ' ' + tm04 + ' ' + ta04 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s05 + ' ' + tostring(roundn(v05, 2)) + ' ' + tbs05 + ' ' + tm05 + ' ' + ta05 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s06 + ' ' + tostring(roundn(v06, 2)) + ' ' + tbs06 + ' ' + tm06 + ' ' + ta06 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s07 + ' ' + tostring(roundn(v07, 2)) + ' ' + tbs07 + ' ' + tm07 + ' ' + ta07 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s08 + ' ' + tostring(roundn(v08, 2)) + ' ' + tbs08 + ' ' + tm08 + ' ' + ta08 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s09 + ' ' + tostring(roundn(v09, 2)) + ' ' + tbs09 + ' ' + tm09 + ' ' + ta09 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s10 + ' ' + tostring(roundn(v10, 2)) + ' ' + tbs10 + ' ' + tm10 + ' ' + ta10 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s11 + ' ' + tostring(roundn(v11, 2)) + ' ' + tbs11 + ' ' + tm11 + ' ' + ta11 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s12 + ' ' + tostring(roundn(v12, 2)) + ' ' + tbs12 + ' ' + tm12 + ' ' + ta12 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s13 + ' ' + tostring(roundn(v13, 2)) + ' ' + tbs13 + ' ' + tm13 + ' ' + ta13 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s14 + ' ' + tostring(roundn(v14, 2)) + ' ' + tbs14 + ' ' + tm14 + ' ' + ta14 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s15 + ' ' + tostring(roundn(v15, 2)) + ' ' + tbs15 + ' ' + tm15 + ' ' + ta15 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s16 + ' ' + tostring(roundn(v16, 2)) + ' ' + tbs16 + ' ' + tm16 + ' ' + ta16 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s17 + ' ' + tostring(roundn(v17, 2)) + ' ' + tbs17 + ' ' + tm17 + ' ' + ta17 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s18 + ' ' + tostring(roundn(v18, 2)) + ' ' + tbs18 + ' ' + tm18 + ' ' + ta18 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s19 + ' ' + tostring(roundn(v19, 2)) + ' ' + tbs19 + ' ' + tm19 + ' ' + ta19 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s20 + ' ' + tostring(roundn(v20, 2)) + ' ' + tbs20 + ' ' + tm20 + ' ' + ta20 + '\n\n'  : scr_label

scr_label := show_label  ? scr_label + s21 + ' ' + tostring(roundn(v21, 2)) + ' ' + tbs21 + ' ' + tm21 + ' ' + ta21 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s22 + ' ' + tostring(roundn(v22, 2)) + ' ' + tbs22 + ' ' + tm22 + ' ' + ta22 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s23 + ' ' + tostring(roundn(v23, 2)) + ' ' + tbs23 + ' ' + tm23 + ' ' + ta23 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s24 + ' ' + tostring(roundn(v24, 2)) + ' ' + tbs24 + ' ' + tm24 + ' ' + ta24 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s25 + ' ' + tostring(roundn(v25, 2)) + ' ' + tbs25 + ' ' + tm25 + ' ' + ta25 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s26 + ' ' + tostring(roundn(v26, 2)) + ' ' + tbs26 + ' ' + tm26 + ' ' + ta26 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s27 + ' ' + tostring(roundn(v27, 2)) + ' ' + tbs27 + ' ' + tm27 + ' ' + ta27 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s28 + ' ' + tostring(roundn(v28, 2)) + ' ' + tbs28 + ' ' + tm28 + ' ' + ta28 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s29 + ' ' + tostring(roundn(v29, 2)) + ' ' + tbs29 + ' ' + tm29 + ' ' + ta29 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s30 + ' ' + tostring(roundn(v30, 2)) + ' ' + tbs30 + ' ' + tm30 + ' ' + ta30 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s31 + ' ' + tostring(roundn(v31, 2)) + ' ' + tbs31 + ' ' + tm31 + ' ' + ta31 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s32 + ' ' + tostring(roundn(v32, 2)) + ' ' + tbs32 + ' ' + tm32 + ' ' + ta32 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s33 + ' ' + tostring(roundn(v33, 2)) + ' ' + tbs33 + ' ' + tm33 + ' ' + ta33 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s34 + ' ' + tostring(roundn(v34, 2)) + ' ' + tbs34 + ' ' + tm34 + ' ' + ta34 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s35 + ' ' + tostring(roundn(v35, 2)) + ' ' + tbs35 + ' ' + tm35 + ' ' + ta35 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s36 + ' ' + tostring(roundn(v36, 2)) + ' ' + tbs36 + ' ' + tm36 + ' ' + ta36 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s37 + ' ' + tostring(roundn(v37, 2)) + ' ' + tbs37 + ' ' + tm37 + ' ' + ta37 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s38 + ' ' + tostring(roundn(v38, 2)) + ' ' + tbs38 + ' ' + tm38 + ' ' + ta38 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s39 + ' ' + tostring(roundn(v39, 2)) + ' ' + tbs39 + ' ' + tm39 + ' ' + ta39 + '\n\n'  : scr_label
scr_label := show_label  ? scr_label + s40 + ' ' + tostring(roundn(v40, 2)) + ' ' + tbs40 + ' ' + tm40 + ' ' + ta40 + '\n\n'  : scr_label
// Plot Label on the chart
if(show_label)
    lab_l = label.new(
               bar_index, 0, 'Trading Latino monitoreo: \n\n' + scr_label, 
               color     = color(na), 
               textcolor = color.white, 
               style     = label.style_labeldown,
               yloc      = yloc.price,
               size = size.normal)
            
    // This will keep screener only for the last bar
    label.delete(lab_l[1])