Reference
Variables
Guides and navigation are localized. Built-in reference descriptions and code examples are maintained in English.
| Name / Signature | Description | Returns |
|---|---|---|
| alerta.ta.maxta.max → series float | Pine v6 built-in VARIABLE (no parentheses): the running all-time high — the maximum of `high` from the first bar up to the current bar. | series float |
| alerta.ta.minta.min → series float | Pine v6 built-in VARIABLE (no parentheses): the running all-time low — the minimum of `low` from the first bar up to the current bar. | series float |
| alerta.barstate.isfirstbarstate.isfirst | True only on first bar of current dataset. | series bool |
| alerta.barstate.islastbarstate.islast | True only on last bar of current dataset. | series bool |
| alerta.barstate.ishistorybarstate.ishistory | True for historical bars in current execution model. | series bool |
| alerta.barstate.isrealtimebarstate.isrealtime | True on the latest bar during live delta execution (`update_last` and `append_last`). | series bool |
| alerta.barstate.isnewbarstate.isnew | True only when a new candle is appended (`append_last`) on the latest bar. | series bool |
| alerta.barstate.isconfirmedbarstate.isconfirmed | True when bar is confirmed/closed in current execution model. | series bool |
| alerta.syminfo.tickeridsyminfo.tickerid | Exchange-qualified symbol id (e.g. BINANCE:BTCUSDT). Inside request.security it is the requested symbol's; syminfo.main_tickerid stays the chart's. Pine v1–v3 scripts write it as `tickerid`. | string |
| alerta.syminfo.tickersyminfo.ticker | Ticker part of current symbol (e.g. BTCUSDT). Pine v1–v3 scripts write it as `ticker`. | string |
| alerta.syminfo.prefixsyminfo.prefix | Exchange prefix of current symbol (e.g. BINANCE). | string |
| alerta.syminfo.minticksyminfo.mintick | Minimum price increment for the current symbol — the precision the chart's own price axis uses (a magnitude estimate from the last price when the script runs outside the chart). format.mintick and math.round_to_mintick use it. | float |
| alerta.timeframe.periodtimeframe.period | Canonical chart timeframe identifier (e.g. 60, D, W, M). Inside request.security it is the requested timeframe; timeframe.main_period stays the chart's. Pine v1–v3 scripts write it as `period`. | string |
| alerta.timeframe.isintradaytimeframe.isintraday | True when timeframe is minute/hour based. Pine v1–v3 scripts write it (and isdaily, isweekly, ismonthly, isdwm) without the timeframe. prefix. | bool |
| alerta.timeframe.isdailytimeframe.isdaily | True when timeframe period is D. | bool |
| alerta.timeframe.isweeklytimeframe.isweekly | True when timeframe period is W. | bool |
| alerta.timeframe.ismonthlytimeframe.ismonthly | True when timeframe period is M. | bool |
| alerta.ta.pvtta.pvt → series float | Pine built-in VARIABLE (no parentheses): cumulative sum of the close %-change weighted by volume — cum(change(close)/close[1] * volume). Rises when price gains on volume, falls when price drops on volume. | series float |
| alerta.ta.accdistta.accdist → series float | Pine built-in VARIABLE (no parentheses): cumulative Accumulation/Distribution line — cum(((close-low)-(high-close))/(high-low) * volume). Measures buying vs. selling pressure via the close position inside the bar range. | series float |
| alerta.ta.iiita.iii → series float | Pine built-in VARIABLE (no parentheses): (2*close - high - low) / ((high - low) * volume). Gauges where the close sits in the bar range, normalized by volume. | series float |
| alerta.ta.nvita.nvi → series float | Pine built-in VARIABLE (no parentheses): starts at 1.0 and compounds the close %-change ONLY on bars where volume fell versus the prior bar. Tracks what "smart money" does on quiet days. | series float |
| alerta.ta.pvita.pvi → series float | Pine built-in VARIABLE (no parentheses): starts at 1.0 and compounds the close %-change ONLY on bars where volume rose versus the prior bar. Mirror of ta.nvi for high-activity days. | series float |
| alerta.ta.wadta.wad → series float | Pine built-in VARIABLE (no parentheses): cumulative sum of close - min(low, close[1]) on up-closes and close - max(high, close[1]) on down-closes (0 when unchanged). Larry Williams’ accumulation/distribution measure. | series float |
| alerta.strategy.equitystrategy.equity | Returns the current equity (initial capital + realized profit + open profit) for the strategy at the current bar. | series float |
| alerta.strategy.netprofit_percentstrategy.netprofit_percent | Realized net profit expressed as a percentage of the initial capital. Companion percent variants also available: strategy.openprofit_percent, strategy.grossprofit_percent, strategy.grossloss_percent, strategy.max_drawdown_percent, strategy.max_runup_percent. | series float |
| alerta.strategy.avg_tradestrategy.avg_trade | Average profit/loss per closed trade. Companions: strategy.avg_trade_percent (per-trade % of entry notional), strategy.avg_winning_trade(_percent), strategy.avg_losing_trade(_percent). | series float |
| alerta.strategy.margin_liquidation_pricestrategy.margin_liquidation_price | Price at which a margin call would liquidate the position. AlertaScript does not simulate leverage/margin, so this returns na — matching Pine's value when margin requirements are 100%. | series float (na) |
| alerta.strategy.position_sizestrategy.position_size | Returns the size of the current open position. Positive for long positions, negative for short positions, and 0 if neutral. | series float |
| alerta.strategy.openprofitstrategy.openprofit | Returns the unrealized profit/loss of the currently open positions. | series float |
| alerta.strategy.opentradesstrategy.opentrades | Returns the number of currently open trades in the strategy. | int |
| alerta.strategy.closedtradesstrategy.closedtrades | Returns the total number of closed trades in the strategy performance history. | int |
| alerta.strategy.initial_capitalstrategy.initial_capital | Returns the starting capital defined in the strategy() declaration. | float |
| alerta.strategy.grossprofitstrategy.grossprofit | Returns the total profit from all winning closed trades. | float |
| alerta.strategy.grosslossstrategy.grossloss | Returns the total loss (as a positive number) from all losing closed trades. | float |
| alerta.strategy.wintradesstrategy.wintrades | Returns the number of closed trades that ended with a profit. | int |
| alerta.strategy.losstradesstrategy.losstrades | Returns the number of closed trades that ended with a loss. | int |
| alerta.strategy.eventradesstrategy.eventrades | Returns the number of closed trades that ended at breakeven (no profit, no loss). | int |
| alerta.strategy.max_drawdownstrategy.max_drawdown | Returns the maximum equity drawdown of the backtest, intrabar as in the Strategy Tester: the highest closed-trade equity so far minus the equity at a bar's adverse extreme (the low of a long, the high of a short). | float |
| alerta.strategy.max_runupstrategy.max_runup | Returns the maximum equity run-up of the backtest, intrabar: the equity at a bar's favourable extreme minus the lowest closed-trade equity so far. | float |
| alerta.strategy.account_currencystrategy.account_currency | Returns the account currency of strategy equity and P&L: the strategy() currency, or the symbol's own currency when it is currency.NONE (the default) — e.g. "USDT" on BTCUSDT. | string |
| alerta.polyline.allpolyline.all → array<polyline> | Pine v6: read-only array containing every active polyline handle. | array<polyline> |
| alerta.line.allline.all → array<line> | An array of every line the script has drawn and not deleted, oldest first. It is a new array on every read, so deleting lines while walking it — `for l in line.all` then `line.delete(l)`, or `array.get(line.all, i)` in a counted loop — deletes them all. | array<line> |
| alerta.label.alllabel.all → array<label> | Pine v6: read-only array of every active label handle. | array<label> |
| alerta.box.allbox.all → array<box> | Pine v6: read-only array of every active box handle. | array<box> |
| alerta.table.alltable.all → array<table> | Pine v6: read-only array of every active table handle. | array<table> |
| alerta.syminfo.currencysyminfo.currency | Returns the quote currency of the current symbol (e.g. "USDT", "USD", "BTC"). | string |
| alerta.syminfo.basecurrencysyminfo.basecurrency | Returns the base asset of the current symbol (e.g. "BTC" from "BTCUSDT"). | string |
| alerta.syminfo.timezonesyminfo.timezone | Returns the timezone of the current symbol's exchange: "UTC" for crypto, "America/New_York" for US stocks, forex and US indices, "Europe/Istanbul" for Borsa Istanbul. It is also the default clock of hour(), dayofweek(), timestamp() and time() with a session. | string |
| alerta.syminfo.typesyminfo.type | Returns the asset type of the current symbol: "crypto", "stock", "forex", "index", "futures" or "economic" (FRED/macro series). | string |
| alerta.syminfo.descriptionsyminfo.description | Returns a human-readable description or full name of the current symbol — the company name on a stock chart ("Apple Inc."), the ticker otherwise. | string |
| alerta.syminfo.sessionsyminfo.session | Returns the trading session string for the current symbol (e.g. "24x7" for crypto, "0930-1600" for NYSE). | string |
| alerta.syminfo.pointvaluesyminfo.pointvalue | Returns the monetary value of one price point move for the symbol (e.g. 1 for most crypto, 50 for ES futures). | float |
| alerta.syminfo.volumetypesyminfo.volumetype | Returns the type of volume reported by the symbol (e.g. "base" for base asset volume, "quote" for quote asset volume). | string |
| alerta.syminfo.countrysyminfo.country | Two-letter ISO country of the symbol's listing ("US", "TR", "DE") on stock and index charts; an empty string for crypto, forex and macro series. | string |
| alerta.syminfo.sectorsyminfo.sector | The company's sector on a stock chart (e.g. "Electronic Technology"), from the same company profile the symbol panel shows. An empty string for anything that is not a stock, or when the profile has none. | string |
| alerta.syminfo.industrysyminfo.industry | The company's industry on a stock chart (e.g. "Telecommunications Equipment"). An empty string for anything that is not a stock, or when the profile has none. | string |
| alerta.syminfo.shares_outstanding_totalsyminfo.shares_outstanding_total | Total shares outstanding of the company on a stock chart — the latest figure, not a history. na for anything that is not a stock, or when the company profile has none. Multiply by close for an approximate market capitalisation. | float |
| alerta.syminfo.shares_outstanding_floatsyminfo.shares_outstanding_float | Free-float shares of the company. The company profile AlertaChart carries has no float figure, so this is always na — guard it with na(). | float |
| alerta.syminfo.employeessyminfo.employees | Number of employees of the company. Not in the company profile AlertaChart carries, so always na — guard it with na(). | int |
| alerta.syminfo.shareholderssyminfo.shareholders | Number of shareholders of the company. Not in the company profile AlertaChart carries, so always na — guard it with na(). | int |
| alerta.timeframe.multipliertimeframe.multiplier | Returns the numeric multiplier of the current timeframe: 15 on "15", 240 on a 4-hour chart ("240"), 1 on "D", 5 on "5D", 12 on "12M". Pine v1–v3 scripts write it as `interval`. | int |
| alerta.timeframe.isminutestimeframe.isminutes | Returns true if the current chart timeframe is measured in minutes (e.g. 1m, 5m, 15m, 60m). | bool |
| alerta.timeframe.issecondstimeframe.isseconds | Returns true if the current chart timeframe is measured in seconds (e.g. 1S, 5S, 30S). | bool |
| alerta.timeframe.isdwmtimeframe.isdwm | Returns true if the current chart timeframe is daily (D), weekly (W), or monthly (M). | bool |
| alerta.session.ismarketsession.ismarket → series<bool> | Pine v5/v6 series<bool>: true on every bar that opens inside the exchange's regular trading hours, read on the exchange's own clock (so daylight saving moves the window with it — 09:30–16:00 New York time for a US stock). Weekends are closed; exchange holidays are not modelled. A daily or longer bar is always in market, and so is every bar of a symbol that trades around the clock (crypto, forex, indices, futures). | series<bool> |
| alerta.session.ispremarketsession.ispremarket → series<bool> | Pine v5/v6 series<bool>: true on bars that open inside the exchange's pre-market window (04:00–09:30 New York time for a US stock). Always false for symbols without extended hours. | series<bool> |
| alerta.session.ispostmarketsession.ispostmarket → series<bool> | Pine v5/v6 series<bool>: true on bars that open inside the exchange's after-hours window (16:00–20:00 New York time for a US stock). Always false for symbols without extended hours. | series<bool> |
| alerta.session.isfirstbarsession.isfirstbar → series<bool> | Pine v5/v6 series<bool>: true on the first bar of each day's session (the exchange day time("D") uses; a forex session opens 17:00 New York), pre-market bars included; inside request.security, of the requested bars. session.isfirstbar_regular is the first regular-hours bar. | series<bool> |
| alerta.session.islastbarsession.islastbar → series<bool> | Pine v5/v6 series<bool>: true on the last bar of each day's session, post-market bars included; on the chart's last bar when the next bar would open a new day; inside request.security, of the requested bars. session.islastbar_regular is the last regular-hours bar. | series<bool> |
| alerta.chart.fg_colorchart.fg_color → color | Pine v6: the chart's foreground (text/axes) color. Use to keep custom drawings legible across light/dark themes. | color |
| alerta.chart.bg_colorchart.bg_color → color | Pine v6: the chart's background color. | color |
| alerta.chart.is_standardchart.is_standard → bool | Pine v6: true when the chart uses standard candles (not Heikin-Ashi/Renko/Range/etc.). | bool |
| alerta.chart.left_visible_bar_timechart.left_visible_bar_time → int | Pine v6: timestamp of the left-most visible bar. The script runs before the chart has a viewport, so every loaded bar counts as visible: the first loaded bar's time. | int |
| alerta.chart.right_visible_bar_timechart.right_visible_bar_time → int | Pine v6: timestamp of the right-most visible bar: the last loaded bar's time (every loaded bar counts as visible). | int |
| alerta.strategy.position_entry_namestrategy.position_entry_name → string | Pine v6: ID of the most recent open entry order. | string |
| alerta.strategy.position_size_maxstrategy.position_size_max → float | Pine v6: largest absolute position size held across the backtest. | float |
| alerta.strategy.max_contracts_held_allstrategy.max_contracts_held_all → float | Pine v6: largest absolute contract count held across the backtest (alias of position_size_max). | float |
| alerta.strategy.max_contracts_held_longstrategy.max_contracts_held_long → float | Pine v6: largest long-side contract count held. | float |
| alerta.strategy.max_contracts_held_shortstrategy.max_contracts_held_short → float | Pine v6: largest short-side contract count held. | float |
| hlcc4hlcc4 → series float | Pine v6: shortcut for `(high + low + close + close) / 4`. Close is counted twice, giving more weight to the close price. | series float |
| askask → series float | Pine v6: lowest price an active seller will accept for the instrument. Only available on the "1T" timeframe. On AlertaChart it is always `na`, tick charts included: scripts do not receive the order book's best prices. | series float |
| bidbid → series float | Pine v6: highest price an active buyer is willing to pay. Only available on the "1T" timeframe. On AlertaChart it is always `na`, tick charts included: scripts do not receive the order book's best prices. | series float |
| last_bar_timelast_bar_time → series int | Pine v6: UNIX time (ms) of the last chart bar. For closed markets this is the final historical bar; for open markets it is the realtime bar. | series int |
| time_tradingdaytime_tradingday → series int | Pine v6: UNIX timestamp of 00:00 UTC of the trading day the current bar belongs to. Useful for overnight sessions where the bar may open on the previous calendar day. | series int |
| timenowtimenow → series int | Pine v6: the current time in UNIX milliseconds at the moment the script runs. It does not follow the bars: every bar of one run reads the same value, and the next run reads a later one. | series int |
| constconst <type> <name> = <value> | Pine v6 qualifier: a value determined at compile time that never changes during execution. Hierarchy: const < input < simple < series. | qualifier |
| simplesimple <type> <name> = <value> | Pine v6 qualifier: a value resolved at the start of execution and unchanged afterward. Required for some library function parameters (e.g. `ta.ema(src, simple int length)`). | qualifier |
| seriesseries <type> <name> = <value> | Pine v6 qualifier: a value that may change per bar. This is the default qualifier for most expressions and library function parameters. | qualifier |
| alerta.syminfo.main_tickeridsyminfo.main_tickerid → simple string | Pine v6: the CHART's ticker id — unlike syminfo.tickerid, this stays the chart symbol even inside a request.security() context. | simple string |
| alerta.timeframe.main_periodtimeframe.main_period → simple string | Pine v6: the CHART's timeframe period — unlike timeframe.period, this stays the chart timeframe even inside a request.security() context. timeframe.isticks is also available (always false — tick charts are not supported). | simple string |
| alerta.barstate.islastconfirmedhistorybarstate.islastconfirmedhistory → series bool | Identifies the final confirmed historical bar in the current execution dataset, before the current realtime bar when one exists. | series bool |
| alerta.syminfo.rootsyminfo.root → string | Returns the root identifier derived from the current symbol and instrument type. It is useful for displaying a contract family separately from its exchange-qualified ticker. | string |
| alerta.strategy.position_avg_pricestrategy.position_avg_price → series float | Average entry price of the currently open simulated strategy position. The value follows fills in the strategy simulator. While the strategy has no position it is na, as in Pine. | series float |
| alerta.strategy.netprofitstrategy.netprofit → series float | Cumulative realized profit and loss from closed simulated strategy trades. It does not include the unrealized profit of the currently open position. | series float |
| openopen → series float | Opening price of each chart bar. | series float |
| highhigh → series float | Highest traded price in each chart bar. | series float |
| lowlow → series float | Lowest traded price in each chart bar. | series float |
| closeclose → series float | Closing price of each historical bar, or the latest price of the current bar. | series float |
| volumevolume → series float | Volume supplied by the chart data provider for each bar; units and availability depend on the instrument. | series float |
| hl2hl2 → series float | Average of the high and low of each bar: (high + low) / 2. | series float |
| hlc3hlc3 → series float | Average of the high, low and close of each bar: (high + low + close) / 3. | series float |
| ohlc4ohlc4 → series float | Average of each bar’s open, high, low and close. | series float |
| last_bar_indexlast_bar_index → int | Zero-based index of the final bar in the current dataset. Changes when a new chart bar is appended. | int |
| alerta.syminfo.pricescalesyminfo.pricescale → int | Price-scale denominator from the symbol metadata. Together with syminfo.minmove it determines the minimum price increment. | int |
| bar_indexbar_index → series int | Zero-based position of the current bar within the chart dataset. Historical access such as bar_index[1] refers to the preceding bar. | series int |
| alerta.session.isfirstbar_regularsession.isfirstbar_regular → series bool | True on the first regular-hours bar of each day's session — on a stock, the first bar after the pre-market. On a symbol that trades around the clock it is the same bar as session.isfirstbar. Inside request.security, of the requested bars. | series bool |
| alerta.session.islastbar_regularsession.islastbar_regular → series bool | True on the last regular-hours bar of each day's session — on a stock, the last bar before the post-market. On a symbol that trades around the clock it is the same bar as session.islastbar. Inside request.security, of the requested bars. | series bool |
| alerta.syminfo.minmovesyminfo.minmove → int | The numerator of the symbol's price step: syminfo.minmove / syminfo.pricescale is syminfo.mintick. | int |
| alerta.chart.is_heikinashichart.is_heikinashi → simple bool | True on a Heikin Ashi chart in Pine. On AlertaChart it is always false: a Heikin Ashi chart draws its candles from the standard bars, and scripts always run on the standard bars. | simple bool |
| alerta.chart.is_renkochart.is_renko → simple bool | True on a Renko chart in Pine. On AlertaChart it is always false; chart.is_standard is true. | simple bool |
| alerta.chart.is_kagichart.is_kagi → simple bool | True on a Kagi chart in Pine. On AlertaChart it is always false; chart.is_standard is true. | simple bool |
| alerta.chart.is_linebreakchart.is_linebreak → simple bool | True on a Line Break chart in Pine. On AlertaChart it is always false; chart.is_standard is true. | simple bool |
| alerta.chart.is_pnfchart.is_pnf → simple bool | True on a Point & Figure chart in Pine. On AlertaChart it is always false; chart.is_standard is true. | simple bool |
| alerta.chart.is_rangechart.is_range → simple bool | True on a Range chart in Pine. On AlertaChart it is always false; chart.is_standard is true. | simple bool |
| alerta.linefill.alllinefill.all → array<linefill> | An array of every linefill the script has made and not deleted, oldest first. | array<linefill> |
| alerta.strategy.closedtrades.first_indexstrategy.closedtrades.first_index → int | The trade number of the oldest closed trade the strategy keeps. No closed trade is ever dropped from the list here, so it is always 0. | int |