Tabela de conteúdos

Desenhos

Introdução

Criando Desenhos

//@version=4
study("My Script", overlay=true)
label.new(bar_index, high)
//@version=4
study("My Script", overlay=true)
label.new(bar_index, high, style=label.style_none,
    text="x=" + tostring(bar_index) + "\n y=" + tostring(high))
<code javascript>
 
  * Neste exemplo style=label.style_none significa que o rótulo não terá uma coloração de fundo.
 
  * Neste próximo exemplo uma linha é criada
 
<code javascript>
//@version=4
study("My Script", overlay=true)
line.new(x1=bar_index[1], y1=low[1], x2=bar_index, y2=high)

Cálculo na atualização das Barras

//@version=4
study("My Script", overlay=true)
label.new(bar_index, high)

Coordenadas

//@version=4
study("My Script", overlay=true)
if barstate.islast
    label.new(timenow, close, xloc=xloc.bar_time)

Modificando Desenhos

//@version=4
study("My Script", overlay=true)
l = label.new(bar_index, na)
if close >= open
    label.set_text(l, "green")
    label.set_color(l, color.green)
    label.set_yloc(l, yloc.belowbar)
    label.set_style(l, label.style_labelup)
else
    label.set_text(l, "red")
    label.set_color(l, color.red)
    label.set_yloc(l, yloc.abovebar)
    label.set_style(l, label.style_labeldown)

Estilos do Rótulo

Estilos das Linhas

Apagar Desenhos

//@version=4
study("Last Bar Close 1", overlay=true)
 
c = close >= open ? color.lime : color.red
l = label.new(bar_index, na,
  text=tostring(close), color=c,
  style=label.style_labeldown, yloc=yloc.abovebar)
 
label.delete(l[1])
if not na(l[1])
    label.delete(l[1])
//@version=4
study("Last Bar Close 2", overlay=true)
 
var label l = na
label.delete(l)
c = close >= open ? color.lime : color.red
l := label.new(bar_index, na,
  text=tostring(close), color=c,
  style=label.style_labeldown, yloc=yloc.abovebar)
//@version=4
study("Last Bar Close 3", overlay=true)
 
var label l = label.new(bar_index, na,
  style=label.style_labeldown, yloc=yloc.abovebar)
 
c = close >= open ? color.lime : color.red
label.set_color(l, c)
label.set_text(l, tostring(close))
label.set_x(l, bar_index)

Limites de Desenho

//@version=4
study("My Script", overlay=true)
label.new(bar_index, high)
//@version=4
study("My Script", overlay=true, max_labels_count=100)
label.new(bar_index, high)

Ativos Adicionais

//@version=4
study("My Script", overlay=true)
 
if barstate.isrealtime
   label.new(bar_index[10], na, text="Label", yloc=yloc.abovebar)
//@version=4
study("My Script", overlay=true)
 
max_bars_back(time, 10)
 
if barstate.isrealtime
    label.new(bar_index[10], na, text="Label", yloc=yloc.abovebar)