TradingCharts

Built-In Reference

Every built-in function the ChartScript compiler accepts — 449 functions grouped by namespace, with their signatures. Generated from the compiler and the Pine v6 reference on 2026-10-16.

Global functions (declarations, plotting, time)

Function Signature
alert alert(message, freq) → void
alertcondition alertcondition(condition, title?, message?) — Registers an alert trigger. Server-side alert rules fire when condition is true.
barcolor barcolor(color, offset, editable, show_last, title, display) → void
bgcolor bgcolor(color, offset, editable, show_last, title, display, force_overlay) → void
bool bool(x) → const bool
color color(x) → const color
dayofmonth dayofmonth(time, timezone) → series int
dayofweek dayofweek(time, timezone) → series int
fill fill(plot1, plot2, color?) — Fills the background between two plots or hlines.
fixnan fixnan(source) → series float
float float(x) → const float
hline hline(price, title?, color?, linestyle?) — Horizontal line at a fixed price level.
hour hour(time, timezone) → series int
indicator indicator(title, overlay?, ...) — Declares the script as an indicator. overlay=true draws on the price chart; otherwise a separate pane is used.
input input(defval, title, tooltip, inline, group, display, active) → input bool
int int(x) → simple int
library library(title, overlay, dynamic_requests) → void
max_bars_back max_bars_back(var, num) → void
minute minute(time, timezone) → series int
month month(time, timezone) → series int
na na(x) → simple bool
nz nz(source, replacement?) → series — Replaces na values with replacement (default 0).
plot plot(series, title?, color?, linewidth?, style?) — Plots a series as a line (or histogram/columns via style).
plotarrow plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display, format, precision, force_overlay) → void
plotbar plotbar(open, high, low, close, title, color, editable, show_last, display, format, precision, force_overlay) → void
plotcandle plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display, format, precision, force_overlay) → void
plotchar plotchar(condition, title?, char?, location?, color?) — Draws a text character on bars where condition is true.
plotshape plotshape(condition, title?, style?, location?, color?, text?, size?) — Draws a shape on bars where condition is true.
second second(time, timezone) → series int
strategy strategy(title, overlay?, ...) — Declares the script as a strategy that can simulate entries/exits. pyramiding caps same-direction entries (default 1); default_qty_type (strategy.fixed / strategy.percent_of_equity / strategy.cash) with default_qty_value sizes orders that omit qty=; slippage (ticks) worsens market/stop fills; commission_type (strategy.commission.percent / .cash_per_contract / .cash_per_order) with commission_value sets the commission model applied in backtest reports and trade accessors.
string string(x) → const string
time time(timeframe, session, bars_back, timeframe_bars_back) → series int
time_close time_close(timeframe, session, bars_back, timeframe_bars_back) → series int
timestamp timestamp(dateString) → const int
weekofyear weekofyear(time, timezone) → series int
year year(time, timezone) → series int

ta.* — technical analysis

