Your Pine Script isn't too big — it's wasteful: 7 fixes for TradingView's 0.5s execution limit (RE10110)

If you opened TradingView this week and your indicator suddenly refused to load with RE10110 — "the script took too long to execute" — you are not alone. TradingView's 0.5-second execution cap on free plans is breaking heavy scripts that ran fine before, and a second, quieter problem is riding along with it: in Pine v6, ta.* calls hidden inside conditions can silently drift (warning CW10003).

Here's the honest framing first: nobody can remove the cap. What you can do is make a heavy script run under it. Most scripts that hit RE10110 are not "too big" — they are wasteful in a few repeatable ways. Fix the waste, keep the logic.

The silent bug first: precompute ta.* in global scope

Before the performance fixes, check this one, because it corrupts results without any error. In Pine v6, and / or short-circuit: if the left side is false, the right side never runs. So a ta.rsi() sitting inside a condition only advances on some bars, and its value silently drifts away from what you expect.

// WRONG (v6): rsi only advances when close > open signal = close > open and ta.rsi(close, 14) > 50 // RIGHT: compute every bar, then test the stored value rsi = ta.rsi(close, 14) signal = close > open and rsi > 50 

Same rule for anything inside an if block or a ternary: if a ta.* call is conditional, its history is conditional. Compute every indicator once, at the top, in global scope — then use the stored variable everywhere else. Your script still runs either way; it just quietly gives different values if you get this wrong.

Fix 1: Kill request.security() spam

Every request.security() call re-runs the whole script context on another timeframe. Ten calls pulling one value each from the same timeframe is ten full re-runs. Consolidate: one call per timeframe, with a tuple of everything you need.

// Instead of ten separate calls... [htfOpen, htfHigh, htfLow, htfClose] = request.security(syminfo.tickerid, "60", [open, high, low, close]) 

Fix 2: Don't recompute history you already have

Use var for state that persists — zones, levels, counters — and update it incrementally on new bars instead of rescanning the whole lookback window on every bar. If your script re-derives the same levels from scratch on bar 5,000 that it already derived on bar 4,999, that is pure waste.

Fix 3: Bound your loops and break early

A loop over 500 bars × several arrays, running on every bar, is the classic RE10110 trigger. Cap the lookback to what the logic actually needs, iterate newest → oldest, and break the moment the condition is met. Nested loops multiply the cost, not add to it — a 200 × 200 loop is 40,000 steps per bar.

Fix 4: Drawings are not free

Hundreds of boxes, lines and labels with per-bar updates cost real time — and heavy zone-drawing scripts are exactly the ones dying under this cap. Keep only the N most recent objects, delete the rest (box.delete / line.delete / label.delete), and draw on the last bar where the logic allows it.

Fix 5: Cheap filters first

Order your conditions so the cheapest, most selective test runs first. In v6 the short-circuit that corrupts ta.* is your friend for plain comparisons: put the rare condition first and the expensive one last, so the expensive work usually never runs.

Fix 6: Measure before and after

Note the script's behaviour before the change — does it load, on which plan? — and after each fix. Change one thing at a time, so you know which fix actually bought the time. If your script is editable, Pine's Profiler mode (More → Profiler in the Pine Editor) shows which lines cost the most.

Fix 7: Split only if you must

If one script genuinely does two unrelated jobs, splitting it into two scripts is a legitimate last resort. But try fixes 1–5 first — in my experience the request.security() consolidation alone is often enough to get a script loading again on a free plan without changing a single signal.

The takeaway

The cap is a budget, not a verdict on your script. Precompute your indicators in global scope so v6 can't corrupt them, consolidate your request.security() calls, bound your loops, prune your drawings, and measure each change. I took a script that was dying with RE10110 and got it loading on a free plan without changing its signals — the fixes were the ones above.

What hit your script hardest — loops, security calls, or drawings? I'd be curious to hear which fix bought you the most time.