AnyDozer
AnyDozer

Reputation: 2568

Autoscale vertical line width

I am drawing vertical lines using the function line.set Is it possible to autoscale vertical line width so that it is equal to the candlestick width. Or other drawing possibilities without using plot.

[ADDED]

study("V_Line")

var bar0 = line.new(na, na, na, na, width=5, extend=extend.none)
var bar1 = line.new(na, na, na, na, width=5, extend=extend.none)
var bar2 = line.new(na, na, na, na, width=5, extend=extend.none)
vol=0.0

vcolor = close[2] < close[0] and close[1] < close[0] ? color.green : (close[2] > close[0] and close[1] > close[0] ? color.red : color.black)
vol := vcolor[1]==vcolor[0]  ?  nz(vol[1]) + nz(volume) : nz(volume)

line.set_xy1(bar0, bar_index, 0)
line.set_xy2(bar0, bar_index, vol)
line.set_color(bar0, vcolor)

line.set_xy1(bar1, bar_index[1], 0)
line.set_xy2(bar1, bar_index[1], vol[1])
line.set_color(bar1, vcolor[1])

line.set_xy1(bar2, bar_index[2], 0)
line.set_xy2(bar2, bar_index[2], vol[2])
line.set_color(bar2, vcolor[2])

enter image description here

Upvotes: 0

Views: 176

Answers (1)

Bjorn Mistiaen
Bjorn Mistiaen

Reputation: 6905

Like this?

//@version=4
study("V_Line")

vol=0.0

vcolor = close[2] < close[0] and close[1] < close[0] ? color.green : (close[2] > close[0] and close[1] > close[0] ? color.red : color.black)
vol := vcolor[1]==vcolor[0]  ?  nz(vol[1]) + nz(volume) : nz(volume)

plot(vol, color=vcolor, style=plot.style_columns)

enter image description here

Upvotes: 1

Related Questions