Function Signature
ta.alma ta.alma(series, length, offset, sigma, floor) → series float
ta.atr ta.atr(length) → series float
ta.barssince ta.barssince(condition) → series int
ta.bb ta.bb(series, length, mult) → [series float, series float, series float]
ta.bbw ta.bbw(series, length, mult) → series float
ta.cci ta.cci(source, length) → series float
ta.change ta.change(source, length) → series float
ta.cmo ta.cmo(series, length) → series float
ta.cog ta.cog(source, length) → series float
ta.correlation ta.correlation(source1, source2, length) → series float
ta.cross ta.cross(source1, source2) → series bool
ta.crossover ta.crossover(source1, source2) → series bool
ta.crossunder ta.crossunder(source1, source2) → series bool
ta.cum ta.cum(source) → series float
ta.dev ta.dev(source, length) → series float
ta.dmi ta.dmi(diLength, adxSmoothing) → [series float, series float, series float]
ta.ema ta.ema(source, length) → series float
ta.falling ta.falling(source, length) → series bool
ta.highest ta.highest(source, length) → series float
ta.highestbars ta.highestbars(source, length) → series int
ta.hma ta.hma(source, length) → series float
ta.kc ta.kc(series, length, mult, useTrueRange) → [series float, series float, series float]
ta.kcw ta.kcw(series, length, mult, useTrueRange) → series float
ta.linreg ta.linreg(source, length, offset) → series float
ta.lowest ta.lowest(source, length) → series float
ta.lowestbars ta.lowestbars(source, length) → series int
ta.macd ta.macd(source, fastlen, slowlen, siglen) → [series float, series float, series float]
ta.max ta.max(source) → series float
ta.median ta.median(source, length) → series float
ta.mfi ta.mfi(series, length) → series float
ta.min ta.min(source) → series float
ta.mode ta.mode(source, length) → series float
ta.mom ta.mom(source, length) → series float
ta.percentile_linear_interpolation ta.percentile_linear_interpolation(source, length, percentage) → series float
ta.percentile_nearest_rank ta.percentile_nearest_rank(source, length, percentage) → series float
ta.percentrank ta.percentrank(source, length) → series float
ta.pivot_point_levels ta.pivot_point_levels(type, anchor, developing) → array<float>
ta.pivothigh ta.pivothigh(leftbars, rightbars) → series float
ta.pivotlow ta.pivotlow(leftbars, rightbars) → series float
ta.range ta.range(source, length) → series float
ta.rci ta.rci(source, length) → series float
ta.rising ta.rising(source, length) → series bool
ta.rma ta.rma(source, length) → series float
ta.roc ta.roc(source, length) → series float
ta.rsi ta.rsi(source, length) → series float
ta.sar ta.sar(start, inc, max) → series float
ta.sma ta.sma(source, length) → series float
ta.stdev ta.stdev(source, length, biased) → series float
ta.stoch ta.stoch(source, high, low, length) → series float
ta.supertrend ta.supertrend(factor, atrPeriod) → [series float, series float]
ta.swma ta.swma(source) → series float
ta.tr ta.tr(handle_na) → series float
ta.tsi ta.tsi(source, short_length, long_length) → series float
ta.valuewhen ta.valuewhen(condition, source, occurrence) → series float
ta.variance ta.variance(source, length, biased) → series float
ta.vwap ta.vwap(source, anchor) → series float
ta.vwma ta.vwma(source, length) → series float
ta.wma ta.wma(source, length) → series float
ta.wpr ta.wpr(length) → series float

math.*

Function Signature
math.abs math.abs(number) → simple int
math.acos math.acos(angle) → simple float
math.asin math.asin(angle) → simple float
math.atan math.atan(angle) → simple float
math.avg math.avg(number0, number1, ...) → simple float
math.ceil math.ceil(number) → simple int
math.cos math.cos(angle) → simple float
math.exp math.exp(number) → simple float
math.floor math.floor(number) → simple int
math.log math.log(number) → simple float
math.log10 math.log10(number) → simple float
math.max math.max(number0, number1, ...) → const int
math.min math.min(number0, number1, ...) → const int
math.pow math.pow(base, exponent) → simple float
math.random math.random(min, max, seed) → series float
math.round math.round(number) → simple int
math.round_to_mintick math.round_to_mintick(number) → simple float
math.sign math.sign(number) → simple float
math.sin math.sin(angle) → simple float
math.sqrt math.sqrt(number) → simple float
math.sum math.sum(source, length) → series float
math.tan math.tan(angle) → simple float
math.todegrees math.todegrees(radians) → series float
math.toradians math.toradians(degrees) → series float

str.* — strings

