Resource limit

Fix too many unique `request.*()` calls

Reduce the number of unique `request.*()` contexts executed by the script. Repeated identical requests are reused, but different symbols, timeframes, expressions, or scopes can count separately. The first v6 loop requests 50 different timeframes. Current documentation lists 40 unique calls, or 64 for Ultimate. The second loop caps this isolated example at 40; it changes the requested datasets and resulting sum, rather than preserving all 50 inputs. Count other script and library requests before applying a cap.

This link opens the Pine Script AI Coding Agent overview. It does not run or change code on this page.

Before and after

Make the smallest reviewable change

Both artifacts include the version declaration and the code needed to inspect the stated problem. The diff lists the lines that change between them.

Broken code.pine
//@version=6
indicator("Request limit demo")
float requestedSum = 0.0
for i = 1 to 50
    requestedSum += request.security(syminfo.tickerid, str.tostring(i), close)
plot(requestedSum)
Fixed code.pine
//@version=6
indicator("Request limit demo")
float requestedSum = 0.0
for i = 1 to 40
    requestedSum += request.security(syminfo.tickerid, str.tostring(i), close)
plot(requestedSum)
Diff.pine
--- broken.pine
+++ fixed.pine
@@
-for i = 1 to 50
+for i = 1 to 40

Root causes

  • A script requests too many distinct symbol, timeframe, modifier, expression, or scope combinations.
  • Library-scoped requests add unique calls even when similar requests exist in the main script.
  • The script treats repeated data needs as separate requests instead of reusing one result or tuple.

How the fix was verified

Method
Pineify MCP pine-script-syntax-checker; static diagnostics only
Broken result
Returned no grammar diagnostics; the unique-call limit is enforced at runtime.
Fixed result
Returned no grammar diagnostics.
Limit
Not runtime-tested. The 40-context example uses the whole lower request budget and omits ten datasets. Other script or library requests and the current plan limit must be considered.

Bring the actual script, not just the message

Open the Coding Agent overview to paste editable Pine Script, explain the intended behavior, and request a review. Compile and test the result in TradingView before using it.

Paste your code to fix this error