All free tools

Pine Script tool

Pine Script Indicator Speed Estimator

Paste a script to count the things that most often make a Pine Script slow or push it past a platform limit: request calls, nested loops and drawing objects. It reads the structure of the text and never times anything. It runs in your browser and nothing is uploaded.

Request calls
2
Limit 40 unique calls (64 on Ultimate)
Loops
3
All have a fixed iteration count
Worst loop per bar
10,000
Iterations, nested loops multiplied
Drawing creations
1
Calls to line.new, label.new and box.new
  • Behaviour changeLine 5

    Repeated request.security call

    The same request already appears on line 4. Fetch it once into a variable and reuse it; each call costs a data request.

  • Needs your decisionLine 9

    Nested loop, depth 2

    Up to 10,000 iterations on every bar. Pine stops a script when one loop runs longer than 500 ms on a bar, so keep the product small or compute it incrementally.

  • Behaviour changeLine 13

    line.new() inside a loop

    Each pass creates another line. Once the script holds 50 of them, TradingView deletes the oldest. Set max_lines_count deliberately and delete objects you no longer need.

What this counts

Three things account for most slow scripts. Loops run their body on every bar, so a loop of 200 passes with another of 50 inside it does 10,000 iterations per bar. Pine stops a script when one loop takes longer than 500 ms on a single bar. Data requests such as request.security each cost a fetch, and a script can contain up to 40 unique ones. Drawing objects are capped by an allowance of 50 per type by default, raised to at most 500 with max_lines_count, max_labels_count and max_boxes_count.

The limits come from the Limitations page of the Pine Script v6 User Manual. TradingView can change them, so confirm against the current manual.

What it cannot tell you

This is a static scan. It does not know how many bars your chart holds, how expensive each built-in is, or how many requests are unique once arguments are evaluated. Loops with bounds that are variables show no fixed count. A clean result means none of the common patterns matched, not that the script is fast. For the longer story on profiling and fixing slow scripts, read why Pine Script is slow.

A lighter version in Pine Script

The same sample after the usual fixes: one request instead of two, a built-in average in place of the nested loop, and a single drawing that is replaced rather than added.

Describe what you want the indicator to compute and PineScripter generates v6 code that prefers built-ins and a single request, so you start from a structure that is cheaper to run.

Pine Script v6
//@version=6
indicator("Lighter version", overlay = true, max_lines_count = 100)

// One request, reused.
daily = request.security(syminfo.tickerid, "D", close)

// A built-in replaces the hand-written inner loop.
avg = ta.sma(close, 50)

// Draw only when something changes, and remove the old object.
var line lastLine = na
if barstate.islast
    line.delete(lastLine)
    lastLine := line.new(bar_index - 10, high, bar_index, low)

plot(avg)
plot(daily, color = color.gray)

PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.

Related free calculators

From the blog

PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.