Function Signature
str.contains str.contains(source, str) → const bool
str.endswith str.endswith(source, str) → const bool
str.format str.format(formatString, arg0, arg1, ...) → simple string
str.format_time str.format_time(time, format, timezone) → series string
str.length str.length(string) → const int
str.lower str.lower(source) → const string
str.match str.match(source, regex) → simple string
str.pos str.pos(source, str) → const int
str.repeat str.repeat(source, repeat, separator) → const string
str.replace str.replace(source, target, replacement, occurrence) → const string
str.replace_all str.replace_all(source, target, replacement) → simple string
str.split str.split(string, separator) → array<string>
str.startswith str.startswith(source, str) → const bool
str.substring str.substring(source, begin_pos, end_pos) → const string
str.tonumber str.tonumber(string) → series float
str.tostring str.tostring(value) → series string
str.trim str.trim(source) → const string
str.upper str.upper(source) → const string

color.*

Function Signature
color.b color.b(color) → series float
color.from_gradient color.from_gradient(value, bottom_value, top_value, bottom_color, top_color) → series color
color.g color.g(color) → series float
color.new color.new(color, transp) → const color
color.r color.r(color) → series float
color.rgb color.rgb(red, green, blue, transp) → series color
color.t color.t(color) → series float

input.* — script inputs

Function Signature
input.bool input.bool(defval, title, tooltip, inline, group, confirm, display, active) → input bool
input.color input.color(defval, title, tooltip, inline, group, confirm, display, active) → input color
input.enum input.enum(defval, title, options, tooltip, inline, group, confirm, display, active) → input enum
input.float input.float(defval, title, minval, maxval, step, tooltip, inline, group, confirm, display, active) → input float
input.int input.int(defval, title, minval, maxval, step, tooltip, inline, group, confirm, display, active) → input int
input.price input.price(defval, title, tooltip, inline, group, confirm, display, active) → input float
input.session input.session(defval, title, options, tooltip, inline, group, confirm, display, active) → input string
input.source input.source(defval, title, tooltip, inline, group, display, active, confirm) → series float
input.string input.string(defval, title, options, tooltip, inline, group, confirm, display, active) → input string
input.symbol input.symbol(defval, title, tooltip, inline, group, confirm, display, active) → input string
input.text_area input.text_area(defval, title, tooltip, group, confirm, display, active) → input string
input.time input.time(defval, title, tooltip, inline, group, confirm, display, active) → input int
input.timeframe input.timeframe(defval, title, options, tooltip, inline, group, confirm, display, active) → input string

request.* — other symbols, timeframes and data

Function Signature
request.dividends request.dividends(ticker, field?) → series — Dividend per share, visible from each ex-date onward. field is dividends.gross (default) or dividends.net.
request.earnings request.earnings(ticker, field?) → series — Quarterly earnings per share, stepped at fiscal-quarter boundaries. field is earnings.actual (default) or earnings.standardized.
request.economic request.economic(country_code, field, gaps, ignore_invalid_symbol) → series float
request.financial request.financial(symbol, financial_id, period) → series — Fundamental data (e.g. "TOTAL_REVENUE", "NET_INCOME", "EARNINGS_PER_SHARE") stepped onto chart bars at fiscal-period boundaries. period is "FY", "FQ", or "TTM". Server executions resolve from the securities financial cache.
request.security request.security(symbol, timeframe, expression) → series — Evaluates expression on another symbol/timeframe. Server executions preload every referenced timeframe from real market data.
request.security_lower_tf request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency, ignore_invalid_timeframe, calc_bars_count) → array<type>
request.splits request.splits(ticker, field) → series — Split/bonus ratio components, visible from each ex-date onward. field is splits.numerator or splits.denominator.

ticker.* — synthetic tickers

Function Signature
ticker.heikinashi ticker.heikinashi(symbol) → simple string
ticker.inherit ticker.inherit(from_tickerid, symbol) → simple string
ticker.kagi ticker.kagi(symbol, reversal) → simple string
ticker.linebreak ticker.linebreak(symbol, number_of_lines) → simple string
ticker.modify ticker.modify(tickerid, session, adjustment, backadjustment, settlement_as_close) → simple string
ticker.new ticker.new(prefix, ticker, session, adjustment, backadjustment, settlement_as_close) → simple string
ticker.pointfigure ticker.pointfigure(symbol, source, style, param, reversal) → simple string
ticker.renko ticker.renko(symbol, style, param, request_wicks, source) → simple string
ticker.standard ticker.standard(symbol) → simple string

