OPEN-SOURCE SCRIPT
Volume Orderbook (Expo) — safe-indexed

基于 Zeiierman 的Volume Orderbook(Expo) 修复了以下bug
Pine Script®
修复思路:
提供一个索引钳制函数 clampIndex(idx, last),把任何索引限制在 [0, last] 区间内。
所有 array.get() 前都用该函数钳制索引(包括对 levels / volumes 的两端访问,以及 +1 时的上界保护)。
网格线、方框上下边界使用的 levels.get(...) 也统一钳制,避免负值或越界。
In 'array.get()' function. Index 3 is out of bounds, array size is 3.
at #main():75
修复思路:
提供一个索引钳制函数 clampIndex(idx, last),把任何索引限制在 [0, last] 区间内。
所有 array.get() 前都用该函数钳制索引(包括对 levels / volumes 的两端访问,以及 +1 时的上界保护)。
网格线、方框上下边界使用的 levels.get(...) 也统一钳制,避免负值或越界。
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.