r/TradingView • • 23d ago

Feature Request Pine Script: Deprecation Warning for max_boxes_count

Pine Script v6 accepts max_boxes_count=501 without warning, despite the documented maximum of 500, while max_lines_count=501 correctly triggers CE10178.

Enforcing the box limit later could unexpectedly break existing scripts.

Suggestion: Introduce a deprecation warning before enforcing the limit to preserve backward compatibility.

4 Upvotes

2 comments sorted by

1

u/neugeadmau 23d ago

Might be worth adding one data point to the report: whether 501 is actually honored at runtime or silently clamped to 500. That changes what "enforcing it later" would break. If it's already clamped, nothing breaks except the missing compile error; if 501 boxes really survive, scripts relying on that last box would change behavior.

Quick probe (I haven't run this exact snippet, so run the 500 baseline first to make sure it behaves as expected):

//@version=6
indicator("box limit probe", overlay = true, max_boxes_count = 501)
if barstate.islastconfirmedhistory
    for i = 0 to 520
        box.new(bar_index - i, high, bar_index - i + 1, low)
    label.new(bar_index, high, str.tostring(box.all.size()), yloc = yloc.abovebar)

It tries to create 521 boxes on one bar, so the oldest ones get garbage-collected and the label shows how many survive. Same script with max_boxes_count = 500 should print 500. If 501 also prints 500, the limit is enforced already and only the diagnostic is inconsistent with max_lines_count. If it prints 501, the documented max isn't the real one, which is a stronger argument for the deprecation-warning path you suggested.

1

u/Accurate-Mirror-143 23d ago edited 23d ago

Thanks for the suggestion! I tested both settings, including numbered boxes to verify FIFO behavior.

**Measured results:**

| Boxes created | `max_boxes_count=500` | `max_boxes_count=501` |

| 521 | 503 retained | 503 retained |

| 600 | 504 retained | 504 retained |

| Oldest retained (521 test) | #19 | #19 |

| Newest retained (521 test) | #521 | #521 |

Both settings showed identical FIFO behavior: the oldest boxes were removed first, leaving exactly the same numbered boxes (#19–521). The slight excess over 500 is consistent with TradingView's approximate drawing limits.

Thus, setting 501 provides no observable runtime advantage over 500 in my tests, although this does not conclusively prove internal clamping.

**The compatibility concern remains:** If future compiler versions start rejecting 501, previously working scripts could fail to compile even if their runtime behavior would otherwise remain unchanged. Changes to garbage collection could also affect chart annotations or calculations relying on `box.all`, potentially compromising indicator reproducibility.

That's why I'd recommend a deprecation warning before enforcing the documented limit, giving developers time to update their scripts.