array.*

Function Signature
array.abs array.abs(id) → array<float>
array.avg array.avg(id) → series float
array.binary_search array.binary_search(id, val) → series int
array.binary_search_leftmost array.binary_search_leftmost(id, val) → series int
array.binary_search_rightmost array.binary_search_rightmost(id, val) → series int
array.clear array.clear(id) → void
array.concat array.concat(id1, id2) → array<type>
array.copy array.copy(id) → array<type>
array.covariance array.covariance(id1, id2, biased) → series float
array.every array.every(id) → series bool
array.fill array.fill(id, value, index_from, index_to) → void
array.first array.first(id) → series <type>
array.from array.from(arg0, arg1, ...) → array<type>
array.get array.get(id, index) → series <type>
array.includes array.includes(id, value) → series bool
array.indexof array.indexof(id, value) → series int
array.insert array.insert(id, index, value) → void
array.join array.join(id, separator) → series string
array.last array.last(id) → series <type>
array.lastindexof array.lastindexof(id, value) → series int
array.max array.max(id, nth) → series float
array.median array.median(id) → series float
array.min array.min(id, nth) → series float
array.mode array.mode(id) → series float
array.new<type> array.new<type>(size, initial_value) → array<type>
array.new_bool array.new_bool(size, initial_value) → array<bool>
array.new_box array.new_box(size, initial_value) → array<box>
array.new_color array.new_color(size, initial_value) → array<color>
array.new_float array.new_float(size, initial_value) → array<float>
array.new_int array.new_int(size, initial_value) → array<int>
array.new_label array.new_label(size, initial_value) → array<label>
array.new_line array.new_line(size, initial_value) → array<line>
array.new_linefill array.new_linefill(size, initial_value) → array<linefill>
array.new_string array.new_string(size, initial_value) → array<string>
array.new_table array.new_table(size, initial_value) → array<table>
array.percentile_linear_interpolation array.percentile_linear_interpolation(id, percentage) → series float
array.percentile_nearest_rank array.percentile_nearest_rank(id, percentage) → series float
array.percentrank array.percentrank(id, index) → series float
array.pop array.pop(id) → series <type>
array.push array.push(id, value) → void
array.range array.range(id) → series float
array.remove array.remove(id, index) → series <type>
array.reverse array.reverse(id) → void
array.set array.set(id, index, value) → void
array.shift array.shift(id) → series <type>
array.size array.size(id) → series int
array.slice array.slice(id, index_from, index_to) → array<type>
array.some array.some(id) → series bool
array.sort array.sort(id, order) → void
array.sort_indices array.sort_indices(id, order) → array<int>
array.standardize array.standardize(id) → array<float>
array.stdev array.stdev(id, biased) → series float
array.sum array.sum(id) → series float
array.unshift array.unshift(id, value) → void
array.variance array.variance(id, biased) → series float

map.*

Function Signature
map.clear map.clear(id) → void
map.contains map.contains(id, key) → series bool
map.copy map.copy(id) → map<keyType, valueType>
map.get map.get(id, key) → <value_type>
map.keys map.keys(id) → array<type>
map.new<type,type> —
map.put map.put(id, key, value) → <value_type>
map.put_all map.put_all(id, id2) → void
map.remove map.remove(id, key) → <value_type>
map.size map.size(id) → series int
map.values map.values(id) → array<type>

matrix.*

