Código: Seleccionar todo
//@version=4
study(title="EMA 34 Dif con Precio", shorttitle="EMA 34 y Precio ", overlay=true)
//DECLARACION DE VARIABLES DE CRUCE
crucepositivo = 0
crucenegativo = 0
//VARIABLES DE P Y EMA 34
int precio = input(title="EMA 10", type = input.integer, defval=6)
int periodo_34 = input(title="EMA 34", type = input.integer, defval=34)
p = ema(close,precio)
e34 = ema(close,periodo_34)
//FLECHAS ALCISTAS Y BAJISTAS
bajistas = crossunder(p, e34)
alcistas = crossover(p, e34)
plotshape(bajistas, title="Bajista", location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, text="0", size = size.small)
plotshape(alcistas, title="Alcista", location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, text="1", size = size.small)
//PLOTS QUE IMPRIMEN EL PRECIO LA EMA DE 34 TEMPORALIDADES
plot(p, color=color.red, linewidth = 3)
plot(e34, color=color.orange, linewidth = 3)
//IF QUE DA VALOR A CRUCEPOSITIVO
if ( (p[2] <= e34[2]) and (p[1] > e34[1]) )
crucepositivo := 1
else
crucepositivo := 0
//IF QUE DA VALOR A CRUCENEGATIVO
if ( (p[2] >=e34[2]) and (p[1] <e34[1]) )
crucenegativo := 1
else
crucenegativo := 0
// IF QUE PERMITE MOSTRAR LA FLECHA ARRIBA
arrowup = if (crucepositivo)
true
else
false
//bgcolor(color = cross(p, e34) ? color.green : na, transp =70)
//PLOT QUE IMPRITE LA FLECHA ARRIBA
//plotshape(series=arrowup, style=shape.triangleup, location = location.belowbar,color = color.green, size = size.small)
bgcolor(color = crossover(p, e34) ? color.green : na, transp =70)
// IF QUE PERMITE MOSTRAR LA FLECHA ABAJO
arrowdown = if (crucenegativo)
true
else
false
//bgcolor(color = cross(p, e34) ? color.red : na, transp =70)
//PLOT QUE IMPRITE LA FLECHA ABAJO
//plotshape(series=arrowdown, style=shape.triangledown, location = location.abovebar, color = color.red, transp = 5, size = size.small)
bgcolor(color = crossunder(p, e34) ? color.red : na, transp =70)
Código: Seleccionar todo
//@version=4
study("Tabla Condiciones binarias", shorttitle = " TCB", overlay = true)
//variables
crucepositivo = 0
crucenegativo = 0
//inputs que muestran las condiciones binarias
c0 = input(inline = "Condicion", type= input.integer, defval = 0, title = " 5m: ")
c1 = input(inline = "Condicion", type= input.integer, defval = 0, title = " 15m: ")
c2 = input(inline = "Condicion", type= input.integer, defval = 0, title = " 30m: ")
c3 = input(inline = "Condicion", type= input.integer, defval = 0, title = " 1h: ")
c4 = input(inline = "Condicion", type= input.integer, defval = 0, title = " 4h: ")
c5 = input(inline = "Condicion", type= input.integer, defval = 0, title = " D: ")
c6 = input(inline = "Condicion", type= input.integer, defval = 0, title = " S: ")
c7 = input(inline = "Condicion", type= input.integer, defval = 0, title = " M: ")
//tabla de 2 x 10
var table info = table.new(position.top_right, 2,10, border_width = 1)
//Función de conversión a decimal
binario(c0,c1,c2,c3,c4,c5,c6,c7) =>
spot = c0 * pow(2,0) + c1 * pow(2,1) + c2 * pow(2,2) + c3 * pow(2,3) + c4 * pow(2,4) + c5 * pow(2,5) + c6 * pow(2,6) + c7 * pow(2,7)
tostring(spot)
//variable que guarda el resultado de la funcion y manda los datos que ingrese el usuario
cd = binario( (c0), (c1), (c2), (c3), (c4), (c5), (c6), (c7) )
//condición para color verde alcitas color rojo bajistas
ca0 = (c0) > 0
ca1 = (c1) > 0
ca2 = (c2) > 0
ca3 = (c3) > 0
ca4 = (c4) > 0
ca5 = (c5) > 0
ca6 = (c6) > 0
ca7 = (c7) > 0
if barstate.islast
//titulos columnas
table.cell(info, 0 ,0 , "Temporalidades", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 1 ,0 , "Condición Binaria", bgcolor= color.new(color.orange, 70), text_color = color.white )
//Columna 1-filas
table.cell(info, 0 ,1 , "5m", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,2 , "15m", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,3 , "30m", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,4 , "1h", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,5 , "4h", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,6 , "D", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,7 , "S", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,8 , "M", bgcolor= color.new(color.orange, 70), text_color = color.white )
table.cell(info, 0 ,9 , "Decimal", bgcolor= color.new(color.black, 70), text_color = color.white )
//Columna 2-filas
table.cell(info, 1 ,1 , tostring(c0), bgcolor= ca0 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,2 , tostring(c1), bgcolor= ca1 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,3 , tostring(c2), bgcolor= ca2 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,4 , tostring(c3), bgcolor= ca3 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,5 , tostring(c4), bgcolor= ca4 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,6 , tostring(c5), bgcolor= ca5 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,7 , tostring(c6), bgcolor= ca6 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,8 , tostring(c7), bgcolor= ca7 ? color.new(color.green, 70) : color.new(color.red, 70), text_color = color.white )
table.cell(info, 1 ,9 , cd , bgcolor= color.new(color.black, 70), text_color = color.white )