admin管理员组文章数量:1291044
Not a big coding guru here. Wondering why I get
Error on bar 0: In 'array.get()' function. Index 0 is out of bounds, array size is 0.
for this:
if array.size(vah_levels) > 0
for i = 0 to array.size(vah_levels) - 1
if not array.get(trades_taken, i)
current_vah = array.get(vah_levels, i)
current_val = array.get(val_levels, i)
[above_vah, below_val] = f_detect_swing(current_vah, current_val)
Some research points to array.size(vah_levels) being 0 in the beginning. Should tell it to ignore such cases? Grateful for any advice. Thanks
Not a big coding guru here. Wondering why I get
Error on bar 0: In 'array.get()' function. Index 0 is out of bounds, array size is 0.
for this:
if array.size(vah_levels) > 0
for i = 0 to array.size(vah_levels) - 1
if not array.get(trades_taken, i)
current_vah = array.get(vah_levels, i)
current_val = array.get(val_levels, i)
[above_vah, below_val] = f_detect_swing(current_vah, current_val)
Some research points to array.size(vah_levels) being 0 in the beginning. Should tell it to ignore such cases? Grateful for any advice. Thanks
Share Improve this question asked Feb 13 at 23:19 Svetoslav GeievSvetoslav Geiev 32 bronze badges 2 |1 Answer
Reset to default 0You have three arrays you are working with. Before doing any kind of accessing their elements you need to check if there is something in them.
Currently, you are only testing one of your arrays. So, the issue is probably coming from the other two.
Below should at least prevent the error.
len_vah = array.size(vah_levels)
len_val = array.size(val_levels)
len_trades = array.size(trades_taken)
if ((len_vah > 0) and (len_val > 0) and (len_trades > 0))
for i = 0 to len_vah - 1
if not array.get(trades_taken, i)
current_vah = array.get(vah_levels, i)
current_val = array.get(val_levels, i)
[above_vah, below_val] = f_detect_swing(current_vah, current_val)
本文标签:
版权声明:本文标题:pine script - Error on bar 0: In 'array.get()' function. Index 0 is out of bounds, array size is 0 - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741502507a2382130.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
trades_taken
? Is it an array? Where is it initialized? – PM 77-1 Commented Feb 13 at 23:31