Function Signature
matrix.add_col matrix.add_col(id, column, array_id) → void
matrix.add_row matrix.add_row(id, row, array_id) → void
matrix.avg matrix.avg(id) → series float
matrix.col matrix.col(id, column) → array<type>
matrix.columns matrix.columns(id) → series int
matrix.concat matrix.concat(id1, id2) → matrix<type>
matrix.copy matrix.copy(id) → matrix<type>
matrix.det matrix.det(id) → series float
matrix.diff matrix.diff(id1, id2) → matrix<int>
matrix.eigenvalues matrix.eigenvalues(id) → array<float>
matrix.eigenvectors matrix.eigenvectors(id) → matrix<float>
matrix.elements_count matrix.elements_count(id) → series int
matrix.fill matrix.fill(id, value, from_row, to_row, from_column, to_column) → void
matrix.get matrix.get(id, row, column) → <matrix_type>
matrix.inv matrix.inv(id) → matrix<float>
matrix.is_antidiagonal matrix.is_antidiagonal(id) → series bool
matrix.is_antisymmetric matrix.is_antisymmetric(id) → series bool
matrix.is_binary matrix.is_binary(id) → series bool
matrix.is_diagonal matrix.is_diagonal(id) → series bool
matrix.is_identity matrix.is_identity(id) → series bool
matrix.is_square matrix.is_square(id) → series bool
matrix.is_stochastic matrix.is_stochastic(id) → series bool
matrix.is_symmetric matrix.is_symmetric(id) → series bool
matrix.is_triangular matrix.is_triangular(id) → series bool
matrix.is_zero matrix.is_zero(id) → series bool
matrix.kron matrix.kron(id1, id2) → matrix<float>
matrix.max matrix.max(id) → series float
matrix.median matrix.median(id) → series float
matrix.min matrix.min(id) → series float
matrix.mode matrix.mode(id) → series float
matrix.mult matrix.mult(id1, id2) → matrix<int>
matrix.new<type> matrix.new<type>(rows, columns, initial_value) → matrix<type>
matrix.pinv matrix.pinv(id) → matrix<float>
matrix.pow matrix.pow(id, power) → matrix<float>
matrix.rank matrix.rank(id) → series int
matrix.remove_col matrix.remove_col(id, column) → array<type>
matrix.remove_row matrix.remove_row(id, row) → array<type>
matrix.reshape matrix.reshape(id, rows, columns) → void
matrix.reverse matrix.reverse(id) → void
matrix.row matrix.row(id, row) → array<type>
matrix.rows matrix.rows(id) → series int
matrix.set matrix.set(id, row, column, value) → void
matrix.sort matrix.sort(id, column, order) → void
matrix.submatrix matrix.submatrix(id, from_row, to_row, from_column, to_column) → matrix<type>
matrix.sum matrix.sum(id1, id2) → matrix<int>
matrix.swap_columns matrix.swap_columns(id, column1, column2) → void
matrix.swap_rows matrix.swap_rows(id, row1, row2) → void
matrix.trace matrix.trace(id) → series float
matrix.transpose matrix.transpose(id) → matrix<type>

line.*

Function Signature
line.copy line.copy(id) → series line
line.delete line.delete(id) → void
line.get_price line.get_price(id, x) → series float
line.get_x1 line.get_x1(id) → series int
line.get_x2 line.get_x2(id) → series int
line.get_y1 line.get_y1(id) → series float
line.get_y2 line.get_y2(id) → series float
line.new line.new(x1, y1, x2, y2, ...) → line — Creates a line segment.
line.set_color line.set_color(id, color) → void
line.set_extend line.set_extend(id, extend) → void
line.set_first_point line.set_first_point(id, point) → void
line.set_second_point line.set_second_point(id, point) → void
line.set_style line.set_style(id, style) → void
line.set_width line.set_width(id, width) → void
line.set_x1 line.set_x1(id, x) → void
line.set_x2 line.set_x2(id, x) → void
line.set_xloc line.set_xloc(id, x1, x2, xloc) → void
line.set_xy1 line.set_xy1(id, x, y) → void
line.set_xy2 line.set_xy2(id, x, y) → void
line.set_y1 line.set_y1(id, y) → void
line.set_y2 line.set_y2(id, y) → void

