Appearance
Reference
Where do you look up a built-in name? Find its namespace below, or press / and search. Each entry gives the name's signature, its parameters and what it gives in this engine, with an example where the call needs one.
Reading an entry
A badge under each name says where it comes from and whether it works here.
| Badge | Means |
|---|---|
| Pine v6 | Pine Script v6 has the name too, and the badge links TradingView's entry. Where it works differently here, the entry says so. |
| AmenoScript only | Only AmenoScript has it, so a script using it is AmenoScript. On a parameter, a default or one signature line, only that part is. |
| No effect here | Accepted, so a script that uses it still runs, and it does nothing here: it reads na or a fixed value, or changes nothing. |
Language
Types and qualifiers
The kinds of value a script holds, the four qualifiers that say when a value is known, and what na is in each type.
Types · Qualifiers · Declaring a variable's type
Keywords
What each keyword of the language does, from var and if to type and enum.
var · varip · if · switch · for · while · import · export · method · type · enum · true and false
Operators
Arithmetic, comparison, logic, the ternary, history, assignment, and the order operators bind in.
Arithmetic · Comparison · Logic · The ternary · History · Assignment · Coalescing (AmenoScript) · Precedence
Declarations
indicator(), strategy() and library(), the first statement of every script.
indicator · strategy · library
Imports and libraries
Bring a library's functions into a script with import, and which libraries resolve here.
What an import finds · What a library brings · Built-in helpers · See also
Namespaces
Global
The bar's prices and times, na and nz, the type casts and the date functions, with no namespace.
ask · bar_index · bid · bool · box · close · color · dayofmonth · dayofweek · dayofyear · fixnan · float · high · hl2 · hlc3 · hlcc4 · hour · int · label · last_bar_index · last_bar_time · line · linefill · low · max_bars_back · minute · month · na · nz · ohlc4 · open · second · string · table · time · time_close · time_tradingday · timenow · timestamp · volume · weekofyear · year
Alerts
Say when a script's alert should fire, with alert() and alertcondition().
alert · alert.freq_* · alertcondition
array
Lists of values: build them, read and change them, search, sort and summarise them, and keep them across bars with var.
array.new · array.new_* · array.from · array.get · array.set · array.size · array.first · array.last · array.push · array.pop · array.unshift · array.shift · array.insert · array.remove · array.clear · array.fill · array.copy · array.slice · array.concat · array.reverse · array.join · array.includes · array.includes_all · array.indexof · array.lastindexof · array.binary_search · array.binary_search_leftmost · array.binary_search_rightmost · array.sort · array.sort_indices · array.sum · array.avg · array.min · array.max · array.median · array.mode · array.range · array.stdev · array.variance · array.covariance · array.standardize · array.abs · array.percentile_nearest_rank · array.percentile_linear_interpolation · array.percentrank · array.every · array.some · array.map · array.filter · array.reduce · array.sort_by · array.any · array.all · array.find
barstate
Where the current bar sits: first, last, history, realtime, closed or still forming.
barstate.isconfirmed · barstate.isfirst · barstate.ishistory · barstate.islast · barstate.islastconfirmedhistory · barstate.isnew · barstate.isrealtime
book
Trade a whole list of names by stating target weights; the engine fills, charges and keeps the account.
book.config · book.target · book.equity · book.turnover · book.fee · book.funding · book.weights
box
Rectangles between two bars and two prices, with optional text inside.
box.new · box.copy · box.delete · box.all · box.get_left · box.get_right · box.get_top · box.get_bottom · box.set_left · box.set_right · box.set_top · box.set_bottom · box.set_lefttop · box.set_rightbottom · box.set_top_left_point · box.set_bottom_right_point · box.set_xloc · box.set_extend · box.set_border_color · box.set_border_width · box.set_border_style · box.set_bgcolor · box.set_text · box.set_text_color · box.set_text_size · box.set_text_halign · box.set_text_valign · box.set_text_wrap · box.set_text_font_family · box.set_text_formatting
chart
The chart's type, colours and visible range, which this engine reads as fixed values.
chart.bg_color · chart.fg_color · chart.is_standard · chart.is_* · chart.left_visible_bar_time · chart.right_visible_bar_time
chart.point
A point on the chart, a bar and a price, which labels, lines, boxes and polylines take.
chart.point · chart.point.new · chart.point.now · chart.point.from_index · chart.point.from_time · chart.point.copy
color
Make colours, set their transparency, blend them on a gradient and read their channels.
color.b · color.from_gradient · color.g · color.new · color.r · color.rgb · color.t · color.*
Constants
The named values a function's arguments take: where a drawing sits, how big its text is, how a number prints, the days and months.
xloc.* · yloc.* · extend.* · size.* · text.* · font.* · position.* · format.* · order.* · dayofweek.* · month.* · currency.* · scale.*
cs
Rank, standardise and scale an array of values across the members of a list, on one bar.
cs.rank · cs.zscore · cs.scale · cs.winsor · cs.demean · cs.residual · cs.top · cs.row_sum
footprint
Volume footprints are not built here: request.footprint and every footprint.* read na.
footprint.buy_volume · footprint.sell_volume · footprint.total_volume · footprint.delta · footprint.poc · footprint.vah · footprint.val · footprint.rows · footprint.get_row_by_price
input
Settings a reader can change without editing the script: numbers, sources, symbols, times and lists.
input · input.bool · input.check · input.color · input.enum · input.float · input.hline · input.int · input.price · input.session · input.source · input.string · input.symbol · input.text_area · input.time · input.timeframe
label
Text and shapes pinned to a bar and a price, which a script can move, restyle and delete.
label.new · label.copy · label.delete · label.all · label.get_x · label.get_y · label.get_text · label.set_x · label.set_y · label.set_xy · label.set_point · label.set_xloc · label.set_yloc · label.set_text · label.set_color · label.set_textcolor · label.set_style · label.set_size · label.set_textalign · label.set_tooltip · label.set_text_font_family · label.set_text_formatting · label.style_*
line
Straight lines between two points on the chart, which a script can move, restyle, extend and delete.
line.new · line.copy · line.delete · line.all · line.get_x1 · line.get_x2 · line.get_y1 · line.get_y2 · line.get_price · line.set_x1 · line.set_x2 · line.set_y1 · line.set_y2 · line.set_xy1 · line.set_xy2 · line.set_first_point · line.set_second_point · line.set_xloc · line.set_extend · line.set_color · line.set_style · line.set_width · line.style_*
linefill
A fill between two lines, which follows them as they move.
linefill.new · linefill.get_line1 · linefill.get_line2 · linefill.set_color · linefill.delete · linefill.all
log
log.info, log.warning and log.error are accepted and write nothing.
log.info · log.warning · log.error
map
Values looked up by key, kept in the order their keys were first put.
map.new · map.put · map.put_all · map.get · map.contains · map.remove · map.size · map.clear · map.keys · map.values · map.copy
math
Rounding, powers, logarithms, trigonometry and the other number functions.
math.abs · math.acos · math.asin · math.atan · math.atan2 · math.avg · math.ceil · math.cos · math.exp · math.floor · math.hypot · math.log · math.log10 · math.max · math.min · math.pow · math.random · math.round · math.round_to_mintick · math.sign · math.sin · math.sqrt · math.sum · math.tan · math.todegrees · math.toradians · math.*
matrix
Tables of values in rows and columns, with the linear algebra to work on them, such as products, inverses, determinants and eigenvalues.
matrix.new · matrix.get · matrix.set · matrix.rows · matrix.columns · matrix.elements_count · matrix.row · matrix.col · matrix.add_row · matrix.add_col · matrix.remove_row · matrix.remove_col · matrix.swap_rows · matrix.swap_columns · matrix.fill · matrix.reverse · matrix.sort · matrix.copy · matrix.submatrix · matrix.transpose · matrix.reshape · matrix.concat · matrix.sum · matrix.diff · matrix.mult · matrix.kron · matrix.pow · matrix.det · matrix.inv · matrix.pinv · matrix.rank · matrix.trace · matrix.eigenvalues · matrix.eigenvectors · matrix.avg · matrix.min · matrix.max · matrix.median · matrix.mode · matrix.is_square · matrix.is_zero · matrix.is_binary · matrix.is_diagonal · matrix.is_antidiagonal · matrix.is_identity · matrix.is_symmetric · matrix.is_antisymmetric · matrix.is_triangular · matrix.is_stochastic
mpt
Turn a window of returns your script has collected into portfolio measures and weights.
mpt.read · mpt.score · mpt.weights · mpt.omega_weights · mpt.inverse_vol · mpt.mean · mpt.vol · mpt.cov · mpt.corr · mpt.bets · mpt.returns_of · mpt.contributions · mpt.running_mean · mpt.frontier · mpt.black_litterman · mpt.capped · mpt.status
Plots
Draw a script's values as lines, shapes, candles, levels, fills and background colours.
plot · plot.style_* · plot.linestyle_* · display.* · plotshape · shape.* · location.* · plotchar · plotarrow · plotcandle · plotbar · hline · hline.style_* · fill · bgcolor · barcolor
polyline
One drawing through many chart points, open or closed, straight or curved.
polyline.new · polyline.delete · polyline.all
report
Hand a value per member, or a whole pair matrix, to the Strategy Tester and the Screener without drawing it.
request
Read another symbol or timeframe, published facts, funding rates, and in AmenoScript a coin ranking or a whole list.
request.security · request.security_lower_tf · request.dividends · request.splits · request.earnings · request.economic · request.financial · request.funding · request.currency_rate · request.seed · request.quandl · request.footprint · request.md · request.universe · request.each · request.pairs · request.age · request.status · request.quality · barmerge.gaps_off · barmerge.gaps_on · barmerge.lookahead_off · barmerge.lookahead_on · ticker.new · ticker.modify · ticker.standard · ticker.inherit · ticker.heikinashi · ticker.kagi · ticker.linebreak · ticker.pointfigure · ticker.renko · adjustment.* · backadjustment.* · settlement_as_close.* · close.* · dividends.* · earnings.* · splits.*
runtime
Stop a script with an error message of your own.
session
The session kinds a time function takes, and the session flags, which this engine doesn't follow.
session.ismarket · session.is* · session.*
str
Text: format numbers and dates, search, split, replace and compare strings.
str.char · str.concat · str.contains · str.endswith · str.format · str.format_time · str.length · str.lower · str.match · str.pos · str.repeat · str.replace · str.replace_all · str.split · str.startswith · str.substring · str.tonumber · str.tostring · str.trim · str.trim_left · str.trim_right · str.upper
strategy
Place orders from a strategy and read its position, trades and results.
strategy.entry · strategy.order · strategy.exit · strategy.close · strategy.close_all · strategy.cancel · strategy.cancel_all · strategy.default_entry_qty · strategy.convert_to_account · strategy.convert_to_symbol · strategy.commission · strategy.risk.allow_entry_in · strategy.risk.max_cons_loss_days · strategy.risk.max_drawdown · strategy.risk.max_intraday_filled_orders · strategy.risk.max_intraday_loss · strategy.risk.max_position_size · strategy.position_size · strategy.position_avg_price · strategy.position_entry_name · strategy.equity · strategy.netprofit · strategy.openprofit · strategy.initial_capital · strategy.account_currency · strategy.closedtrades · strategy.closedtrades.first_index · strategy.opentrades · strategy.opentrades.capital_held · strategy.margin_liquidation_price · strategy.max_drawdown · strategy.max_runup · strategy.closedtrades.* · strategy.opentrades.* · strategy.oca.* · strategy.commission.* · strategy.direction.* · strategy.*
How a strategy fills
When a strategy's orders fill, at what price and size, bar by bar, as TradingView's emulator does.
When your script runs · At the open · The path inside the bar · Trailing stops · At the close · Prices on the tick · Slippage · Order sizes · Entries that face a position · Exits and closes · Commission · Margin · Risk rules · Money and the report · Where this engine differs from TradingView · See also
syminfo
The symbol a script runs on: its name, its kind, its tick and what a point is worth.
syminfo.basecurrency · syminfo.cadence · syminfo.cftc_code · syminfo.currency · syminfo.description · syminfo.isintraday · syminfo.lag · syminfo.main_tickerid · syminfo.mincontract · syminfo.minmove · syminfo.mintick · syminfo.minvolume · syminfo.period · syminfo.pointvalue · syminfo.prefix · syminfo.pricescale · syminfo.session · syminfo.ticker · syminfo.tickerid · syminfo.timezone · syminfo.type · syminfo.unit · syminfo.volumetype · syminfo.recommendations_* · syminfo.target_price_* · syminfo.*
ta
Moving averages, oscillators, bands, pivots and the other per-bar indicators.
ta.accdist · ta.alma · ta.atr · ta.barssince · ta.bb · ta.bbw · ta.beta · ta.cci · ta.change · ta.cmo · ta.cog · ta.correlation · ta.cov · ta.cross · ta.crossover · ta.crossunder · ta.cum · ta.dev · ta.dmi · ta.ema · ta.falling · ta.highest · ta.highestbars · ta.hma · ta.ichimoku · ta.iii · ta.kc · ta.kcw · ta.linreg · ta.lowest · ta.lowestbars · ta.macd · ta.max · ta.md · ta.median · ta.mfi · ta.min · ta.mode · ta.mom · ta.nvi · ta.obv · ta.percentile_linear_interpolation · ta.percentile_nearest_rank · ta.percentrank · ta.pivot_point_levels · ta.pivothigh · ta.pivotlow · ta.pvi · ta.pvt · ta.range · ta.rci · ta.rising · ta.rma · ta.roc · ta.rsi · ta.sar · ta.sma · ta.stdev · ta.stoch · ta.supertrend · ta.swma · ta.tr · ta.ts_rank · ta.tsi · ta.valuewhen · ta.variance · ta.vwap · ta.vwma · ta.wad · ta.wma · ta.wpr · ta.wvad · ta.zigzag
table
A grid of cells fixed to a corner of the pane, for values that should stay on screen.
table.new · table.cell · table.cell_set_* · table.merge_cells · table.clear · table.delete · table.all · table.set_position · table.set_bgcolor · table.set_frame_color · table.set_frame_width · table.set_border_color · table.set_border_width
timeframe
The chart's timeframe, as text and as tests, and the functions that convert and compare timeframes.
timeframe.change · timeframe.from_seconds · timeframe.in_seconds · timeframe.main_period · timeframe.multiplier · timeframe.period · timeframe.is*
volume_row
A footprint's rows: accepted, and every volume_row.* reads na or false.
volume_row.buy_volume · volume_row.sell_volume · volume_row.total_volume · volume_row.delta · volume_row.up_price · volume_row.down_price · volume_row.has_buy_imbalance · volume_row.has_sell_imbalance