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 broken v6 loop requests 50 different timeframes, exceeding the 40-call limit on non-professional plans. The fixed example caps that loop at 40. Professional plan limits differ, so match the cap to the user’s current plan and required datasets.

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 UAT grammar checker via check-pine-script-grammar.mjs
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 fixed cap targets current non-professional plans; professional plan limits and required datasets differ.

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