Tabela de conteúdos

Candles Customizados

Barras OHLC e Candles

plotbar

//@version=4
study("Exemplo 1")
plotbar(open, high, low, close)
//@version=4
study("Exemplo 2")
paleta = close >= open ? color.lime : color.red
plotbar(open, high, low, close, color=paleta)

plotcandle

//@version=4
study("Exemplo 3")
c = close > open ? na : close
plotcandle(open, high, low, close, c)

Valores não OHLC

//@version=4
study("Exemplo 4")
len = input(9)
smooth(x) =>
    sma(x, len)
o = smooth(open)
h = smooth(high)
l = smooth(low)
c = smooth(close)
plotcandle(o, h, l, c)
// NOTA: adicionar esse código em um gráfico intraday
//@version=4
study("Exemplo 5")
higherRes = input("D", type=input.resolution)
is_newbar(res) =>
    t = time(res)
    not na(t) and (na(t[1]) or t > t[1])
o = security(syminfo.tickerid, higherRes, open)
h = security(syminfo.tickerid, higherRes, high)
l = security(syminfo.tickerid, higherRes, low)
c = security(syminfo.tickerid, higherRes, close)
plotbar(is_newbar(higherRes) ? o : na, h, l, c, color=c >= o ? color.lime : color.red)