Supported Pine Features
TestMax supports Pine Script v5 and v6 across common indicator and strategy workflows. This page describes the implemented features and the limits to check when bringing a script from TradingView. Identical source can produce different results with different data, sessions, history, or simulation assumptions.
Language and inputs
| Feature | Support |
|---|---|
indicator() and strategy() | Indicators and strategies can be applied to replay charts |
library() and import | Available library source can be saved in your account and imported by exact path |
| Inputs | Integer, float, boolean, string, color, source, timeframe, session, and time inputs |
| Control flow | if / else, for, while, and switch |
| Functions and types | User-defined functions, supported methods, and user-defined types |
| Collections | Supported array, matrix, and map operations, with size limits |
| Series history | x[n] and history-dependent calculations |
| Persistent state | var state rolls back between open-candle updates, including referenced objects; varip persists between executions |
The compiler does not implement every Pine type rule or collection method. A successful compilation is not a promise of full language equivalence. Keep history-dependent TA calculations outside branches that run only occasionally: calculate the value each bar, then use it in the condition.
Common TA calculations
| Category | Functions and built-ins |
|---|---|
| Moving averages | sma, ema, rma, wma, vwma, swma |
| Oscillators | rsi, macd, stoch, cci, mfi |
| Bands and dispersion | bb, stdev, variance, dev, atr, tr |
| Trend | supertrend, sar, dmi — dmi returns +DI, −DI, and ADX |
| Extremes and statistics | highest, lowest, highestbars, lowestbars, median, percentrank, linreg, correlation |
| Changes and totals | change, mom, roc, cum |
| Crosses and conditions | cross, crossover, crossunder, rising, falling |
| Pivots and events | pivothigh, pivotlow, barssince, valuewhen |
| Volume | obv, accdist, and day-anchored vwap |
Common math.* helpers, math.sum, na, nz, and fixnan are available. Numeric str.tostring() formatting supports common decimal/grouping patterns, format.mintick, format.percent, and format.volume.
Bar-state values update with replay execution, including barstate.isconfirmed. Time components use the instrument timezone. Session and calendar behavior is not complete across every Pine time function; VWAP currently resets by calendar day in the exchange timezone.
Plots and drawing objects
| Visual | Support |
|---|---|
| Numeric plots | Lines, step lines, circles, histograms, columns, and areas; per-bar colors and transparency |
hline() | Constant or input-controlled levels with solid, dashed, or dotted lines |
plotshape() / plotchar() | Shape and character glyphs, including absolute, above/below-bar, and pane-edge locations |
plotarrow() | Signed arrows with configurable minimum and maximum heights |
plotbar() / plotcandle() | OHLC drawings with colors, na visibility, show_last, and force_overlay |
bgcolor() | Colored background bands for individual bars |
barcolor() | Candle-body color; the chart’s wick and border styling is preserved |
fill() | Fills between compatible pairs of plot IDs or horizontal-line IDs, including dynamic colors |
| Lines, boxes, and labels | Creation, supported setters, deletion, line extensions/arrowheads, and multiline text |
linefill | Fills that follow the referenced lines |
| Polylines | Straight or curved paths, closed shapes, and fill colors |
| Tables | All nine positions, merged cells, regional clearing, text/alignment/size/color setters, tooltips, and supported font formatting |
Open-candle redraws replace temporary output and restore prior drawing state. Exact font metrics, curve interpolation, marker sizing, and plot widths can differ from TradingView.
The following options remain limited:
plot.style_linebr,plot.style_areabr,plot.style_cross, andplot.style_stepline_diamondare not rendered.- Nonzero plot/drawing
offsetandjoin=trueare not supported where checked. show_lastis supported for shape, character, arrow, OHLC, and fill output; it is not supported for numeric plots or background/candle coloring.force_overlayis supported for tables and OHLC output. Other visuals use their script’s pane.- Supported display settings control pane visibility. TradingView’s full status-line and Data Window interfaces are not reproduced.
Libraries
Save each library’s source as a Library with the exact name used by the import, such as local/MathTools/1. Then use import local/MathTools/1 as tools in an indicator or strategy.
Imports resolve from your saved sources. TestMax does not download a TradingView library automatically. Missing versions, duplicate saved names, circular imports, and ambiguous overloads report errors. Libraries are not applied directly to a chart. See the library walkthrough.
Other symbols and timeframes
request.security() and request.security_lower_tf() evaluate supported expressions using chart datasets available in your replay. Add a chart pane for a required symbol or timeframe before applying a script that needs it.
- The same symbol/timeframe can reuse its existing bars.
- Higher-timeframe calculations need an available matching dataset or a supported exact aggregation of finer bars. Automatic aggregation currently requires a UTC, continuous-session bar grid; exchange-session rebucketing is not available.
- Lower-timeframe requests require an available finer dataset whose interval divides the chart interval.
request.security_lower_tf()returns the revealed intrabars as arrays. - Gaps and lookahead settings operate within the replay’s revealed-data boundary. A request cannot provide future replay candles, so scripts relying on future historical values can differ from a complete TradingView history run.
- Requested results can be primitive values or flat tuples. Nested requests, chart drawing/order calls inside requested expressions, currency conversion, and
calc_bars_countare not supported.
If an error says data is unavailable, add the matching pane and apply again. If a requested expression captures a mutable outer value, move its calculation into a function evaluated by the request.
Strategy support
Entries, raw orders, stop/limit brackets, trailing stops, partial exits, exit reservations, FIFO/ANY allocation, entry/order OCA groups, immediate closes, commissions, margin checks, and margin liquidation are implemented. The Strategies guide explains their defaults and fill rules.
Bar Magnifier, alternate calculation modes, strategy risk-control commands, custom OCA groups on strategy.exit(), and automatic currency conversion remain unsupported. Alerts do not send notifications or webhooks; use chart markers or tables for feedback during replay.
Limits
| Limit | Value |
|---|---|
| Editor, paste, import, save, and export | 50 MiB of valid UTF-8 per script |
| Script plus imported libraries | 50 MiB combined; up to 16 libraries |
| Saved scripts | 1,000 per account |
| Account script storage | 100 MiB by default; administrator configurable |
| Applied scripts | 10 per symbol |
| Compile and history calculation | 30 seconds each |
| Executable source complexity | 100,000 code tokens; deeply nested expressions may also be rejected |
| TA lookback | 10,000 bars |
| Collections | 100,000 elements per collection; maps up to 50,000 key/value pairs |
| Data requests | 40 request contexts, using available replay data |
| Drawing counts | 50 by default; declared line/box/label limits up to 500 and polyline limits up to 100 |
| Table cells | 10,000 per script |
| Strategy orders | 1,000 calls per execution and 1,000 pending orders |
| Strategy history | 10,000 trade records |
A 30 MiB comment-heavy script can compile and run when its executable body fits the workload limits. Large document size alone does not determine calculation cost. Dense generated code, extensive loops, large collections, and excessive chart output can exceed separate execution limits.
Large documents automatically use plain-text editor mode. Wait for a large paste or import to finish checking before saving or applying. If you hit a limit, reduce the calculation’s lookback, collection size, drawing count, or loaded history as appropriate. Additional memory and output limits can stop a run with a specific error.
Errors and recovery
Compile errors appear in the editor’s error console; use the reported location to find the relevant code. Runtime errors include the bar where execution stopped. Re-apply after correcting the script or providing its missing data. Other applied scripts can keep running.