Etiquetas
Publicado: 30 Ene 2023 08:48
Buenas de nuevo,
Una vez más pido ayuda por si alguien me puede dar algo de luz....
En este fragmento de código trato de identificar tres tipos de GAPs que se producen entre el cierre del FDAX del día anterior y la apertura del FDAX a las 8:00 de la mañana y me gustaría que saliese una nota/etiqueta en el gráfico que me indicase el tipo de GAP que se ha producido.
El código funciona y la nota aparece, pero no consigo que me salga una única etiqueta, se van solapando. Os pongo una imagen a modo de ejemplo.
Si se fijan bien, en el círculo amarillo, tenemos solapadas dos etiquetas, a pesar que he añadido la sentencia siguiente en el código:
¿Alguna idea o causa del problema?
Muchas gracias.
Una vez más pido ayuda por si alguien me puede dar algo de luz....
Código: Seleccionar todo
GAP_WIDE = false
GAP_DOBLE = false
GAP_MONSTER = false
var label id = na
label.delete(id[1])
if max_vola > 30
GAP_WIDE := false
GAP_DOBLE := false
GAP_MONSTER := false
else if math.abs(OpenPA - ClosePA) > 300
GAP_MONSTER := true
if barstate.islast and linezonetime
id = label.new(bar_index, y=high+200, text="GAP MONSTER\n Volatilidad " + str.tostring(max_vola) + "\n Half GAP "+ str.tostring( math.abs(OpenPA-ClosePA)/2 + math.min(OpenPA,ClosePA) ) + "\n Nº Puntos "+ str.tostring( math.abs(OpenPA-ClosePA)/2), style=label.style_label_down, yloc=yloc.price, color=color.purple, textcolor=color.white, size=size.small)
else if ((((CloseDAX < ClosePA) and (ClosePA < OpenPA)) or ((CloseDAX > ClosePA) and (ClosePA > OpenPA))) and math.abs(CloseDAX - ClosePA) >= 10 and math.abs(OpenPA - CloseDAX) >= 70) and not GAP_MONSTER
GAP_DOBLE := true
if barstate.islast and linezonetime
id = label.new(bar_index, y=high+200, text="GAP Doble\n Volatilidad " + str.tostring(max_vola) + "\n Half GAP "+ str.tostring( math.abs(OpenPA-ClosePA)/2 + math.min(OpenPA,ClosePA) ) + "\n Nº Puntos "+ str.tostring( math.abs(OpenPA-ClosePA)/2), style=label.style_label_down, yloc=yloc.price, color=color.purple, textcolor=color.white, size=size.small)
else if not GAP_DOBLE and max_vola < 20 and not GAP_MONSTER and (math.abs(OpenPA - ClosePA) >= 40) // and not GAP_MONSTER
GAP_WIDE := true
if barstate.islast and linezonetime
id = label.new(bar_index, y=high+200, text="GAP\n Inverso\n Volatilidad "+ str.tostring(max_vola) + "\n Half GAP "+ str.tostring( math.abs(OpenPA-ClosePA)/2 + math.min(OpenPA,ClosePA) ) + "\n Nº Puntos "+ str.tostring( math.abs(OpenPA-ClosePA)/2), style=label.style_label_down, yloc=yloc.price, color=color.purple, textcolor=color.white, size=size.small)
else if not GAP_DOBLE and max_vola >= 20 and not GAP_MONSTER and (math.abs(OpenPA - ClosePA) >= 70) // and not GAP_MONSTER
label.delete(id[1])
GAP_WIDE := true
if barstate.islast and linezonetime
id = label.new(bar_index, y=high+200, text="GAP\n Inverso\n Volatilidad "+ str.tostring(max_vola) + "\n Half GAP "+ str.tostring( math.abs(OpenPA-ClosePA)/2 + math.min(OpenPA,ClosePA) ) + "\n Nº Puntos "+ str.tostring( math.abs(OpenPA-ClosePA)/2), style=label.style_label_down, yloc=yloc.price, color=color.purple, textcolor=color.white, size=size.small)
El código funciona y la nota aparece, pero no consigo que me salga una única etiqueta, se van solapando. Os pongo una imagen a modo de ejemplo.
Si se fijan bien, en el círculo amarillo, tenemos solapadas dos etiquetas, a pesar que he añadido la sentencia siguiente en el código:
Código: Seleccionar todo
label.delete(id[1])
¿Alguna idea o causa del problema?
Muchas gracias.