label.*

Function Signature
label.copy label.copy(id) → series label
label.delete label.delete(id) → void
label.get_text label.get_text(id) → series string
label.get_x label.get_x(id) → series int
label.get_y label.get_y(id) → series float
label.new label.new(x, y, text?, ...) → label — Creates a text label.
label.set_color label.set_color(id, color) → void
label.set_point label.set_point(id, point) → void
label.set_size label.set_size(id, size) → void
label.set_style label.set_style(id, style) → void
label.set_text label.set_text(id, text) → void
label.set_text_font_family label.set_text_font_family(id, text_font_family) → void
label.set_text_formatting label.set_text_formatting(id, text_formatting) → void
label.set_textalign label.set_textalign(id, textalign) → void
label.set_textcolor label.set_textcolor(id, textcolor) → void
label.set_tooltip label.set_tooltip(id, tooltip) → void
label.set_x label.set_x(id, x) → void
label.set_xloc label.set_xloc(id, x, xloc) → void
label.set_xy label.set_xy(id, x, y) → void
label.set_y label.set_y(id, y) → void
label.set_yloc label.set_yloc(id, yloc) → void

box.*

Function Signature
box.copy box.copy(id) → series box
box.delete box.delete(id) → void
box.get_bottom box.get_bottom(id) → series float
box.get_left box.get_left(id) → series int
box.get_right box.get_right(id) → series int
box.get_top box.get_top(id) → series float
box.new box.new(left, top, right, bottom, ...) → box — Creates a rectangle in bar-index/price coordinates. Mutate with box.set_* functions.
box.set_bgcolor box.set_bgcolor(id, color) → void
box.set_border_color box.set_border_color(id, color) → void
box.set_border_style box.set_border_style(id, style) → void
box.set_border_width box.set_border_width(id, width) → void
box.set_bottom box.set_bottom(id, bottom) → void
box.set_bottom_right_point box.set_bottom_right_point(id, point) → void
box.set_extend box.set_extend(id, extend) → void
box.set_left box.set_left(id, left) → void
box.set_lefttop box.set_lefttop(id, left, top) → void
box.set_right box.set_right(id, right) → void
box.set_rightbottom box.set_rightbottom(id, right, bottom) → void
box.set_text box.set_text(id, text) → void
box.set_text_color box.set_text_color(id, text_color) → void
box.set_text_font_family box.set_text_font_family(id, text_font_family) → void
box.set_text_formatting box.set_text_formatting(id, text_formatting) → void
box.set_text_halign box.set_text_halign(id, text_halign) → void
box.set_text_size box.set_text_size(id, text_size) → void
box.set_text_valign box.set_text_valign(id, text_valign) → void
box.set_text_wrap box.set_text_wrap(id, text_wrap) → void
box.set_top box.set_top(id, top) → void
box.set_top_left_point box.set_top_left_point(id, point) → void
box.set_xloc box.set_xloc(id, left, right, xloc) → void

table.*

