Aug 12, 2025 • 18 min read
Build a Multi‑Symbol Scanner in Pine v6: request.security(), Tables, and Limits
Pine can’t replace TradingView’s native screeners, but you can scan a curated list of tickers efficiently. Here’s a practical, performant approach.
Key constraints and expectations
- Each
request.security()
call is a performance hit; too many calls will slow or fail scripts. - There’s a limit to simultaneous requested series. Keep lists small and focused.
- Pine scripts run on the chart symbol; scanners are best for watchlists, not whole exchanges.
Pattern: fixed watchlist array + looped security()
//@version=6 indicator("Mini Scanner", overlay=false) // Define a small watchlist (5-20 symbols). Too many will hit limits. syms = array.from("AAPL", "MSFT", "NVDA", "TSLA", "AMZN") len = array.size(syms) // Results arrays var arrClose = array.new_float() var arrUp = array.new_bool() if barstate.isfirst array.resize(arrClose, len) array.resize(arrUp, len) for i = 0 to len - 1 string s = array.get(syms, i) float c = request.security(s, timeframe.period, close) bool up = c > request.security(s, timeframe.period, ta.ema(close, 50)) array.set(arrClose, i, c) array.set(arrUp, i, up) // Table output var table t = table.new(position.top_right, 3, len + 1, border_width=1) if barstate.isfirst table.cell(t, 0, 0, "Symbol", text_color=color.white, bgcolor=color.new(color.gray, 0)) table.cell(t, 1, 0, "Close") table.cell(t, 2, 0, "Above 50EMA") for i = 0 to len - 1 string s = array.get(syms, i) float c = array.get(arrClose, i) bool up = array.get(arrUp, i) table.cell(t, 0, i + 1, s) table.cell(t, 1, i + 1, str.tostring(c, format.mintick)) table.cell(t, 2, i + 1, up ? "Yes" : "No", text_color=up ? color.lime : color.red)
Variations and enhancements
- Replace the EMA condition with your own signal (e.g., Donchian breakout, RSI cross).
- Add color coding by regime, or sort top rows with simple rank heuristics (beware complexity limits).
- Use inputs to toggle watchlist presets (tech, energy, futures) without modifying code.
Performance tips
- Keep the symbol list tight. 5–20 is a practical range.
- Reuse calculations and avoid nested
request.security()
in deep loops. - Limit plots; render via tables for compact UI.
- Test on smaller history first; expand once stable.
FAQ
Can I scan an entire exchange?
No. Pine runs inside a single chart context with limits on external requests. Use this approach for curated lists or pair it with external screeners.
Why is my script slow or timing out?
Too many request.security()
calls or heavy calculations. Reduce list size, simplify conditions, and avoid nested loops.