'Is there any specific reason why my code is not executing on all candles?

This is pretty simple

//@version=4
study("My script", overlay=true)


line ln = na
ln := line.new(bar_index, close, bar_index, close[10])
line.set_style(ln, line.style_dashed)

but this is the result I'm getting

chart

I'm not sure what I'm doing wrong, s there any specific reason why my code is not executing on all candles?

Thank you



Solution 1:[1]

There is a limit to the number of lines you can use on your chart. By default the limit is 50. You can extend this to 500 by using the max_lines_count parameter in study/strategy.

study("My script", overlay = true, max_lines_count = 500)

https://www.tradingview.com/pine-script-reference/v4/#fun_study

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rumpypumpydumpy