Function Signature
table.cell table.cell(table, column, row, text?, ...) — Sets one cell of a table.
table.cell_set_bgcolor table.cell_set_bgcolor(table_id, column, row, bgcolor) → void
table.cell_set_height table.cell_set_height(table_id, column, row, height) → void
table.cell_set_text table.cell_set_text(table_id, column, row, text) → void
table.cell_set_text_color table.cell_set_text_color(table_id, column, row, text_color) → void
table.cell_set_text_font_family table.cell_set_text_font_family(table_id, column, row, text_font_family) → void
table.cell_set_text_formatting table.cell_set_text_formatting(table_id, column, row, text_formatting) → void
table.cell_set_text_halign table.cell_set_text_halign(table_id, column, row, text_halign) → void
table.cell_set_text_size table.cell_set_text_size(table_id, column, row, text_size) → void
table.cell_set_text_valign table.cell_set_text_valign(table_id, column, row, text_valign) → void
table.cell_set_tooltip table.cell_set_tooltip(table_id, column, row, tooltip) → void
table.cell_set_width table.cell_set_width(table_id, column, row, width) → void
table.clear table.clear(table_id, start_column, start_row, end_column, end_row) → void
table.delete table.delete(table_id) → void
table.merge_cells table.merge_cells(table_id, start_column, start_row, end_column, end_row) → void
table.new table.new(position, columns, rows, ...) → table — Creates a chart-corner data table. Fill cells with table.cell().
table.set_bgcolor table.set_bgcolor(table_id, bgcolor) → void
table.set_border_color table.set_border_color(table_id, border_color) → void
table.set_border_width table.set_border_width(table_id, border_width) → void
table.set_frame_color table.set_frame_color(table_id, frame_color) → void
table.set_frame_width table.set_frame_width(table_id, frame_width) → void
table.set_position table.set_position(table_id, position) → void

polyline.*

Function Signature
polyline.delete polyline.delete(id) → void
polyline.new polyline.new(points, curved, closed, xloc, line_color, fill_color, line_style, line_width, force_overlay) → series polyline

linefill.*

Function Signature
linefill.delete linefill.delete(id) → void
linefill.get_line1 linefill.get_line1(id) → series line
linefill.get_line2 linefill.get_line2(id) → series line
linefill.new linefill.new(line1, line2, color) → series linefill
linefill.set_color linefill.set_color(id, color) → void

chart.point.*

Function Signature
chart.point.copy chart.point.copy(id) → chart.point
chart.point.from_index chart.point.from_index(index, price) → chart.point
chart.point.from_time chart.point.from_time(time, price) → chart.point
chart.point.new chart.point.new(time, index, price) → chart.point
chart.point.now chart.point.now(price) → chart.point

strategy.* — orders, risk, trade accessors

