Skip to content
Back to App

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

FeatureSupport
indicator() and strategy()Indicators and strategies can be applied to replay charts
library() and importAvailable library source can be saved in your account and imported by exact path
InputsInteger, float, boolean, string, color, source, timeframe, session, and time inputs
Control flowif / else, for, while, and switch
Functions and typesUser-defined functions, supported methods, and user-defined types
CollectionsSupported array, matrix, and map operations, with size limits
Series historyx[n] and history-dependent calculations
Persistent statevar 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

CategoryFunctions and built-ins
Moving averagessma, ema, rma, wma, vwma, swma
Oscillatorsrsi, macd, stoch, cci, mfi
Bands and dispersionbb, stdev, variance, dev, atr, tr
Trendsupertrend, sar, dmidmi returns +DI, −DI, and ADX
Extremes and statisticshighest, lowest, highestbars, lowestbars, median, percentrank, linreg, correlation
Changes and totalschange, mom, roc, cum
Crosses and conditionscross, crossover, crossunder, rising, falling
Pivots and eventspivothigh, pivotlow, barssince, valuewhen
Volumeobv, 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

VisualSupport
Numeric plotsLines, 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 labelsCreation, supported setters, deletion, line extensions/arrowheads, and multiline text
linefillFills that follow the referenced lines
PolylinesStraight or curved paths, closed shapes, and fill colors
TablesAll 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, and plot.style_stepline_diamond are not rendered.
  • Nonzero plot/drawing offset and join=true are not supported where checked.
  • show_last is supported for shape, character, arrow, OHLC, and fill output; it is not supported for numeric plots or background/candle coloring.
  • force_overlay is 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_count are 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

LimitValue
Editor, paste, import, save, and export50 MiB of valid UTF-8 per script
Script plus imported libraries50 MiB combined; up to 16 libraries
Saved scripts1,000 per account
Account script storage100 MiB by default; administrator configurable
Applied scripts10 per symbol
Compile and history calculation30 seconds each
Executable source complexity100,000 code tokens; deeply nested expressions may also be rejected
TA lookback10,000 bars
Collections100,000 elements per collection; maps up to 50,000 key/value pairs
Data requests40 request contexts, using available replay data
Drawing counts50 by default; declared line/box/label limits up to 500 and polyline limits up to 100
Table cells10,000 per script
Strategy orders1,000 calls per execution and 1,000 pending orders
Strategy history10,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.