Reference
Metadata
Guides and navigation are localized. Built-in reference descriptions and code examples are maintained in English.
| Name / Signature | Description | Returns |
|---|---|---|
| alerta.input.sourceinput.source(defval, title) | Creates a source selector input: the series chosen in the script's settings is the series the script reads. | series float |
| alerta.input.timeframeinput.timeframe(defval, title) | Creates a timeframe input suitable for request.security. | string |
| alerta.input.symbolinput.symbol(defval, title) | Creates a symbol input suitable for request.security. | string |
| alerta.input.timeinput.time(defval, title) | Creates a timestamp input (epoch milliseconds). | int |
| alerta.input.sessioninput.session(defval, title) | Creates a session string input (HHMM-HHMM[:days]). | string |
| alerta.input.intinput.int(defval, title, options) | Creates an integer input in the script's settings. Pine's named arguments are accepted: minval, maxval and step set the range the settings allow, options (a list of allowed values) offers only those values, and tooltip, inline and group arrange the input in the settings. The older `{ min, max, step }` object as the third argument is accepted too. | int |
| alerta.input.floatinput.float(defval, title, options) | Creates a decimal-number input in the script's settings. Pine's named arguments are accepted: minval, maxval and step set the range the settings allow, options (a list of allowed values) offers only those values, and tooltip, inline and group arrange the input in the settings. The older `{ min, max, step }` object as the third argument is accepted too. | float |
| alerta.input.boolinput.bool(defval, title) | Creates a boolean (checkbox) input parameter. | bool |
| alerta.input.stringinput.string(defval, title) | Creates a string input parameter. | string |
| alerta.input.colorinput.color(defval, title) | Creates a color picker input parameter. | color |
| alerta.input.priceinput.price(defval, title, options) | Creates a price-like numeric input parameter. | float |
| alerta.input.text_areainput.text_area(defval, title) | Creates a multiline text input parameter. | string |
| alerta.input.enuminput.enum(defval, title, options?) | Creates a dropdown input from a user-declared enum. Returns the selected enum MEMBER (not its title string), so it compares directly against EnumName.member. Member titles are what the user sees in the settings dialog. | enum member |
| alerta.timetime() or time(timeframe, session?, timezone?, bars_back?, timeframe_bars_back?) | Returns bar open timestamps (epoch milliseconds). Also usable as a bare built-in variable (no parens). The Pine v6 overload `time(timeframe, session?, timezone?, bars_back?, timeframe_bars_back?)` is accepted; when a session is supplied the value is the bar time inside the session window (in the given timezone) and `na` outside. | series int |
| alerta.time_closetime_close() or time_close(timeframe, session?, timezone?, bars_back?, timeframe_bars_back?) | Returns the bar's close time (epoch milliseconds): open + timeframe, calendar months for monthly bars, and the session close for a stock's daily bar. Also usable as a bare built-in variable. Takes the same optional arguments as `time`: with a timeframe, `time_close("D")` is the close of the higher-timeframe bar the current bar belongs to; with a session, the value is the close time inside the session window and `na` outside. | series int |
| alerta.timestamptimestamp(year, month, day, hour, minute, second) | timestamp(timezone, year, month, day, …) | timestamp(dateString) | Builds a timestamp (milliseconds since the Unix epoch). Three forms: from date/time components, read on the chart symbol's exchange clock (`syminfo.timezone` — UTC on crypto charts, New York time on a US stock); with an IANA timezone as the first argument, which reads those components in that zone instead; or from a single DATE STRING — `timestamp("2024-01-01")`, `timestamp("2024-01-01 09:30")`, `timestamp("2026-08-01T11:00:00-0500")`. A date string without its own offset is read as UTC. | int |
| alerta.hourhour(source?, timezone?) | Returns hour component from timestamp series. With a timezone arg, the hour is computed in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.minuteminute(source?, timezone?) | Returns minute component from timestamp series. With a timezone arg, the minute is computed in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.secondsecond(source?, timezone?) | Returns second component from timestamp series. With a timezone arg, the second is computed in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.dayofmonthdayofmonth(source?, timezone?) | Returns day-of-month from timestamp series. With a timezone arg, computed in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.dayofweekdayofweek(source?, timezone?) | Returns the day of week from a timestamp (1=Sunday..7=Saturday). With a timezone arg, the day-of-week is computed in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.weekofyearweekofyear(source?, timezone?) | Returns the ISO week number (weeks start on Monday) of a timestamp. With a timezone arg, the date is read in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.monthmonth(source?, timezone?) | Returns month (1..12) from timestamp series. With a timezone arg, computed in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.yearyear(source?, timezone?) | Returns year from timestamp series. With a timezone arg, computed in that timezone (Pine v6). Without one, the chart symbol's exchange clock applies (`syminfo.timezone`): UTC on crypto charts, New York time on a US stock — daylight saving included. | series int |
| alerta.timeframe.in_secondstimeframe.in_seconds(timeframe) | Returns timeframe duration in seconds. | int |
| alerta.timeframe.from_secondstimeframe.from_seconds(seconds) | Converts seconds value to canonical timeframe string. | string |
| 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 |
| librarylibrary(title, overlay, dynamic_requests) | Defines the script as a reusable library header. Pine v6 libraries are imported via `import author/libraryName/version`. The body may contain `export` function declarations that become callable from importing scripts. | void |
| indicatorindicator(title, shorttitle, overlay, format, precision, max_labels_count, max_lines_count, max_boxes_count, max_bars_back, …, scale) | Defines the script as an indicator and sets its properties. | void |
| strategystrategy(title, shorttitle, overlay, initial_capital, default_qty_value, default_qty_type, currency, pyramiding, commission_type, commission_value, slippage, process_orders_on_close, calc_on_order_fills, calc_on_every_tick, close_entries_rule, margin_long, margin_short, max_lines_count, max_labels_count, max_boxes_count, max_polylines_count, max_bars_back, risk_free_rate, use_bar_magnifier, fill_orders_on_standard_ohlc, scale) | Defines the script as a strategy and sets backtesting properties. Use as the single script header (do not combine with indicator/study headers). | void |
| 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.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 |
| enumenum Name Member1 = "title1" Member2 | Pine v6: declares an enumerated type with named members. Members can optionally carry a title (used by str.tostring and input.enum dropdowns) and behave as identity-stable runtime values. `EnumName.all()` returns an array of every member in declaration order. | enum |
| importimport publisher/library/version [as alias] | Pine v5/v6: imports a published library. `TradingView/ta` resolves to the REAL built-in ta.* surface (alias calls like ta7.rsi(...) run natively). Other libraries register a permissive stub — the script still runs, a warning is shown, and calls through the alias return na. | library |
| 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.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 |
| 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.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 |