BarnBuilder
BarnBuilder

Reputation: 3

Make Indicator Only Visible For 1 Security

I have an indicator that is unique to a security. I only want it visible when that security is selected. Is there a way to make it visible only for that security? Its an annoyance to have to turn it off every time.

Upvotes: 0

Views: 820

Answers (1)

rumpypumpydumpy
rumpypumpydumpy

Reputation: 3833

You can create a boolean condition to check the symbol, which you can then use as a condition for plotting, or with other renders such as lines, boxes, etc you can wrap the code in an if statement which only executes if it is the correct symbol.

sym = input.string("BINANCE:BTCUSDT", title = "symbol for visible")

visible = syminfo.tickerid == sym

plot(visible ? close : na)



var line hh_line = na

hh = ta.highest(high, 50)

new_hh = ta.change(hh) != 0

if visible
    if na(hh_line)
        hh_line := line.new(x1 = bar_index, y1 = hh, x2 = bar_index + 1, y2 = hh, extend = extend.both)
    else
        if new_hh
            line.set_xy1(hh_line, x = bar_index, y = hh)
            line.set_xy2(hh_line, x = bar_index + 1, y = hh)
        else
            line.set_x2(hh_line, x = bar_index + 1)

Upvotes: 1

Related Questions