RandomFellow
RandomFellow

Reputation: 347

Pine: bug with the label.new function

If you execute this code on RUNEUSD:

//@version=5
indicator("MA", "", true)

if (bar_index > 5000 and bar_index < 5800)
    label.new(bar_index, open,"🠅", yloc = yloc.belowbar, style = label.style_none, textcolor = color.blue, size = size.normal)
    
plot(na, "Zero line", color.gray)

you will notice blue arrows appearing below the bars (between bars 5000 and 5800).

But if you change the range with 4000 and 5000 like so:

if (bar_index > 4000 and bar_index < 5000)

No bar will appear at all!

I really cannot understand why, any idea ?

Thank you

Upvotes: 1

Views: 767

Answers (1)

vitruvius
vitruvius

Reputation: 21121

They do appear but they don't start at index #4000. That is because you can only have a limited amount of labels on your chart. Default value is 50.

If you want to increase that add max_labels_count=500 to your indicator() call.

indicator("MA", "", true, max_labels_count=500)

Your code: enter image description here

With max_labels_count=500 enter image description here

The separate chart plots bar_index.

Upvotes: 3

Related Questions