Function Signature
strategy.cancel strategy.cancel(id) — Cancels the working entry or exit order with the given id.
strategy.cancel_all strategy.cancel_all() → void
strategy.close strategy.close(id, when?) — Closes the open trade with the given id at the bar close.
strategy.close_all strategy.close_all(when?) — Closes every open trade at the bar close and cancels working exit orders.
strategy.closedtrades.commission strategy.closedtrades.commission(trade_num) → series float
strategy.closedtrades.entry_bar_index strategy.closedtrades.entry_bar_index(trade_num) → series int
strategy.closedtrades.entry_comment strategy.closedtrades.entry_comment(trade_num) → series string
strategy.closedtrades.entry_id strategy.closedtrades.entry_id(trade_num) → series string
strategy.closedtrades.entry_price strategy.closedtrades.entry_price(trade_num) → series float
strategy.closedtrades.entry_time strategy.closedtrades.entry_time(trade_num) → series int
strategy.closedtrades.exit_bar_index strategy.closedtrades.exit_bar_index(trade_num) → series int
strategy.closedtrades.exit_comment strategy.closedtrades.exit_comment(trade_num) → series string
strategy.closedtrades.exit_id strategy.closedtrades.exit_id(trade_num) → series string
strategy.closedtrades.exit_price strategy.closedtrades.exit_price(trade_num) → series float
strategy.closedtrades.exit_time strategy.closedtrades.exit_time(trade_num) → series int
strategy.closedtrades.max_drawdown strategy.closedtrades.max_drawdown(trade_num) → series float
strategy.closedtrades.max_drawdown_percent strategy.closedtrades.max_drawdown_percent(trade_num) → series float
strategy.closedtrades.max_runup strategy.closedtrades.max_runup(trade_num) → series float
strategy.closedtrades.max_runup_percent strategy.closedtrades.max_runup_percent(trade_num) → series float
strategy.closedtrades.profit strategy.closedtrades.profit(trade_num) → series float
strategy.closedtrades.profit_percent strategy.closedtrades.profit_percent(trade_num) → series float
strategy.closedtrades.size strategy.closedtrades.size(trade_num) → series float
strategy.convert_to_account strategy.convert_to_account(value) → series float
strategy.convert_to_symbol strategy.convert_to_symbol(value) → series float
strategy.default_entry_qty strategy.default_entry_qty(fill_price) → series float
strategy.entry strategy.entry(id, direction, qty?, when?, limit?, stop?, oca_name?, oca_type?) — Opens a position at the bar close, or — with limit=/stop= — places a working entry order filled intrabar on later bars (both = stop-limit). An opposite open position is reversed (closed first); same-direction adds are capped by the declaration's pyramiding. oca_name groups working orders; when one fills, siblings react per their oca_type (strategy.oca.cancel / .reduce / .none). Omitted qty uses the default sizing. Idempotent per id; re-issuing replaces the working order.
strategy.exit strategy.exit(id, from_entry?, stop?, limit?, profit?, loss?, trail_price?, trail_points?, trail_offset?, qty?, qty_percent?, when?) — Registers a working exit order, evaluated intrabar against subsequent bars' OHLC. stop/limit are prices; profit/loss are tick distances from the entry price; trail_price (level) or trail_points (distance) arms a trail that follows by trail_offset. qty/qty_percent exit part of the trade. Gap opens fill at the open; when both stop and limit are touched in one bar, the stop fills.
strategy.opentrades.commission strategy.opentrades.commission(trade_num) → series float
strategy.opentrades.entry_bar_index strategy.opentrades.entry_bar_index(trade_num) → series int
strategy.opentrades.entry_comment strategy.opentrades.entry_comment(trade_num) → series string
strategy.opentrades.entry_id strategy.opentrades.entry_id(trade_num) → series string
strategy.opentrades.entry_price strategy.opentrades.entry_price(trade_num) → series float
strategy.opentrades.entry_time strategy.opentrades.entry_time(trade_num) → series int
strategy.opentrades.max_drawdown strategy.opentrades.max_drawdown(trade_num) → series float
strategy.opentrades.max_drawdown_percent strategy.opentrades.max_drawdown_percent(trade_num) → series float
strategy.opentrades.max_runup strategy.opentrades.max_runup(trade_num) → series float
strategy.opentrades.max_runup_percent strategy.opentrades.max_runup_percent(trade_num) → series float
strategy.opentrades.profit strategy.opentrades.profit(trade_num) → series float
strategy.opentrades.profit_percent strategy.opentrades.profit_percent(trade_num) → series float
strategy.opentrades.size strategy.opentrades.size(trade_num) → series float
strategy.order strategy.order(id, direction, qty?, when?) — Market order that nets against the opposite position FIFO; any remainder opens a new trade under id.
strategy.risk.allow_entry_in strategy.risk.allow_entry_in(value) → void
strategy.risk.max_cons_loss_days strategy.risk.max_cons_loss_days(count, alert_message) → void
strategy.risk.max_drawdown strategy.risk.max_drawdown(value, type, alert_message) → void
strategy.risk.max_intraday_filled_orders strategy.risk.max_intraday_filled_orders(count, alert_message) → void
strategy.risk.max_intraday_loss strategy.risk.max_intraday_loss(value, type, alert_message) → void
strategy.risk.max_position_size strategy.risk.max_position_size(contracts) → void

log.*

Function Signature
log.error log.error(message) → void
log.info log.info(message) → void
log.warning log.warning(message) → void

runtime.*

Function Signature
runtime.error runtime.error(message) → void

timeframe.*

Function Signature
timeframe.change timeframe.change(timeframe) → series bool
timeframe.from_seconds timeframe.from_seconds(seconds) → simple string
timeframe.in_seconds timeframe.in_seconds(timeframe) → simple int

syminfo.*

Function Signature
syminfo.prefix syminfo.prefix(symbol) → simple string
syminfo.ticker syminfo.ticker(symbol) → simple string