Built-ins and plotting
Declarations, plotting, colouring the chart, and the small helpers every script uses: na, nz, fixnan.
54 names from PineTS 0.11.1 · 19 with full entries
indicator
Verifiedindicator(title, shorttitle, overlay, format, precision, max_bars_back, max_lines_count, max_labels_count, max_boxes_count)
Declares the script an indicator. Must be the first statement after the version line.
| Argument | Type | Meaning |
|---|---|---|
| title | const string | The name shown in the legend and the catalogue. |
| shorttitleoptional | const string | A shorter name for the legend. |
| overlayoptional | const bool | true draws on the price chart; false (default) gives the script its own pane. |
| precisionoptional | const int | Decimal places for values in the legend. |
See alsostrategy
strategy
Verifiedstrategy(title, shorttitle, overlay, initial_capital, default_qty_type, default_qty_value, pyramiding, commission_type, commission_value, slippage)
Declares the script a strategy, which can place simulated orders and produce a backtest.
| Argument | Type | Meaning |
|---|---|---|
| title | const string | The strategy's name. |
| overlayoptional | const bool | Draw on the price chart. |
| initial_capitaloptional | const float | Starting equity. Default 1,000,000. |
| default_qty_typeoptional | const string | strategy.fixed, strategy.cash or strategy.percent_of_equity. |
| default_qty_valueoptional | const float | The order size in that unit. |
| pyramidingoptional | const int | How many entries may stack in one direction. Default 0. |
| commission_typeoptional | const string | strategy.commission.percent, cash_per_contract or cash_per_order. |
| commission_valueoptional | const float | Commission in that unit. |
| slippageoptional | const int | Slippage in ticks added to market fills. |
See alsostrategy.entrystrategy.exit
plot
Verifiedplot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display, force_overlay)
Draws a series on the chart, one value per bar.
| Argument | Type | Meaning |
|---|---|---|
| series | series int/float | The values to draw. na leaves a gap. |
| titleoptional | const string | Name in the legend and settings. |
| coloroptional | series color | Line colour; may change per bar. |
| linewidthoptional | input int | Width in pixels, 1 to 4. |
| styleoptional | input plot_style | plot.style_line, _linebr, _stepline, _histogram, _columns, _area, _areabr, _circles, _cross. |
| offsetoptional | simple int | Shift the plot left (negative) or right by bars. |
| show_lastoptional | input int | Draw only the last N bars. |
| displayoptional | input plot_display | display.none computes without drawing. |
| force_overlayoptional | const bool | Draw on the price chart from a pane script. |
Returns A plot id, for fill().
//@version=6indicator("plot", overlay = true)plot(ta.sma(close, 20), "SMA 20", color = color.orange, linewidth = 2)plotshape
Verifiedplotshape(series, title, style, location, color, offset, text, textcolor, size, show_last, display, force_overlay)
Draws a shape on bars where the series is true or a non-zero number.
| Argument | Type | Meaning |
|---|---|---|
| series | series bool/float | Where to draw. na, false and 0 draw nothing. |
| styleoptional | input string | shape.triangleup, triangledown, circle, cross, xcross, diamond, square, flag, arrowup, arrowdown, labelup, labeldown. |
| locationoptional | input string | location.abovebar, belowbar, top, bottom, absolute. |
| sizeoptional | const string | size.tiny, small, normal, large, huge, auto. |
| textoptional | const string | Text drawn with the shape. |
//@version=6indicator("plotshape", overlay = true)plotshape(ta.crossover(ta.ema(close, 9), ta.ema(close, 21)), "Cross", style = shape.triangleup, location = location.belowbar, color = color.teal, size = size.small)plotchar
Verifiedplotchar(series, title, char, location, color, offset, text, textcolor, size, show_last, display)
Draws a single character on bars where the series is true or non-zero.
| Argument | Type | Meaning |
|---|---|---|
| char | input string | One character, for example "x" or "▲". |
See alsoplotshape
plotarrow
Supportedplotarrow(series, title, colorup, colordown, offset, minheight, maxheight, show_last, display)
Draws an up arrow for positive values and a down arrow for negative ones; zero and na draw nothing.
plotcandle
Verifiedplotcandle(open, high, low, close, title, color, wickcolor, bordercolor, display)
Draws candles from your own OHLC series, for example Heikin Ashi computed in the script.
See alsoplotbar
plotbar
Supportedplotbar(open, high, low, close, title, color, display)
Like plotcandle, but draws OHLC bars.
hline
Verifiedhline(price, title, color, linestyle, linewidth, editable, display)
A fixed horizontal line at a price or level.
| Argument | Type | Meaning |
|---|---|---|
| price | input int/float | Where the line sits. |
| linestyleoptional | input hline_style | hline.style_solid, style_dotted, style_dashed. |
Returns An hline id, for fill().
See alsofill
fill
Verifiedfill(plot1, plot2, color, title, editable, fillgaps, display) · fill(hline1, hline2, color, …)
Shades the area between two plots or two hlines.
| Argument | Type | Meaning |
|---|---|---|
| plot1, plot2 | plot or hline | The ids returned by plot() or hline(). |
| coloroptional | series color | Usually a transparent colour from color.new(). |
//@version=6indicator("fill", overlay = true)[m, u, l] = ta.bb(close, 20, 2)p1 = plot(u, "Upper")p2 = plot(l, "Lower")fill(p1, p2, color = color.new(color.purple, 85))bgcolor
Verifiedbgcolor(color, offset, editable, show_last, title, display, force_overlay)
Tints the background behind each bar. na leaves it untouched.
barcolor
Verifiedbarcolor(color, offset, editable, show_last, title, display)
Recolours the chart's candles.
na
Verifiedna(x) · na
As a value, na means "no value". As a function, na(x) is true when x has no value.
nz
Verifiednz(source, replacement)
Replaces na with a value: 0 by default, or replacement.
//@version=6indicator("nz")change = close - close[1]plot(nz(change), "Change, na as 0")fixnan
Supportedfixnan(source)
Replaces na with the last value that was not na.
alert
Verifiedalert(message, freq)
Emits an alert event when called. On Tradequix it appears in the editor console.
| Argument | Type | Meaning |
|---|---|---|
| freqoptional | input string | alert.freq_all, freq_once_per_bar, freq_once_per_bar_close. |
See alsoalertcondition
alertcondition
Verifiedalertcondition(condition, title, message)
Declares a condition that can be alerted on. Captured and shown in the editor console.
timestamp
Supportedtimestamp(year, month, day, hour, minute, second) · timestamp(timezone, year, …)
A time in milliseconds, for drawings with xloc.bar_time or comparing with time. The feed runs on UTC.
max_bars_back
Supportedmax_bars_back(var, num)
Reserves history for a series that is referenced further back than the engine can infer.
Everything else in Built-ins and plotting
Also implemented. These follow TradingView’s Pine v6 reference for their arguments.
- bar_indexVerifiedImplemented. Arguments as in TradingView's Pine v6 reference.
- boolSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- daySupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- dayofmonthSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- dayofweekSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- errorSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- floatVerifiedImplemented. Arguments as in TradingView's Pine v6 reference.
- freq_allSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- freq_once_per_barSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- freq_once_per_bar_closeSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- hourVerifiedImplemented. Arguments as in TradingView's Pine v6 reference.
- intVerifiedImplemented. Arguments as in TradingView's Pine v6 reference.
- linestyle_dashedSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- linestyle_dottedSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- linestyle_solidSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- minuteSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- monthSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- secondSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- stringSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_areaSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_areabrSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_circlesSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_columnsSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_crossSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_dashedSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_dottedSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_histogramSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_lineSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_linebrSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_solidSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_steplineSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_stepline_diamondSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- style_steplinebrSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- weekofyearSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
- yearVerifiedImplemented. Arguments as in TradingView's Pine v6 reference.