1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
4,350 lines of Pine Script v5 from PineScriptv5guide.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.
PineScriptv5guide.txt
//@version=5
indicator("bar_index")
plot(bar_index)
plot(bar_index > 5000 ? close : 0)
REMARKS::
- Replaced 'n' variable in version 4.
- Indexing starts from 0 on the first historical bar.
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: last_bar_index, barstate.isfirst, barstate.islast, barstate.isrealtime, barstate.isconfirmed
---
# --- Entry: barstate.isconfirmed ---
NAME:: barstate.isconfirmed
TYPE:: series bool
DESCRIPTION:: Returns true if the script is calculating the last (closing) update of the current bar. The next script calculation will be on the new bar data.
REMARKS::
- Code using this variable could calculate differently on history and real-time data.
- NOT recommended in request.security expression (unpredictable value).
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: barstate.isfirst, barstate.islast, barstate.ishistory, barstate.isrealtime, barstate.isnew, barstate.islastconfirmedhistory
---
# --- Entry: barstate.isfirst ---
NAME:: barstate.isfirst
TYPE:: series bool
DESCRIPTION:: Returns true if current bar is first bar in barset, false otherwise.
REMARKS::
- Code using this variable could calculate differently on history and real-time data.
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: barstate.islast, barstate.ishistory, barstate.isrealtime, barstate.isnew, barstate.isconfirmed, barstate.islastconfirmedhistory
---
# --- Entry: barstate.ishistory ---
NAME:: barstate.ishistory
TYPE:: series bool
DESCRIPTION:: Returns true if current bar is a historical bar, false otherwise.
REMARKS::
- Code using this variable could calculate differently on history and real-time data.
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: barstate.isfirst, barstate.islast, barstate.isrealtime, barstate.isnew, barstate.isconfirmed, barstate.islastconfirmedhistory
---
# --- Entry: barstate.islast ---
NAME:: barstate.islast
TYPE:: series bool
DESCRIPTION:: Returns true if current bar is the last bar in barset, false otherwise. This condition is true for all real-time bars in barset.
REMARKS::
- Code using this variable could calculate differently on history and real-time data.
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: barstate.isfirst, barstate.ishistory, barstate.isrealtime, barstate.isnew, barstate.isconfirmed, barstate.islastconfirmedhistory
---
# --- Entry: barstate.islastconfirmedhistory ---
NAME:: barstate.islastconfirmedhistory
TYPE:: series bool
DESCRIPTION:: Returns true if script is executing on the dataset's last bar when market is closed, or script is executing on the bar immediately preceding the real-time bar, if market is open. Returns false otherwise.
REMARKS::
- Code using this variable could calculate differently on history and real-time data.
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: barstate.isfirst, barstate.islast, barstate.ishistory, barstate.isrealtime, barstate.isnew
---
# --- Entry: barstate.isnew ---
NAME:: barstate.isnew
TYPE:: series bool
DESCRIPTION:: Returns true if script is currently calculating on new bar, false otherwise. This variable is true when calculating on historical bars or on first update of a newly generated real-time bar.
REMARKS::
- Code using this variable could calculate differently on history and real-time data.
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: barstate.isfirst, barstate.islast, barstate.ishistory, barstate.isrealtime, barstate.isconfirmed, barstate.islastconfirmedhistory
---
# --- Entry: barstate.isrealtime ---
NAME:: barstate.isrealtime
TYPE:: series bool
DESCRIPTION:: Returns true if current bar is a real-time bar, false otherwise.
REMARKS::
- Code using this variable could calculate differently on history and real-time data.
- WARNING: Using this variable/function can cause indicator repainting.
SEE_ALSO:: barstate.isfirst, barstate.islast, barstate.ishistory, barstate.isnew, barstate.isconfirmed, barstate.islastconfirmedhistory
---
# --- Entry: box.all ---
NAME:: box.all
TYPE:: array<box>
DESCRIPTION:: Returns an array filled with all the current boxes drawn by the script.
EXAMPLE::
//@version=5
indicator("box.all")
//delete all boxes
box.new(time, open, time + 60 * 60 * 24, close, xloc=xloc.bar_time, border_style=line.style_dashed)
a_allBoxes = box.all
if array.size(a_allBoxes) > 0
for i = 0 to array.size(a_allBoxes) - 1
box.delete(array.get(a_allBoxes, i))
REMARKS::
- The array is read-only.
- Index zero is the ID of the oldest object on the chart.
SEE_ALSO:: box.new, line.all, label.all, table.all
---
# --- Entry: chart.bg_color ---
NAME:: chart.bg_color
TYPE:: input color
DESCRIPTION:: Returns the color of the chart's background from the "Chart settings/Appearance/Background" field. When a gradient is selected, the middle point of the gradient is returned.
SEE_ALSO:: chart.fg_color
---
# --- Entry: chart.fg_color ---
NAME:: chart.fg_color
TYPE:: input color
DESCRIPTION:: Returns a color providing optimal contrast with chart.bg_color.
SEE_ALSO:: chart.bg_color
---
# --- Entry: chart.is_heikinashi ---
NAME:: chart.is_heikinashi
TYPE:: simple bool
DESCRIPTION:: Returns true if the chart type is Heikin Ashi, false otherwise.
SEE_ALSO:: chart.is_renko, chart.is_linebreak, chart.is_kagi, chart.is_pnf, chart.is_range
---
# --- Entry: chart.is_kagi ---
NAME:: chart.is_kagi
TYPE:: simple bool
DESCRIPTION:: Returns true if the chart type is Kagi, false otherwise.
SEE_ALSO:: chart.is_renko, chart.is_linebreak, chart.is_heikinashi, chart.is_pnf, chart.is_range
---
# --- Entry: chart.is_linebreak ---
NAME:: chart.is_linebreak
TYPE:: simple bool
DESCRIPTION:: Returns true if the chart type is Line break, false otherwise.
SEE_ALSO:: chart.is_renko, chart.is_heikinashi, chart.is_kagi, chart.is_pnf, chart.is_range
---
# --- Entry: chart.is_pnf ---
NAME:: chart.is_pnf
TYPE:: simple bool
DESCRIPTION:: Returns true if the chart type is Point & figure, false otherwise.
SEE_ALSO:: chart.is_renko, chart.is_linebreak, chart.is_kagi, chart.is_heikinashi, chart.is_range
---
# --- Entry: chart.is_range ---
NAME:: chart.is_range
TYPE:: simple bool
DESCRIPTION:: Returns true if the chart type is Range, false otherwise.
SEE_ALSO:: chart.is_renko, chart.is_linebreak, chart.is_kagi, chart.is_pnf, chart.is_heikinashi
---
# --- Entry: chart.is_renko ---
NAME:: chart.is_renko
TYPE:: simple bool
DESCRIPTION:: Returns true if the chart type is Renko, false otherwise.
SEE_ALSO:: chart.is_heikinashi, chart.is_linebreak, chart.is_kagi, chart.is_pnf, chart.is_range
---
# --- Entry: chart.is_standard ---
NAME:: chart.is_standard
TYPE:: simple bool
DESCRIPTION:: Returns true if the chart type is bars, candles, hollow candles, line, area or baseline, false otherwise.
SEE_ALSO:: chart.is_renko, chart.is_linebreak, chart.is_kagi, chart.is_pnf, chart.is_range, chart.is_heikinashi
---
# --- Entry: chart.left_visible_bar_time ---
NAME:: chart.left_visible_bar_time
TYPE:: input int
DESCRIPTION:: The time of the leftmost bar currently visible on the chart.
REMARKS::
- Scripts using this variable will automatically re-execute when its value updates (e.g., user scrolling, new real-time bars).
- Alerts created with this variable will only use the value at the moment of creation, which may lead to repainting.
SEE_ALSO:: chart.right_visible_bar_time
---
# --- Entry: chart.right_visible_bar_time ---
NAME:: chart.right_visible_bar_time
TYPE:: input int
DESCRIPTION:: The time of the rightmost bar currently visible on the chart.
REMARKS::
- Scripts using this variable will automatically re-execute when its value updates (e.g., user scrolling, new real-time bars).
- Alerts created with this variable will only use the value at the moment of creation, which may lead to repainting.
SEE_ALSO:: chart.left_visible_bar_time
---
# --- Entry: close ---
NAME:: close
TYPE:: series float
DESCRIPTION:: Close price of the current bar when it has closed, or last traded price of a yet incomplete, realtime bar.
REMARKS:: Previous values may be accessed with square brackets operator [], e.g. close[1], close[2].
SEE_ALSO:: open, high, low, volume, time, hl2, hlc3, hlcc4, ohlc4
---
# --- Entry: dayofmonth ---
NAME:: dayofmonth
TYPE:: series int
DESCRIPTION:: Date of current bar time in exchange timezone.
REMARKS:: Note that this variable returns the day based on the time of the bar's open. For overnight sessions, this value can be lower by 1 than the day of the trading day.
SEE_ALSO:: time, year, month, weekofyear, dayofweek, hour, minute, second
---
# --- Entry: dayofweek ---
NAME:: dayofweek
TYPE:: series int
DESCRIPTION:: Day of week for current bar time in exchange timezone.
REMARKS::
- Note that this variable returns the day based on the time of the bar's open. For overnight sessions, this value can be lower by 1 than the day of the trading day.
- Can be compared using dayofweek.sunday, dayofweek.monday, etc.
SEE_ALSO:: time, year, month, weekofyear, dayofmonth, hour, minute, second
---
# --- Entry: dividends.future_amount ---
NAME:: dividends.future_amount
TYPE:: series float
DESCRIPTION:: Returns the payment amount of the upcoming dividend in the currency of the current instrument, or na if this data isn't available.
REMARKS:: Value is only fetched once during the script's initial calculation and will return the same value until the script is recalculated.
---
# --- Entry: dividends.future_ex_date ---
NAME:: dividends.future_ex_date
TYPE:: series int
RETURNS:: UNIX time, expressed in milliseconds.
DESCRIPTION:: Returns the Ex-dividend date (Ex-date) of the current instrument's next dividend payment, or na if this data isn't available.
REMARKS:: Value is only fetched once during the script's initial calculation and will return the same value until the script is recalculated.
---
# --- Entry: dividends.future_pay_date ---
NAME:: dividends.future_pay_date
TYPE:: series int
RETURNS:: UNIX time, expressed in milliseconds.
DESCRIPTION:: Returns the Payment date (Pay date) of the current instrument's next dividend payment, or na if this data isn't available.
REMARKS:: Value is only fetched once during the script's initial calculation and will return the same value until the script is recalculated.
---
# --- Entry: earnings.future_eps ---
NAME:: earnings.future_eps
TYPE:: series float
DESCRIPTION:: Returns the estimated Earnings per Share of the next earnings report in the currency of the instrument, or na if this data isn't available.
REMARKS:: Value is only fetched once during the script's initial calculation and will return the same value until the script is recalculated.
SEE_ALSO:: request.earnings
---
# --- Entry: earnings.future_period_end_time ---
NAME:: earnings.future_period_end_time
TYPE:: series int
RETURNS:: UNIX time, expressed in milliseconds.
DESCRIPTION:: Returns the UNIX timestamp of the day when the financial period covered by the next earnings report ends, or na if this data isn't available.
REMARKS:: Value is only fetched once during the script's initial calculation and will return the same value until the script is recalculated.
SEE_ALSO:: request.earnings
---
# --- Entry: earnings.future_revenue ---
NAME:: earnings.future_revenue
TYPE:: series float
DESCRIPTION:: Returns the estimated Revenue of the next earnings report in the currency of the instrument, or na if this data isn't available.
REMARKS:: Value is only fetched once during the script's initial calculation and will return the same value until the script is recalculated.
SEE_ALSO:: request.earnings
---
# --- Entry: earnings.future_time ---
NAME:: earnings.future_time
TYPE:: series int
RETURNS:: UNIX time, expressed in milliseconds.
DESCRIPTION:: Returns a UNIX timestamp indicating the expected time of the next earnings report, or na if this data isn't available.
REMARKS:: Value is only fetched once during the script's initial calculation and will return the same value until the script is recalculated.
SEE_ALSO:: request.earnings
---
# --- Entry: high ---
NAME:: high
TYPE:: series float
DESCRIPTION:: Current high price.
REMARKS:: Previous values may be accessed with square brackets operator [], e.g. high[1], high[2].
SEE_ALSO:: open, low, close, volume, time, hl2, hlc3, hlcc4, ohlc4
---
# --- Entry: hl2 ---
NAME:: hl2
TYPE:: series float
DESCRIPTION:: Is a shortcut for (high + low)/2
SEE_ALSO:: open, high, low, close, volume, time, hlc3, hlcc4, ohlc4
---
# --- Entry: hlc3 ---
NAME:: hlc3
TYPE:: series float
DESCRIPTION:: Is a shortcut for (high + low + close)/3
SEE_ALSO:: open, high, low, close, volume, time, hl2, hlcc4, ohlc4
---
# --- Entry: hlcc4 ---
NAME:: hlcc4
TYPE:: series float
DESCRIPTION:: Is a shortcut for (high + low + close + close)/4
SEE_ALSO:: open, high, low, close, volume, time, hl2, hlc3, ohlc4
---
# --- Entry: hour ---
NAME:: hour
TYPE:: series int
DESCRIPTION:: Current bar hour in exchange timezone.
SEE_ALSO:: time, year, month, weekofyear, dayofmonth, dayofweek, minute, second
---
# --- Entry: label.all ---
NAME:: label.all
TYPE:: array<label>
DESCRIPTION:: Returns an array filled with all the current labels drawn by the script.
EXAMPLE::
//@version=5
indicator("label.all")
//delete all labels
label.new(bar_index, close)
a_allLabels = label.all
if array.size(a_allLabels) > 0
for i = 0 to array.size(a_allLabels) - 1
label.delete(array.get(a_allLabels, i))
REMARKS::
- The array is read-only.
- Index zero of the array is the ID of the oldest object on the chart.
SEE_ALSO:: label.new, line.all, box.all, table.all
---
# --- Entry: last_bar_index ---
NAME:: last_bar_index
TYPE:: series int
DESCRIPTION:: Bar index of the last chart bar. Bar indices begin at zero on the first bar.
RETURNS:: Last historical bar index for closed markets, or the real-time bar index for open markets.
EXAMPLE::
//@version=5
strategy("Mark Last X Bars For Backtesting", overlay = true, calc_on_every_tick = true)
lastBarsFilterInput = input.int(100, "Bars Count:")
// Use 'var' to store the initial 'last_bar_index' value.
var lastbar = last_bar_index
// Check if the current bar_index is within the last 'lastBarsFilterInput' bars, or if in real-time.
allowedToTrade = (lastbar - bar_index <= lastBarsFilterInput) or barstate.isrealtime
bgcolor(allowedToTrade ? color.new(color.green, 80) : na)
REMARKS:: WARNING: Using this variable can cause indicator repainting.
SEE_ALSO:: bar_index, last_bar_time, barstate.ishistory, barstate.isrealtime
---
# --- Entry: last_bar_time ---
NAME:: last_bar_time
TYPE:: series int
DESCRIPTION:: Time in UNIX format (milliseconds) of the last chart bar.
REMARKS::
- WARNING: Using this variable/function can cause indicator repainting.
- Returns the timestamp based on the time of the bar's open.
SEE_ALSO:: time, timenow, timestamp, last_bar_index
---
# --- Entry: line.all ---
NAME:: line.all
TYPE:: array<line>
DESCRIPTION:: Returns an array filled with all the current lines drawn by the script.
EXAMPLE::
//@version=5
indicator("line.all")
//delete all lines
line.new(bar_index - 10, close, bar_index, close)
a_allLines = line.all
if array.size(a_allLines) > 0
for i = 0 to array.size(a_allLines) - 1
line.delete(array.get(a_allLines, i))
REMARKS::
- The array is read-only.
- Index zero of the array is the ID of the oldest object on the chart.
SEE_ALSO:: line.new, label.all, box.all, table.all
---
# --- Entry: linefill.all ---
NAME:: linefill.all
TYPE:: array<linefill>
DESCRIPTION:: Returns an array filled with all the current linefill objects drawn by the script.
REMARKS::
- The array is read-only.
- Index zero of the array is the ID of the oldest object on the chart.
---
# --- Entry: low ---
NAME:: low
TYPE:: series float
DESCRIPTION:: Current low price.
REMARKS:: Previous values may be accessed with square brackets operator [], e.g. low[1], low[2].
SEE_ALSO:: open, high, close, volume, time, hl2, hlc3, hlcc4, ohlc4
---
# --- Entry: minute ---
NAME:: minute
TYPE:: series int
DESCRIPTION:: Current bar minute in exchange timezone.
SEE_ALSO:: time, year, month, weekofyear, dayofmonth, dayofweek, hour, second
---
# --- Entry: month ---
NAME:: month
TYPE:: series int
DESCRIPTION:: Current bar month in exchange timezone.
REMARKS:: Note that this variable returns the month based on the time of the bar's open. For overnight sessions, this value can be lower by 1 than the month of the trading day.
SEE_ALSO:: time, year, weekofyear, dayofmonth, dayofweek, hour, minute, second
---
# --- Entry: na ---
NAME:: na
TYPE:: simple na
DESCRIPTION:: A keyword signifying "not available", indicating that a variable has no assigned value.
EXAMPLE::
//@version=5
indicator("na")
// CORRECT: Plot no value when on bars zero to nine. Plot `close` on other bars.
plot(bar_index < 10 ? na : close)
// CORRECT: Use the `na()` function to test for `na`.
plot(na(close[1]) ? close : close[1])
REMARKS::
- Do not use comparison operators (==) to test values for na. Use the **na()** function instead.
- Can be used to initialize variables when the type is also specified (e.g., 'float a = na').
SEE_ALSO:: na, nz, fixnan
---
# --- Entry: ohlc4 ---
NAME:: ohlc4
TYPE:: series float
DESCRIPTION:: Is a shortcut for (open + high + low + close)/4
SEE_ALSO:: open, high, low, close, volume, time, hl2, hlc3, hlcc4
---
# --- Entry: open ---
NAME:: open
TYPE:: series float
DESCRIPTION:: Current open price.
REMARKS:: Previous values may be accessed with square brackets operator [], e.g. open[1], open[2].
SEE_ALSO:: high, low, close, volume, time, hl2, hlc3, hlcc4, ohlc4
---
# --- Entry: polyline.all ---
NAME:: polyline.all
TYPE:: array<polyline>
DESCRIPTION:: Returns an array containing all current polyline instances drawn by the script.
REMARKS::
- The array is read-only.
- Index zero of the array references the ID of the oldest polyline object on the chart.
---
# --- Entry: second ---
NAME:: second
TYPE:: series int
DESCRIPTION:: Current bar second in exchange timezone.
SEE_ALSO:: time, year, month, weekofyear, dayofmonth, dayofweek, hour, minute
---
# --- Entry: session.isfirstbar ---
NAME:: session.isfirstbar
TYPE:: series bool
DESCRIPTION:: Returns true if the current bar is the first bar of the day's session, false otherwise. If extended session is used, true only on the first bar of the pre-market bars.
EXAMPLE::
//@version=5
strategy("`session.isfirstbar` Example", overlay = true)
longCondition = year >= 2022
if session.isfirstbar and longCondition
strategy.entry("Long", strategy.long)
if session.islastbar and barstate.isconfirmed
strategy.close("Long", immediately = true)
SEE_ALSO:: session.isfirstbar_regular, session.islastbar, session.islastbar_regular
---
# --- Entry: session.isfirstbar_regular ---
NAME:: session.isfirstbar_regular
TYPE:: series bool
DESCRIPTION:: Returns true on the first regular session bar of the day, false otherwise. Result is the same whether extended session information is used or not.
SEE_ALSO:: session.isfirstbar, session.islastbar, session.islastbar_regular
---
# --- Entry: session.islastbar ---
NAME:: session.islastbar
TYPE:: series bool
DESCRIPTION:: Returns true if the current bar is the last bar of the day's session, false otherwise. If extended session is used, true only on the last bar of the post-market bars.
REMARKS::
- Not guaranteed to return true once every session (last bar might not exist if no trades occur).
- Not guaranteed to work as expected on non-standard chart types (e.g., Renko).
SEE_ALSO:: session.isfirstbar, session.islastbar_regular
---
# --- Entry: session.islastbar_regular ---
NAME:: session.islastbar_regular
TYPE:: series bool
DESCRIPTION:: Returns true on the last regular session bar of the day, false otherwise. Result is the same whether extended session information is used or not.
REMARKS::
- Not guaranteed to return true once every session (last bar might not exist if no trades occur).
- Not guaranteed to work as expected on non-standard chart types (e.g., Renko).
SEE_ALSO:: session.isfirstbar, session.islastbar, session.isfirstbar_regular
---
# --- Entry: session.ismarket ---
NAME:: session.ismarket
TYPE:: series bool
DESCRIPTION:: Returns true if the current bar is a part of the regular trading hours (i.e. market hours), false otherwise.
SEE_ALSO:: session.ispremarket, session.ispostmarket
---
# --- Entry: session.ispostmarket ---
NAME:: session.ispostmarket
TYPE:: series bool
DESCRIPTION:: Returns true if the current bar is a part of the post-market, false otherwise. Always returns false on non-intraday charts.
SEE_ALSO:: session.ismarket, session.ispremarket
---
# --- Entry: session.ispremarket ---
NAME:: session.ispremarket
TYPE:: series bool
DESCRIPTION:: Returns true if the current bar is a part of the pre-market, false otherwise. Always returns false on non-intraday charts.
SEE_ALSO:: session.ismarket, session.ispostmarket
---
# --- Entry: strategy.account_currency ---
NAME:: strategy.account_currency
TYPE:: simple string
DESCRIPTION:: Returns the currency used to calculate strategy results (set in strategy properties).
SEE_ALSO:: strategy, strategy.convert_to_account, strategy.convert_to_symbol
---
# --- Entry: strategy.avg_losing_trade ---
NAME:: strategy.avg_losing_trade
TYPE:: series float
DESCRIPTION:: Returns the average amount of money lost per losing trade.
SEE_ALSO:: strategy.avg_losing_trade_percent
---
# --- Entry: strategy.avg_losing_trade_percent ---
NAME:: strategy.avg_losing_trade_percent
TYPE:: series float
DESCRIPTION:: Returns the average percentage loss per losing trade.
SEE_ALSO:: strategy.avg_losing_trade
---
# --- Entry: strategy.avg_trade ---
NAME:: strategy.avg_trade
TYPE:: series float
DESCRIPTION:: Returns the average amount of money gained or lost per trade (all closed trades).
SEE_ALSO:: strategy.avg_trade_percent
---
# --- Entry: strategy.avg_trade_percent ---
NAME:: strategy.avg_trade_percent
TYPE:: series float
DESCRIPTION:: Returns the average percentage gain or loss per trade (all closed trades).
SEE_ALSO:: strategy.avg_trade
---
# --- Entry: strategy.avg_winning_trade ---
NAME:: strategy.avg_winning_trade
TYPE:: series float
DESCRIPTION:: Returns the average amount of money gained per winning trade.
SEE_ALSO:: strategy.avg_winning_trade_percent
---
# --- Entry: strategy.avg_winning_trade_percent ---
NAME:: strategy.avg_winning_trade_percent
TYPE:: series float
DESCRIPTION:: Returns the average percentage gain per winning trade.
SEE_ALSO:: strategy.avg_winning_trade
---
# --- Entry: strategy.closedtrades ---
NAME:: strategy.closedtrades
TYPE:: series int
DESCRIPTION:: Number of trades which were closed for the whole trading interval.
SEE_ALSO:: strategy.position_size, strategy.opentrades, strategy.wintrades, strategy.losstrades, strategy.eventrades
---
# --- Entry: strategy.equity ---
NAME:: strategy.equity
TYPE:: series float
DESCRIPTION:: Current equity (strategy.initial_capital + strategy.netprofit + strategy.openprofit).
SEE_ALSO:: strategy.netprofit, strategy.openprofit, strategy.position_size
---
# --- Entry: strategy.eventrades ---
NAME:: strategy.eventrades
TYPE:: series int
DESCRIPTION:: Number of breakeven trades for the whole trading interval.
SEE_ALSO:: strategy.position_size, strategy.opentrades, strategy.closedtrades, strategy.wintrades, strategy.losstrades
---
# --- Entry: strategy.grossloss ---
NAME:: strategy.grossloss
TYPE:: series float
DESCRIPTION:: Total currency value of all completed losing trades.
SEE_ALSO:: strategy.netprofit, strategy.grossprofit
---
# --- Entry: strategy.grossloss_percent ---
NAME:: strategy.grossloss_percent
TYPE:: series float
DESCRIPTION:: The total value of all completed losing trades, expressed as a percentage of the initial capital.
SEE_ALSO:: strategy.grossloss
---
# --- Entry: strategy.grossprofit ---
NAME:: strategy.grossprofit
TYPE:: series float
DESCRIPTION:: Total currency value of all completed winning trades.
SEE_ALSO:: strategy.netprofit, strategy.grossloss
---
# --- Entry: strategy.grossprofit_percent ---
NAME:: strategy.grossprofit_percent
TYPE:: series float
DESCRIPTION:: The total currency value of all completed winning trades, expressed as a percentage of the initial capital.
SEE_ALSO:: strategy.grossprofit
---
# --- Entry: strategy.initial_capital ---
NAME:: strategy.initial_capital
TYPE:: series float
DESCRIPTION:: The amount of initial capital set in the strategy properties.
SEE_ALSO:: strategy
---
# --- Entry: strategy.losstrades ---
NAME:: strategy.losstrades
TYPE:: series int
DESCRIPTION:: Number of unprofitable trades for the whole trading interval.
SEE_ALSO:: strategy.position_size, strategy.opentrades, strategy.closedtrades, strategy.wintrades, strategy.eventrades
---
# --- Entry: strategy.margin_liquidation_price ---
NAME:: strategy.margin_liquidation_price
TYPE:: series float
DESCRIPTION:: When margin is used, returns the price point where a simulated margin call will occur and liquidate enough of the position.
REMARKS:: Returns 'na' if the strategy does not use margin (no 'margin_long' or 'margin_short' specified).
---
# --- Entry: strategy.max_contracts_held_all ---
NAME:: strategy.max_contracts_held_all
TYPE:: series float
DESCRIPTION:: Maximum number of contracts/shares/lots/units in one trade for the whole trading interval.
SEE_ALSO:: strategy.position_size, strategy.max_contracts_held_long, strategy.max_contracts_held_short
---
# --- Entry: strategy.max_contracts_held_long ---
NAME:: strategy.max_contracts_held_long
TYPE:: series float
DESCRIPTION:: Maximum number of contracts/shares/lots/units in one long trade for the whole trading interval.
SEE_ALSO:: strategy.position_size, strategy.max_contracts_held_all, strategy.max_contracts_held_short
---
# --- Entry: strategy.max_contracts_held_short ---
NAME:: strategy.max_contracts_held_short
TYPE:: series float
DESCRIPTION:: Maximum number of contracts/shares/lots/units in one short trade for the whole trading interval.
SEE_ALSO:: strategy.position_size, strategy.max_contracts_held_all, strategy.max_contracts_held_long
---
# --- Entry: strategy.max_drawdown ---
NAME:: strategy.max_drawdown
TYPE:: series float
DESCRIPTION:: Maximum equity drawdown value for the whole trading interval.
SEE_ALSO:: strategy.netprofit, strategy.equity, strategy.max_runup
---
# --- Entry: strategy.max_drawdown_percent ---
NAME:: strategy.max_drawdown_percent
TYPE:: series float
DESCRIPTION:: The maximum equity drawdown value for the whole trading interval, expressed as a percentage.
SEE_ALSO:: strategy.max_drawdown
---
# --- Entry: strategy.max_runup ---
NAME:: strategy.max_runup
TYPE:: series float
DESCRIPTION:: Maximum equity run-up value for the whole trading interval.
SEE_ALSO:: strategy.netprofit, strategy.equity, strategy.max_drawdown
---
# --- Entry: strategy.max_runup_percent ---
NAME:: strategy.max_runup_percent
TYPE:: series float
DESCRIPTION:: The maximum equity run-up value for the whole trading interval, expressed as a percentage.
SEE_ALSO:: strategy.max_runup
---
# --- Entry: strategy.netprofit ---
NAME:: strategy.netprofit
TYPE:: series float
DESCRIPTION:: Total currency value of all completed trades.
SEE_ALSO:: strategy.openprofit, strategy.position_size, strategy.grossprofit, strategy.grossloss
---
# --- Entry: strategy.netprofit_percent ---
NAME:: strategy.netprofit_percent
TYPE:: series float
DESCRIPTION:: The total value of all completed trades, expressed as a percentage of the initial capital.
SEE_ALSO:: strategy.netprofit
---
# --- Entry: strategy.openprofit ---
NAME:: strategy.openprofit
TYPE:: series float
DESCRIPTION:: Current unrealized profit or loss for all open positions.
SEE_ALSO:: strategy.netprofit, strategy.position_size
---
# --- Entry: strategy.openprofit_percent ---
NAME:: strategy.openprofit_percent
TYPE:: series float
DESCRIPTION:: The current unrealized profit or loss for all open positions, expressed as a percentage.
SEE_ALSO:: strategy.openprofit
---
# --- Entry: strategy.opentrades ---
NAME:: strategy.opentrades
TYPE:: series int
DESCRIPTION:: Number of market position entries which were not closed and remain opened (0 if flat).
SEE_ALSO:: strategy.position_size
---
# --- Entry: strategy.opentrades.capital_held ---
NAME:: strategy.opentrades.capital_held
TYPE:: series float
DESCRIPTION:: Returns the capital amount currently held by open trades.
REMARKS:: Returns 'na' if the strategy does not simulate funding trades with margin (no nonzero 'margin_long' or 'margin_short' specified).
---
# --- Entry: strategy.position_avg_price ---
NAME:: strategy.position_avg_price
TYPE:: series float
DESCRIPTION:: Average entry price of current market position. Returns 'NaN' if the market position is flat.
SEE_ALSO:: strategy.position_size
---
# --- Entry: strategy.position_entry_name ---
NAME:: strategy.position_entry_name
TYPE:: series string
DESCRIPTION:: Name of the order that initially opened current market position.
SEE_ALSO:: strategy.position_size
---
# --- Entry: strategy.position_size ---
NAME:: strategy.position_size
TYPE:: series float
DESCRIPTION:: Direction and size of the current market position. > 0 is long, < 0 is short. Absolute value is the number of contracts/shares/lots/units.
SEE_ALSO:: strategy.position_avg_price
---
# --- Entry: strategy.wintrades ---
NAME:: strategy.wintrades
TYPE:: series int
DESCRIPTION:: Number of profitable trades for the whole trading interval.
SEE_ALSO:: strategy.position_size, strategy.opentrades, strategy.closedtrades, strategy.losstrades, strategy.eventrades
---
# --- Entry: syminfo.basecurrency ---
NAME:: syminfo.basecurrency
TYPE:: simple string
DESCRIPTION:: Returns a string containing the code representing the symbol's base currency (i.e., the traded currency or coin) for Forex/Crypto pairs or derivatives. Returns an empty string otherwise.
EXAMPLE:: "EUR" for "EURJPY", "BTC" for "BTCUSDT", "" for "NASDAQ:AAPL".
SEE_ALSO:: syminfo.currency, syminfo.ticker
---
# --- Entry: syminfo.country ---
NAME:: syminfo.country
TYPE:: simple string
DESCRIPTION:: Returns the two-letter country code (ISO 3166-1 alpha-2) where the symbol is traded, or 'na' if the exchange is not directly tied to a specific country.
EXAMPLE:: "US" for "NASDAQ:AAPL", "GB" for "LSE:AAPL", 'na' for "BITSTAMP:BTCUSD".
---
# --- Entry: syminfo.currency ---
NAME:: syminfo.currency
TYPE:: simple string
DESCRIPTION:: Returns a string containing the code representing the currency of the symbol's prices.
EXAMPLE:: "USD" for "NASDAQ:AAPL", "JPY" for "EURJPY".
SEE_ALSO:: syminfo.basecurrency, syminfo.ticker, currency.USD, currency.EUR
---
# --- Entry: syminfo.description ---
NAME:: syminfo.description
TYPE:: simple string
DESCRIPTION:: Description for the current symbol.
SEE_ALSO:: syminfo.ticker, syminfo.prefix
---
# --- Entry: syminfo.employees ---
NAME:: syminfo.employees
TYPE:: simple int
DESCRIPTION:: The number of employees the company has.
EXAMPLE::
//@version=5
indicator("syminfo simple")
// variable A table containing information about a company's employees, shareholders, and shares.
var result_table = table.new(position = position.top)
# --------------------------------------------------------------------------
# PINE SCRIPT CONSTANTS REFERENCE (Selected)
# Format: KEY:: VALUE
# --- Entry: adjustment.dividends ---
NAME:: adjustment.dividends
TYPE:: const string
DESCRIPTION:: Constant for dividends adjustment type (dividends adjustment is applied).
SEE_ALSO:: adjustment.none, adjustment.splits, ticker.new
---
# --- Entry: adjustment.none ---
NAME:: adjustment.none
TYPE:: const string
DESCRIPTION:: Constant for none adjustment type (no adjustment is applied).
SEE_ALSO:: adjustment.splits, adjustment.dividends, ticker.new
---
# --- Entry: adjustment.splits ---
NAME:: adjustment.splits
TYPE:: const string
DESCRIPTION:: Constant for splits adjustment type (splits adjustment is applied).
SEE_ALSO:: adjustment.none, adjustment.dividends, ticker.new
---
# --- Entry: alert.freq_all ---
NAME:: alert.freq_all
TYPE:: const string
DESCRIPTION:: Alert frequency constant. All function calls trigger the alert.
SEE_ALSO:: alert
---
# --- Entry: alert.freq_once_per_bar ---
NAME:: alert.freq_once_per_bar
TYPE:: const string
DESCRIPTION:: Alert frequency constant. The first function call during the bar triggers the alert.
SEE_ALSO:: alert
---
# --- Entry: alert.freq_once_per_bar_close ---
NAME:: alert.freq_once_per_bar_close
TYPE:: const string
DESCRIPTION:: Alert frequency constant. Triggers only on the last script iteration of the real-time bar when it closes.
SEE_ALSO:: alert
---
# --- Entry: backadjustment.inherit ---
NAME:: backadjustment.inherit
TYPE:: const backadjustment
DESCRIPTION:: Specifies the backadjustment parameter in ticker.new/ticker.modify functions to inherit from the chart.
SEE_ALSO:: ticker.new, ticker.modify, backadjustment.on, backadjustment.off
---
# --- Entry: backadjustment.off ---
NAME:: backadjustment.off
TYPE:: const backadjustment
DESCRIPTION:: Specifies the backadjustment parameter in ticker.new/ticker.modify functions to disable backadjustment.
SEE_ALSO:: ticker.new, ticker.modify, backadjustment.on, backadjustment.inherit
---
# --- Entry: backadjustment.on ---
NAME:: backadjustment.on
TYPE:: const backadjustment
DESCRIPTION:: Specifies the backadjustment parameter in ticker.new/ticker.modify functions to enable backadjustment.
SEE_ALSO:: ticker.new, ticker.modify, backadjustment.inherit, backadjustment.off
---
# --- Entry: barmerge.gaps_off ---
NAME:: barmerge.gaps_off
TYPE:: const barmerge_gaps
DESCRIPTION:: Merge strategy for requested data. Data is merged continuously without gaps; gaps are filled with the previous nearest existing value.
SEE_ALSO:: request.security, barmerge.gaps_on
---
# --- Entry: barmerge.gaps_on ---
NAME:: barmerge.gaps_on
TYPE:: const barmerge_gaps
DESCRIPTION:: Merge strategy for requested data. Data is merged with possible gaps (na values).
SEE_ALSO:: request.security, barmerge.gaps_off
---
# --- Entry: barmerge.lookahead_off ---
NAME:: barmerge.lookahead_off
TYPE:: const barmerge_lookahead
DESCRIPTION:: Merge strategy for requested data position. Merges in order of bar close time, which disables getting data from the "future" on history. Recommended for backtesting strategies.
SEE_ALSO:: request.security, barmerge.lookahead_on
---
# --- Entry: barmerge.lookahead_on ---
NAME:: barmerge.lookahead_on
TYPE:: const barmerge_lookahead
DESCRIPTION:: Merge strategy for requested data position. Merges in order of bar opening time. Can lead to getting data from the "future" on history. Useful in indicators, but unacceptable for backtesting strategies.
SEE_ALSO:: request.security, barmerge.lookahead_off
---
# --- Entry: color.aqua ---
NAME:: color.aqua
TYPE:: const color
DESCRIPTION:: Named constant for #00BCD4 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.orange
---
# --- Entry: color.black ---
NAME:: color.black
TYPE:: const color
DESCRIPTION:: Named constant for #363A45 color.
SEE_ALSO:: color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.blue ---
NAME:: color.blue
TYPE:: const color
DESCRIPTION:: Named constant for #2962ff color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.teal, color.aqua, color.orange
---
# --- Entry: color.fuchsia ---
NAME:: color.fuchsia
TYPE:: const color
DESCRIPTION:: Named constant for #E040FB color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.gray ---
NAME:: color.gray
TYPE:: const color
DESCRIPTION:: Named constant for #787B86 color.
SEE_ALSO:: color.black, color.silver, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.green ---
NAME:: color.green
TYPE:: const color
DESCRIPTION:: Named constant for #4CAF50 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.lime ---
NAME:: color.lime
TYPE:: const color
DESCRIPTION:: Named constant for #00E676 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color
---
# --- Entry: color.maroon ---
NAME:: color.maroon
TYPE:: const color
DESCRIPTION:: Named constant for #880E4F color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.navy ---
NAME:: color.navy
TYPE:: const color
DESCRIPTION:: Named constant for #311B92 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.olive ---
NAME:: color.olive
TYPE:: const color
DESCRIPTION:: Named constant for #808000 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.orange ---
NAME:: color.orange
TYPE:: const color
DESCRIPTION:: Named constant for #FF9800 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua
---
# --- Entry: color.purple ---
NAME:: color.purple
TYPE:: const color
DESCRIPTION:: Named constant for #9C27B0 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.red ---
NAME:: color.red
TYPE:: const color
DESCRIPTION:: Named constant for #FF5252 color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.silver ---
NAME:: color.silver
TYPE:: const color
DESCRIPTION:: Named constant for #B2B5BE color.
SEE_ALSO:: color.black, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.teal ---
NAME:: color.teal
TYPE:: const color
DESCRIPTION:: Named constant for #00897B color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.aqua, color.orange
---
# --- Entry: color.white ---
NAME:: color.white
TYPE:: const color
DESCRIPTION:: Named constant for #FFFFFF color.
SEE_ALSO:: color.black, color.silver, color.gray, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: color.yellow ---
NAME:: color.yellow
TYPE:: const color
DESCRIPTION:: Named constant for #FFEB3B color.
SEE_ALSO:: color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.navy, color.blue, color.teal, color.aqua, color.orange
---
# --- Entry: currency.AUD ---
NAME:: currency.AUD
TYPE:: const string
DESCRIPTION:: Australian dollar.
SEE_ALSO:: strategy
---
# --- Entry: currency.BTC ---
NAME:: currency.BTC
TYPE:: const string
DESCRIPTION:: Bitcoin.
SEE_ALSO:: strategy
---
# --- Entry: currency.CAD ---
NAME:: currency.CAD
TYPE:: const string
DESCRIPTION:: Canadian dollar.
SEE_ALSO:: strategy
---
# --- Entry: currency.CHF ---
NAME:: currency.CHF
TYPE:: const string
DESCRIPTION:: Swiss franc.
SEE_ALSO:: strategy
---
# --- Entry: currency.ETH ---
NAME:: currency.ETH
TYPE:: const string
DESCRIPTION:: Ethereum.
SEE_ALSO:: strategy
---
# --- Entry: currency.EUR ---
NAME:: currency.EUR
TYPE:: const string
DESCRIPTION:: Euro.
SEE_ALSO:: strategy
---
# --- Entry: currency.GBP ---
NAME:: currency.GBP
TYPE:: const string
DESCRIPTION:: Pound sterling.
SEE_ALSO:: strategy
---
# --- Entry: currency.HKD ---
NAME:: currency.HKD
TYPE:: const string
DESCRIPTION:: Hong Kong dollar.
SEE_ALSO:: strategy
---
# --- Entry: currency.INR ---
NAME:: currency.INR
TYPE:: const string
DESCRIPTION:: Indian rupee.
SEE_ALSO:: strategy
---
# --- Entry: currency.JPY ---
NAME:: currency.JPY
TYPE:: const string
DESCRIPTION:: Japanese yen.
SEE_ALSO:: strategy
---
# --- Entry: currency.KRW ---
NAME:: currency.KRW
TYPE:: const string
DESCRIPTION:: South Korean won.
SEE_ALSO:: strategy
---
# --- Entry: currency.MYR ---
NAME:: currency.MYR
TYPE:: const string
DESCRIPTION:: Malaysian ringgit.
SEE_ALSO:: strategy
---
# --- Entry: currency.NOK ---
NAME:: currency.NOK
TYPE:: const string
DESCRIPTION:: Norwegian krone.
SEE_ALSO:: strategy
---
# --- Entry: currency.NONE ---
NAME:: currency.NONE
TYPE:: const string
DESCRIPTION:: Unspecified currency.
SEE_ALSO:: strategy
---
# --- Entry: currency.NZD ---
NAME:: currency.NZD
TYPE:: const string
DESCRIPTION:: New Zealand dollar.
SEE_ALSO:: strategy
---
# --- Entry: currency.RUB ---
NAME:: currency.RUB
TYPE:: const string
DESCRIPTION:: Russian ruble.
SEE_ALSO:: strategy
---
# --- Entry: currency.SEK ---
NAME:: currency.SEK
TYPE:: const string
DESCRIPTION:: Swedish krona.
SEE_ALSO:: strategy
---
# --- Entry: currency.SGD ---
NAME:: currency.SGD
TYPE:: const string
DESCRIPTION:: Singapore dollar.
SEE_ALSO:: strategy
---
# --- Entry: currency.TRY ---
NAME:: currency.TRY
TYPE:: const string
DESCRIPTION:: Turkish lira.
SEE_ALSO:: strategy
---
# --- Entry: currency.USD ---
NAME:: currency.USD
TYPE:: const string
DESCRIPTION:: United States dollar.
SEE_ALSO:: strategy
---
# --- Entry: currency.USDT ---
NAME:: currency.USDT
TYPE:: const string
DESCRIPTION:: Tether.
SEE_ALSO:: strategy
---
# --- Entry: currency.ZAR ---
NAME:: currency.ZAR
TYPE:: const string
DESCRIPTION:: South African rand.
SEE_ALSO:: strategy
---
# --- Entry: dayofweek.friday ---
NAME:: dayofweek.friday
TYPE:: const int
DESCRIPTION:: Named constant for the value representing Friday.
SEE_ALSO:: dayofweek.sunday, dayofweek.monday, dayofweek.tuesday, dayofweek.wednesday, dayofweek.thursday, dayofweek.saturday
---
# --- Entry: dayofweek.monday ---
NAME:: dayofweek.monday
TYPE:: const int
DESCRIPTION:: Named constant for the value representing Monday.
SEE_ALSO:: dayofweek.sunday, dayofweek.tuesday, dayofweek.wednesday, dayofweek.thursday, dayofweek.friday, dayofweek.saturday
---
# --- Entry: dayofweek.saturday ---
NAME:: dayofweek.saturday
TYPE:: const int
DESCRIPTION:: Named constant for the value representing Saturday.
SEE_ALSO:: dayofweek.sunday, dayofweek.monday, dayofweek.tuesday, dayofweek.wednesday, dayofweek.thursday, dayofweek.friday
---
# --- Entry: dayofweek.sunday ---
NAME:: dayofweek.sunday
TYPE:: const int
DESCRIPTION:: Named constant for the value representing Sunday.
SEE_ALSO:: dayofweek.monday, dayofweek.tuesday, dayofweek.wednesday, dayofweek.thursday, dayofweek.friday, dayofweek.saturday
---
# --- Entry: dayofweek.thursday ---
NAME:: dayofweek.thursday
TYPE:: const int
DESCRIPTION:: Named constant for the value representing Thursday.
SEE_ALSO:: dayofweek.sunday, dayofweek.monday, dayofweek.tuesday, dayofweek.wednesday, dayofweek.friday, dayofweek.saturday
---
# --- Entry: dayofweek.tuesday ---
NAME:: dayofweek.tuesday
TYPE:: const int
DESCRIPTION:: Named constant for the value representing Tuesday.
SEE_ALSO:: dayofweek.sunday, dayofweek.monday, dayofweek.wednesday, dayofweek.thursday, dayofweek.friday, dayofweek.saturday
---
# --- Entry: dayofweek.wednesday ---
NAME:: dayofweek.wednesday
TYPE:: const int
DESCRIPTION:: Named constant for the value representing Wednesday.
SEE_ALSO:: dayofweek.sunday, dayofweek.monday, dayofweek.tuesday, dayofweek.thursday, dayofweek.friday, dayofweek.saturday
---
# --- Entry: display.all ---
NAME:: display.all
TYPE:: const plot_simple_display
DESCRIPTION:: Plot display constant. Displays plotted or input values in all possible locations.
SEE_ALSO:: plot, plotshape, plotchar, plotarrow, plotbar, plotcandle
---
# --- Entry: display.data_window ---
NAME:: display.data_window
TYPE:: const plot_display
DESCRIPTION:: Plot display constant. Displays plotted or input values in the Data Window (right sidebar menu).
SEE_ALSO:: plot, plotshape, plotchar, plotarrow, plotbar, plotcandle
---
# --- Entry: display.none ---
NAME:: display.none
TYPE:: const plot_simple_display
DESCRIPTION:: Plot display constant. Does not display plotted values anywhere, but they can still be used by alerts/fills and appear in exported data. Input values only show in script settings.
SEE_ALSO:: plot, plotshape, plotchar, plotarrow, plotbar, plotcandle
---
# --- Entry: display.pane ---
NAME:: display.pane
TYPE:: const plot_display
DESCRIPTION:: Plot display constant. Displays plotted values in the chart pane used by the script.
SEE_ALSO:: plot, plotshape, plotchar, plotarrow, plotbar, plotcandle
---
# --- Entry: display.price_scale ---
NAME:: display.price_scale
TYPE:: const plot_display
DESCRIPTION:: Plot display constant. Displays the plot's label and value on the price scale if chart settings allow.
SEE_ALSO:: plot, plotshape, plotchar, plotarrow, plotbar, plotcandle
---
# --- Entry: display.status_line ---
NAME:: display.status_line
TYPE:: const plot_display
DESCRIPTION:: Plot display constant. Displays plotted or input values in the status line next to the script's name.
SEE_ALSO:: plot, plotshape, plotchar, plotarrow, plotbar, plotcandle
---
# --- Entry: dividends.gross ---
NAME:: dividends.gross
TYPE:: const string
DESCRIPTION:: Constant for request.dividends. Requests the dividends return on a stock before deductions.
SEE_ALSO:: request.dividends
---
# --- Entry: dividends.net ---
NAME:: dividends.net
TYPE:: const string
DESCRIPTION:: Constant for request.dividends. Requests the dividends return on a stock after deductions.
SEE_ALSO:: request.dividends
---
# --- Entry: earnings.actual ---
NAME:: earnings.actual
TYPE:: const string
DESCRIPTION:: Constant for request.earnings. Requests the earnings value as it was reported.
SEE_ALSO:: request.earnings
---
# --- Entry: earnings.estimate ---
NAME:: earnings.estimate
TYPE:: const string
DESCRIPTION:: Constant for request.earnings. Requests the estimated earnings value.
SEE_ALSO:: request.earnings
---
# --- Entry: earnings.standardized ---
NAME:: earnings.standardized
TYPE:: const string
DESCRIPTION:: Constant for request.earnings. Requests the standardized earnings value.
SEE_ALSO:: request.earnings
---
# --- Entry: extend.both ---
NAME:: extend.both
TYPE:: const string
DESCRIPTION:: Line extension constant. Extends the line in both directions.
SEE_ALSO:: line.new, line.set_extend, extend.none, extend.left, extend.right
---
# --- Entry: extend.left ---
NAME:: extend.left
TYPE:: const string
DESCRIPTION:: Line extension constant. Extends the line to the left.
SEE_ALSO:: line.new, line.set_extend, extend.none, extend.right, extend.both
---
# --- Entry: extend.none ---
NAME:: extend.none
TYPE:: const string
DESCRIPTION:: Line extension constant. No extension is applied.
SEE_ALSO:: line.new, line.set_extend, extend.left, extend.right, extend.both
---
# --- Entry: extend.right ---
NAME:: extend.right
TYPE:: const string
DESCRIPTION:: Line extension constant. Extends the line to the right.
SEE_ALSO:: line.new, line.set_extend, extend.none, extend.left, extend.both
---
# --- Entry: false ---
NAME:: false
TYPE:: const bool
DESCRIPTION:: Literal representing a boolean value of **false**.
REMARKS:: See the User Manual for comparison operators and logical operators.
SEE_ALSO:: bool
---
# --- Entry: font.family_default ---
NAME:: font.family_default
TYPE:: const string
DESCRIPTION:: Default text font for box/label/table functions.
SEE_ALSO:: box.new, box.set_text_font_family, label.new, label.set_text_font_family, table.cell, table.cell_set_text_font_family, font.family_monospace
---
# --- Entry: font.family_monospace ---
NAME:: font.family_monospace
TYPE:: const string
DESCRIPTION:: Monospace text font for box/label/table functions.
SEE_ALSO:: box.new, box.set_text_font_family, label.new, label.set_text_font_family, table.cell, table.cell_set_text_font_family, font.family_default
---
# --- Entry: format.inherit ---
NAME:: format.inherit
TYPE:: const string
DESCRIPTION:: Formatting constant. Selects the formatting of script output values from the parent series in the indicator function.
SEE_ALSO:: indicator, format.price, format.volume, format.percent
---
# --- Entry: format.mintick ---
NAME:: format.mintick
TYPE:: const string
DESCRIPTION:: Formatting constant for str.tostring. Rounds a number to the nearest value divisible by syminfo.mintick and returns a string with trailing zeros.
SEE_ALSO:: indicator, format.inherit, format.price, format.volume, format.percent
---
# --- Entry: format.percent ---
NAME:: format.percent
TYPE:: const string
DESCRIPTION:: Formatting constant. Selects formatting as a percentage in the indicator function. Adds a percent sign.
REMARKS:: Default precision is 2, but can be changed with the 'precision' argument of the indicator function.
SEE_ALSO:: indicator, format.inherit, format.price, format.volume
---
# --- Entry: format.price ---
NAME:: format.price
TYPE:: const string
DESCRIPTION:: Formatting constant. Selects formatting of script output values as prices in the indicator function.
REMARKS:: Default precision is set by the chart's precision, but can be changed with the 'precision' argument of the indicator function.
SEE_ALSO:: indicator, format.inherit, format.volume, format.percent
---
# --- Entry: format.volume ---
NAME:: format.volume
TYPE:: const string
DESCRIPTION:: Formatting constant. Selects formatting of script output values as volume (e.g., 'K' for thousands). Takes precedence over other precision settings.
SEE_ALSO:: indicator, format.inherit, format.price, format.percent
---
# --- Entry: hline.style_dashed ---
NAME:: hline.style_dashed
TYPE:: const hline_style
DESCRIPTION:: Line style constant for a dashed line in hline function.
SEE_ALSO:: hline.style_solid, hline.style_dotted
---
# --- Entry: hline.style_dotted ---
NAME:: hline.style_dotted
TYPE:: const hline_style
DESCRIPTION:: Line style constant for a dotted line in hline function.
SEE_ALSO:: hline.style_solid, hline.style_dashed
---
# --- Entry: hline.style_solid ---
NAME:: hline.style_solid
TYPE:: const hline_style
DESCRIPTION:: Line style constant for a solid line in hline function.
SEE_ALSO:: hline.style_dotted, hline.style_dashed
---
# --- Entry: label.style_arrowdown ---
NAME:: label.style_arrowdown
TYPE:: const string
DESCRIPTION:: Label style constant for a downward arrow.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_arrowup ---
NAME:: label.style_arrowup
TYPE:: const string
DESCRIPTION:: Label style constant for an upward arrow.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_circle ---
NAME:: label.style_circle
TYPE:: const string
DESCRIPTION:: Label style constant for a circle.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_cross ---
NAME:: label.style_cross
TYPE:: const string
DESCRIPTION:: Label style constant for a cross ('+').
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_diamond ---
NAME:: label.style_diamond
TYPE:: const string
DESCRIPTION:: Label style constant for a diamond shape.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square
---
# --- Entry: label.style_flag ---
NAME:: label.style_flag
TYPE:: const string
DESCRIPTION:: Label style constant for a flag shape.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_center ---
NAME:: label.style_label_center
TYPE:: const string
DESCRIPTION:: Label style constant for a centered label box.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_down ---
NAME:: label.style_label_down
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing down.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_left ---
NAME:: label.style_label_left
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing left.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_lower_left ---
NAME:: label.style_label_lower_left
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing lower-left.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_lower_right ---
NAME:: label.style_label_lower_right
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing lower-right.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_right ---
NAME:: label.style_label_right
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing right.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_up ---
NAME:: label.style_label_up
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing up.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_upper_left ---
NAME:: label.style_label_upper_left
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing upper-left.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_label_upper_right ---
NAME:: label.style_label_upper_right
TYPE:: const string
DESCRIPTION:: Label style constant for a label box pointing upper-right.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_none ---
NAME:: label.style_none
TYPE:: const string
DESCRIPTION:: Label style constant for no shape (text only).
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_square ---
NAME:: label.style_square
TYPE:: const string
DESCRIPTION:: Label style constant for a square shape.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_diamond
---
# --- Entry: label.style_text_outline ---
NAME:: label.style_text_outline
TYPE:: const string
DESCRIPTION:: Label style constant for a text outline (deprecated in recent versions, often replaced by background/border properties).
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_triangledown ---
NAME:: label.style_triangledown
TYPE:: const string
DESCRIPTION:: Label style constant for a downward triangle.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangleup, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_triangleup ---
NAME:: label.style_triangleup
TYPE:: const string
DESCRIPTION:: Label style constant for an upward triangle.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_xcross, label.style_cross, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left, label.style_label_upper_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: label.style_xcross ---
NAME:: label.style_xcross
TYPE:: const string
DESCRIPTION:: Label style constant for an 'X' shape.
SEE_ALSO:: label.new, label.set_style, label.set_textalign, label.style_none, label.style_cross, label.style_triangleup, label.style_triangledown, label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown, label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right, label.style_label_center, label.style_square, label.style_diamond
---
# --- Entry: line.style_arrow_both ---
NAME:: line.style_arrow_both
TYPE:: const string
DESCRIPTION:: Line style constant. Solid line with arrows on both points.
SEE_ALSO:: line.new, line.set_style, line.style_solid, line.style_dotted, line.style_dashed, line.style_arrow_left, line.style_arrow_right
---
# --- Entry: line.style_arrow_left ---
NAME:: line.style_arrow_left
TYPE:: const string
DESCRIPTION:: Line style constant. Solid line with arrow on the first point.
SEE_ALSO:: line.new, line.set_style, line.style_solid, line.style_dotted, line.style_dashed, line.style_arrow_right, line.style_arrow_both
---
# --- Entry: line.style_arrow_right ---
NAME:: line.style_arrow_right
TYPE:: const string
DESCRIPTION:: Line style constant. Solid line with arrow on the second point.
SEE_ALSO:: line.new, line.set_style, line.style_solid, line.style_dotted, line.style_dashed, line.style_arrow_left, line.style_arrow_both
---
# --- Entry: line.style_dashed ---
NAME:: line.style_dashed
TYPE:: const string
DESCRIPTION:: Line style constant for a dashed line.
SEE_ALSO:: line.new, line.set_style, line.style_solid, line.style_dotted, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both
---
# --- Entry: line.style_dotted ---
NAME:: line.style_dotted
TYPE:: const string
DESCRIPTION:: Line style constant for a dotted line.
SEE_ALSO:: line.new, line.set_style, line.style_solid, line.style_dashed, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both
---
# --- Entry: line.style_solid ---
NAME:: line.style_solid
TYPE:: const string
DESCRIPTION:: Line style constant for a solid line.
SEE_ALSO:: line.new, line.set_style, line.style_dotted, line.style_dashed, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both
---
# --- Entry: location.abovebar ---
NAME:: location.abovebar
TYPE:: const string
DESCRIPTION:: Plot location constant. Shape is plotted above main series bars.
SEE_ALSO:: plotshape, plotchar, location.belowbar, location.top, location.bottom, location.absolute
---
# --- Entry: location.absolute ---
NAME:: location.absolute
TYPE:: const string
DESCRIPTION:: Plot location constant. Shape is plotted on chart using indicator value as a price coordinate.
SEE_ALSO:: plotshape, plotchar, location.abovebar, location.belowbar, location.top, location.bottom
---
# --- Entry: location.belowbar ---
NAME:: location.belowbar
TYPE:: const string
DESCRIPTION:: Plot location constant. Shape is plotted below main series bars.
SEE_ALSO:: plotshape, plotchar, location.abovebar, location.top, location.bottom, location.absolute
---
# --- Entry: location.bottom ---
NAME:: location.bottom
TYPE:: const string
DESCRIPTION:: Plot location constant. Shape is plotted near the bottom chart border.
SEE_ALSO:: plotshape, plotchar, location.abovebar, location.belowbar, location.top, location.absolute
---
# --- Entry: location.top ---
NAME:: location.top
TYPE:: const string
DESCRIPTION:: Plot location constant. Shape is plotted near the top chart border.
SEE_ALSO:: plotshape, plotchar, location.abovebar, location.belowbar, location.bottom, location.absolute
---
# --- Entry: math.e ---
NAME:: math.e
TYPE:: const float
DESCRIPTION:: Constant for the base of the natural logarithm, **e** $(\approx 2.718281828459045)$.
SEE_ALSO:: math.pi
#----------------------------------------------------------------------------------
# PINE SCRIPT FUNCTIONS AND CONSTANTS REFERENCE
--- Entry: alert ---
NAME:: alert
TYPE:: function
DESCRIPTION:: Creates an alert event during the real-time bar. Used to trigger an alert based on "alert function events."
SEE_ALSO:: alertcondition, alert.freq_all, alert.freq_once_per_bar, alert.freq_once_per_bar_close
--- Entry: alertcondition ---
NAME:: alertcondition
TYPE:: function
DESCRIPTION:: Creates an alert condition that is visible and selectable in the "Create Alert" dialog. Does not create an alert itself but provides options for user-defined alerts.
SEE_ALSO:: alert
--- Entry: array.abs ---
NAME:: array.abs
TYPE:: function
DESCRIPTION:: Returns a new array containing the absolute value of each element in the original array.
SEE_ALSO:: array.new_float, array.insert, array.slice, array.reverse
--- Entry: array.avg ---
NAME:: array.avg
TYPE:: function
DESCRIPTION:: Returns the mean (average) of an array's numeric elements.
SEE_ALSO:: array.new_float, array.max, array.min, array.stdev
--- Entry: array.binary_search ---
NAME:: array.binary_search
TYPE:: function
DESCRIPTION:: Returns the index of the value, or -1 if not found. Requires the array to be sorted in ascending order.
SEE_ALSO:: array.binary_search_leftmost, array.binary_search_rightmost, array.sort
--- Entry: array.binary_search_leftmost ---
NAME:: array.binary_search_leftmost
TYPE:: function
DESCRIPTION:: Returns the index of the first instance of the value found (or the insertion point to the left if not found). Requires an ascending array.
SEE_ALSO:: array.binary_search, array.binary_search_rightmost, array.sort
--- Entry: array.binary_search_rightmost ---
NAME:: array.binary_search_rightmost
TYPE:: function
DESCRIPTION:: Returns the index of the last instance of the value found (or the insertion point to the right if not found). Requires an ascending array.
SEE_ALSO:: array.binary_search, array.binary_search_leftmost, array.sort
--- Entry: array.clear ---
NAME:: array.clear
TYPE:: function
DESCRIPTION:: Removes all elements from an array, setting its size to zero.
SEE_ALSO:: array.new_float, array.insert, array.push, array.remove, array.pop
--- Entry: array.concat ---
NAME:: array.concat
TYPE:: function
DESCRIPTION:: Merges two arrays by pushing all elements from the second array (id2) onto the end of the first array (id1), and returns the first array.
SEE_ALSO:: array.new_float, array.insert, array.slice
--- Entry: array.copy ---
NAME:: array.copy
TYPE:: function
DESCRIPTION:: Creates a shallow copy of an existing array and returns the new array.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.covariance ---
NAME:: array.covariance
TYPE:: function
DESCRIPTION:: Returns the covariance of two arrays.
SEE_ALSO:: array.new_float, array.stdev, array.avg, array.variance
--- Entry: array.every ---
NAME:: array.every
TYPE:: function
DESCRIPTION:: Returns true if all elements of the boolean array are true, false otherwise. (For numeric arrays, non-zero is true.)
SEE_ALSO:: array.some, array.get
--- Entry: array.fill ---
NAME:: array.fill
TYPE:: function
DESCRIPTION:: Sets elements of an array to a single value within an optional index range.
SEE_ALSO:: array.new_float, array.set, array.slice
--- Entry: array.first ---
NAME:: array.first
TYPE:: function
DESCRIPTION:: Returns the array's first element. Throws a runtime error if the array is empty.
SEE_ALSO:: array.last, array.get
--- Entry: array.from ---
NAME:: array.from
TYPE:: function
DESCRIPTION:: Creates and returns a new array object by passing a variable number of elements directly to the function.
SEE_ALSO:: array.new_float, array.push, array.size
--- Entry: array.get ---
NAME:: array.get
TYPE:: function
DESCRIPTION:: Returns the value of the element at the specified index.
SEE_ALSO:: array.new_float, array.set, array.slice, array.sort
--- Entry: array.includes ---
NAME:: array.includes
TYPE:: function
DESCRIPTION:: Returns true if the value was found in an array, false otherwise.
SEE_ALSO:: array.indexof, array.shift, array.remove, array.insert
--- Entry: array.indexof ---
NAME:: array.indexof
TYPE:: function
DESCRIPTION:: Returns the index of the first occurrence of the value, or -1 if the value is not found.
SEE_ALSO:: array.lastindexof, array.get, array.remove, array.insert
--- Entry: array.insert ---
NAME:: array.insert
TYPE:: function
DESCRIPTION:: Adds a value in place at a specified index, shifting subsequent elements to the right.
SEE_ALSO:: array.new_float, array.set, array.push, array.remove, array.pop, array.unshift
--- Entry: array.join ---
NAME:: array.join
TYPE:: function
DESCRIPTION:: Creates and returns a new string by concatenating all array elements, separated by the specified separator string.
SEE_ALSO:: array.new_string, array.set, array.insert
--- Entry: array.last ---
NAME:: array.last
TYPE:: function
DESCRIPTION:: Returns the array's last element. Throws a runtime error if the array is empty.
SEE_ALSO:: array.first, array.get
--- Entry: array.lastindexof ---
NAME:: array.lastindexof
TYPE:: function
DESCRIPTION:: Returns the index of the last occurrence of the value, or -1 if the value is not found.
SEE_ALSO:: array.new_float, array.set, array.push, array.remove, array.insert
--- Entry: array.max ---
NAME:: array.max
TYPE:: function
DESCRIPTION:: Returns the greatest value, or the n
th
greatest value if the optional nth argument is used.
SEE_ALSO:: array.new_float, array.min, array.sum
--- Entry: array.median ---
NAME:: array.median
TYPE:: function
DESCRIPTION:: Returns the median (the middle value) of an array's elements.
SEE_ALSO:: array.avg, array.variance, array.min
--- Entry: array.min ---
NAME:: array.min
TYPE:: function
DESCRIPTION:: Returns the smallest value, or the n
th
smallest value if the optional nth argument is used.
SEE_ALSO:: array.new_float, array.max, array.sum
--- Entry: array.mode ---
NAME:: array.mode
TYPE:: function
DESCRIPTION:: Returns the mode (most frequently occurring value) of an array's elements.
SEE_ALSO:: array.new_float, ta.mode, array.avg
--- Entry: array.new_bool ---
NAME:: array.new_bool
TYPE:: function
DESCRIPTION:: Creates a new array object of bool type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_box ---
NAME:: array.new_box
TYPE:: function
DESCRIPTION:: Creates a new array object of box type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_color ---
NAME:: array.new_color
TYPE:: function
DESCRIPTION:: Creates a new array object of color type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_float ---
NAME:: array.new_float
TYPE:: function
DESCRIPTION:: Creates a new array object of float type elements.
SEE_ALSO:: array.new_color, array.new_bool, array.get, array.slice
--- Entry: array.new_int ---
NAME:: array.new_int
TYPE:: function
DESCRIPTION:: Creates a new array object of int type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_label ---
NAME:: array.new_label
TYPE:: function
DESCRIPTION:: Creates a new array object of label type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_line ---
NAME:: array.new_line
TYPE:: function
DESCRIPTION:: Creates a new array object of line type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_linefill ---
NAME:: array.new_linefill
TYPE:: function
DESCRIPTION:: Creates a new array object of linefill type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_string ---
NAME:: array.new_string
TYPE:: function
DESCRIPTION:: Creates a new array object of string type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new_table ---
NAME:: array.new_table
TYPE:: function
DESCRIPTION:: Creates a new array object of table type elements.
SEE_ALSO:: array.new_float, array.get, array.slice
--- Entry: array.new<type> ---
NAME:: array.new<type>
TYPE:: function
DESCRIPTION:: The generic function to create a new array object of <type> elements.
SEE_ALSO:: array.from, array.push, array.get, array.size
--- Entry: array.percentile_linear_interpolation ---
NAME:: array.percentile_linear_interpolation
TYPE:: function
DESCRIPTION:: Returns the value for which the specified percentile of array values are less than or equal to it, using linear interpolation.
SEE_ALSO:: array.percentile_nearest_rank, array.sort
--- Entry: array.percentile_nearest_rank ---
NAME:: array.percentile_nearest_rank
TYPE:: function
DESCRIPTION:: Returns the value for which the specified percentile of array values are less than or equal to it, using the nearest-rank method.
SEE_ALSO:: array.percentile_linear_interpolation, array.sort
--- Entry: array.percentrank ---
NAME:: array.percentrank
TYPE:: function
DESCRIPTION:: Returns the percentile rank of the element at the specified index.
SEE_ALSO:: array.new_float, array.sort
--- Entry: array.pop ---
NAME:: array.pop
TYPE:: function
DESCRIPTION:: Removes the last element from an array and returns its value.
SEE_ALSO:: array.new_float, array.push, array.remove, array.shift
--- Entry: array.push ---
NAME:: array.push
TYPE:: function
DESCRIPTION:: Appends a value to the end of an array.
SEE_ALSO:: array.new_float, array.set, array.insert, array.remove, array.pop, array.unshift
--- Entry: array.range ---
NAME:: array.range
TYPE:: function
DESCRIPTION:: Returns the difference between the min and max values (i.e., the range) from a given array.
SEE_ALSO:: array.new_float, array.min, array.max
--- Entry: array.remove ---
NAME:: array.remove
TYPE:: function
DESCRIPTION:: Changes the contents of an array by removing the element with the specified index and returns the value of the removed element.
SEE_ALSO:: array.new_float, array.set, array.push, array.insert, array.pop, array.shift
--- Entry: array.reverse ---
NAME:: array.reverse
TYPE:: function
DESCRIPTION:: Reverses an array in place (first becomes last, last becomes first).
SEE_ALSO:: array.new_float, array.sort, array.push
--- Entry: array.set ---
NAME:: array.set
TYPE:: function
DESCRIPTION:: Sets the value of the element at the specified index.
SEE_ALSO:: array.new_float, array.get, array.slice, array.sort, array.fill
--- Entry: array.shift ---
NAME:: array.shift
TYPE:: function
DESCRIPTION:: Removes the first element from an array and returns its value.
SEE_ALSO:: array.new_float, array.set, array.push, array.remove, array.pop, array.unshift
--- Entry: array.slice ---
NAME:: array.slice
TYPE:: function
DESCRIPTION:: Returns a new array containing a portion of the original array between the beginning and end indices (end index is exclusive).
SEE_ALSO:: array.new_float, array.copy, array.get, array.set
--- Entry: array.size ---
NAME:: array.size
TYPE:: function
DESCRIPTION:: Returns the number of elements in the array.
SEE_ALSO:: array.new_float, array.push, array.insert, array.remove, array.pop
--- Entry: array.some ---
NAME:: array.some
TYPE:: function
DESCRIPTION:: Returns true if at least one element of the boolean array is true, false otherwise. (For numeric arrays, non-zero is true.)
SEE_ALSO:: array.every, array.get
--- Entry: array.sort ---
NAME:: array.sort
TYPE:: function
DESCRIPTION:: Sorts an array in place. By default, it sorts in ascending order.
SEE_ALSO:: array.new_float, array.reverse, array.slice, order.ascending, order.descending
--- Entry: array.stdev ---
NAME:: array.stdev
TYPE:: function
DESCRIPTION:: Returns the standard deviation of an array's elements, allowing calculation based on a biased (population, default) or unbiased (sample) estimate.
SEE_ALSO:: array.new_float, array.avg, array.variance, array.min
--- Entry: array.sum ---
NAME:: array.sum
TYPE:: function
DESCRIPTION:: Returns the sum of all elements in an array.
SEE_ALSO:: array.new_float, array.avg, array.max, array.min
--- Entry: array.unshift ---
NAME:: array.unshift
TYPE:: function
DESCRIPTION:: Adds a value to the beginning of an array, shifting existing elements to the right.
SEE_ALSO:: array.new_float, array.set, array.push, array.remove, array.pop, array.shift
--- Entry: array.variance ---
NAME:: array.variance
TYPE:: function
DESCRIPTION:: Returns the variance of an array's elements, allowing calculation based on a biased (population, default) or unbiased (sample) estimate.
SEE_ALSO:: array.new_float, array.avg, array.stdev, array.min
--- Entry: barcolor ---
NAME:: barcolor
TYPE:: function
DESCRIPTION:: Sets the color of price bars based on a provided color series or expression.
SEE_ALSO:: bgcolor, plot, fill
--- Entry: bgcolor ---
NAME:: bgcolor
TYPE:: function
DESCRIPTION:: Fills the background of the bars with a specified color.
SEE_ALSO:: barcolor, plot, fill
--- Entry: bool ---
NAME:: bool
TYPE:: function (4 overloads)
DESCRIPTION:: Casts an input value (typically na) to a boolean (bool) type.
SEE_ALSO:: float, int, color, string
--- Entry: box ---
NAME:: box
TYPE:: function
DESCRIPTION:: Casts an input value (typically na) to a box object type.
SEE_ALSO:: float, int, bool, color, string, line, label
--- Entry: box.copy ---
NAME:: box.copy
TYPE:: function
DESCRIPTION:: Creates a clone (copy) of the specified box object and returns the ID of the new box.
SEE_ALSO:: box.new, box.delete
--- Entry: box.delete ---
NAME:: box.delete
TYPE:: function
DESCRIPTION:: Deletes the specified box object. Does nothing if the object is already deleted.
SEE_ALSO:: box.new
--- Entry: box.get_bottom ---
NAME:: box.get_bottom
TYPE:: function
DESCRIPTION:: Returns the price value (Y-coordinate) of the bottom border of the box.
SEE_ALSO:: box.new, box.set_bottom, box.get_left
--- Entry: box.get_left ---
NAME:: box.get_left
TYPE:: function
DESCRIPTION:: Returns the bar index or UNIX time (X-coordinate) of the left border of the box.
SEE_ALSO:: box.new, box.set_left, box.get_right
--- Entry: box.get_right ---
NAME:: box.get_right
TYPE:: function
DESCRIPTION:: Returns the bar index or UNIX time (X-coordinate) of the right border of the box.
SEE_ALSO:: box.new, box.set_right, box.get_left
--- Entry: box.get_top ---
NAME:: box.get_top
TYPE:: function
DESCRIPTION:: Returns the price value (Y-coordinate) of the top border of the box.
SEE_ALSO:: box.new, box.set_top, box.get_bottom
--- Entry: box.new ---
NAME:: box.new
TYPE:: function (2 overloads)
DESCRIPTION:: Creates a new box object, defining its position, colors, borders, and optional text.
SEE_ALSO:: box.delete, box.get_left, box.set_left, box.set_bgcolor
--- Entry: box.set_bgcolor ---
NAME:: box.set_bgcolor
TYPE:: function
DESCRIPTION:: Sets the background color of the specified box object.
SEE_ALSO:: box.new, box.set_border_color
--- Entry: box.set_border_color ---
NAME:: box.set_border_color
TYPE:: function
DESCRIPTION:: Sets the border color of the specified box object.
SEE_ALSO:: box.new, box.set_bgcolor
--- Entry: box.set_border_style ---
NAME:: box.set_border_style
TYPE:: function
DESCRIPTION:: Sets the line style (solid, dotted, or dashed) of the box borders.
SEE_ALSO:: box.new, line.style_solid
--- Entry: box.set_border_width ---
NAME:: box.set_border_width
TYPE:: function
DESCRIPTION:: Sets the width (in pixels) of the borders of the box.
SEE_ALSO:: box.new
--- Entry: box.set_bottom ---
NAME:: box.set_bottom
TYPE:: function
DESCRIPTION:: Sets the price value (Y-coordinate) of the bottom border of the box.
SEE_ALSO:: box.new, box.get_bottom, box.set_top
--- Entry: box.set_bottom_right_point ---
NAME:: box.set_bottom_right_point
TYPE:: function
DESCRIPTION:: Sets the bottom-right corner location of the box using a chart.point object.
SEE_ALSO:: box.new, box.set_top_left_point
--- Entry: box.set_extend ---
NAME:: box.set_extend
TYPE:: function
DESCRIPTION:: Sets the extending type of the box borders (e.g., extend left, right, or both).
SEE_ALSO:: box.new, extend.none, extend.left, extend.right
--- Entry: box.set_left ---
NAME:: box.set_left
TYPE:: function
DESCRIPTION:: Sets the bar index or bar time (X-coordinate) of the left border of the box.
SEE_ALSO:: box.new, box.get_left, box.set_right
--- Entry: box.set_lefttop ---
NAME:: box.set_lefttop
TYPE:: function
DESCRIPTION:: Sets the left (X) and top (Y) coordinates of the box simultaneously.
SEE_ALSO:: box.new, box.get_left, box.get_top
--- Entry: box.set_right ---
NAME:: box.set_right
TYPE:: function
DESCRIPTION:: Sets the bar index or bar time (X-coordinate) of the right border of the box.
SEE_ALSO:: box.new, box.get_right, box.set_left
--- Entry: box.set_rightbottom ---
NAME:: box.set_rightbottom
TYPE:: function
DESCRIPTION:: Sets the right (X) and bottom (Y) coordinates of the box simultaneously.
SEE_ALSO:: box.new, box.get_right, box.get_bottom
--- Entry: box.set_text ---
NAME:: box.set_text
TYPE:: function
DESCRIPTION:: Sets the text string to be displayed inside the box.
SEE_ALSO:: box.set_text_color, box.set_text_size, box.new
--- Entry: box.set_text_color ---
NAME:: box.set_text_color
TYPE:: function
DESCRIPTION:: Sets the color of the text inside the box.
SEE_ALSO:: box.set_text, box.new
--- Entry: box.set_text_font_family ---
NAME:: box.set_text_font_family
TYPE:: function
DESCRIPTION:: Sets the font family of the text inside the box.
SEE_ALSO:: box.new, font.family_default, font.family_monospace
--- Entry: box.set_text_halign ---
NAME:: box.set_text_halign
TYPE:: function
DESCRIPTION:: Sets the horizontal alignment (left, center, or right) of the box's text.
SEE_ALSO:: box.set_text, box.new
--- Entry: box.set_text_size ---
NAME:: box.set_text_size
TYPE:: function
DESCRIPTION:: Sets the size of the text inside the box.
SEE_ALSO:: box.set_text, size.tiny, size.huge, box.new
--- Entry: box.set_text_valign ---
NAME:: box.set_text_valign
TYPE:: function
DESCRIPTION:: Sets the vertical alignment (top, center, or bottom) of the box's text.
SEE_ALSO:: box.set_text, box.new
--- Entry: box.set_text_wrap ---
NAME:: box.set_text_wrap
TYPE:: function
DESCRIPTION:: Sets the mode of wrapping for the text inside the box (auto-wrap or no wrap).
SEE_ALSO:: box.set_text, text.wrap_auto, text.wrap_none, box.new
--- Entry: box.set_top ---
NAME:: box.set_top
TYPE:: function
DESCRIPTION:: Sets the price value (Y-coordinate) of the top border of the box.
SEE_ALSO:: box.new, box.get_top, box.set_bottom
--- Entry: box.set_top_left_point ---
NAME:: box.set_top_left_point
TYPE:: function
DESCRIPTION:: Sets the top-left corner location of the box using a chart.point object.
SEE_ALSO:: box.new, box.set_bottom_right_point
--- Entry: chart.point.copy ---
NAME:: chart.point.copy
TYPE:: function
DESCRIPTION:: Creates a copy of a specified chart.point object and returns the new point.
SEE_ALSO:: chart.point.new, chart.point.from_index
--- Entry: chart.point.from_index ---
NAME:: chart.point.from_index
TYPE:: function
DESCRIPTION:: Creates a chart.point object using a bar index for the X-coordinate and a price for the Y-coordinate.
SEE_ALSO:: chart.point.from_time, chart.point.new, xloc.bar_index
--- Entry: chart.point.from_time ---
NAME:: chart.point.from_time
TYPE:: function
DESCRIPTION:: Creates a chart.point object using a UNIX time value (in milliseconds) for the X-coordinate and a price for the Y-coordinate.
SEE_ALSO:: chart.point.from_index, chart.point.new, xloc.bar_time
--- Entry: chart.point.new ---
NAME:: chart.point.new
TYPE:: function
DESCRIPTION:: Creates a new chart.point object with specified time, index, and price coordinates.
SEE_ALSO:: polyline.new, chart.point.from_index, chart.point.from_time
--- Entry: chart.point.now ---
NAME:: chart.point.now
TYPE:: function
DESCRIPTION:: Creates a chart.point object using the current bar's index and time for the X-coordinates and the specified price for the Y-coordinate.
SEE_ALSO:: chart.point.new, close
--- Entry: color ---
NAME:: color
TYPE:: function (4 overloads)
DESCRIPTION:: Casts an input value (typically na) to a color type.
SEE_ALSO:: float, int, bool, string, color.new
--- Entry: color.b ---
NAME:: color.b
TYPE:: function (4 overloads)
DESCRIPTION:: Retrieves the value (0 to 255) of the blue component of a color.
SEE_ALSO:: color.r, color.g, color.rgb
--- Entry: color.from_gradient ---
NAME:: color.from_gradient
TYPE:: function
DESCRIPTION:: Calculates a color from a linear gradient based on a value's position between a bottom and top value range.
SEE_ALSO:: color.rgb, color.new
--- Entry: color.g ---
NAME:: color.g
TYPE:: function (4 overloads)
DESCRIPTION:: Retrieves the value (0 to 255) of the green component of a color.
SEE_ALSO:: color.r, color.b, color.rgb
--- Entry: color.new ---
NAME:: color.new
TYPE:: function (4 overloads)
DESCRIPTION:: Applies the specified transparency (0 to 100) to a given color.
SEE_ALSO:: color.rgb, color.t
--- Entry: color.r ---
NAME:: color.r
TYPE:: function (4 overloads)
DESCRIPTION:: Retrieves the value (0 to 255) of the red component of a color.
SEE_ALSO:: color.g, color.b, color.rgb
--- Entry: color.rgb ---
NAME:: color.rgb
TYPE:: function (4 overloads)
DESCRIPTION:: Creates a new color with transparency using the Red, Green, Blue (RGB) color model.
SEE_ALSO:: color.new, color.r, color.g, color.b
--- Entry: color.t ---
NAME:: color.t
TYPE:: function (4 overloads)
DESCRIPTION:: Retrieves the color's transparency value (0 to 100).
SEE_ALSO:: color.new, color.rgb
--- Entry: dayofmonth ---
NAME:: dayofmonth
TYPE:: function (2 overloads)
DESCRIPTION:: Returns the day of the month (1-31) for a provided UNIX time, calculated in the exchange's timezone.
SEE_ALSO:: time, year, month, dayofweek, hour
--- Entry: dayofweek ---
NAME:: dayofweek
TYPE:: function (2 overloads)
DESCRIPTION:: Returns the day of the week (1-7, where Sunday is 1) for a provided UNIX time, calculated in the exchange's timezone.
SEE_ALSO:: time, year, month, dayofmonth, hour, dayofweek.monday
--- Entry: fill ---
NAME:: fill
TYPE:: function (3 overloads)
DESCRIPTION:: Fills the background area between two plot lines or two horizontal line (hline) objects with a specified color or gradient.
SEE_ALSO:: plot, barcolor, bgcolor, hline, color.new
--- Entry: fixnan ---
NAME:: fixnan
TYPE:: function (4 overloads)
DESCRIPTION:: Replaces na (Not a Number) values in a series with the immediately preceding non-na value.
SEE_ALSO:: na, nz
--- Entry: float ---
NAME:: float
TYPE:: function (4 overloads)
DESCRIPTION:: Casts an input value (typically na) to a floating-point number (float) type.
SEE_ALSO:: int, bool, color, string
--- Entry: hline ---
NAME:: hline
TYPE:: function
DESCRIPTION:: Renders a fixed, non-moving horizontal line at a specified price level on the chart.
SEE_ALSO:: fill, hline.style_solid
--- Entry: hour ---
NAME:: hour
TYPE:: function (2 overloads)
DESCRIPTION:: Returns the hour (0-23) for a provided UNIX time, calculated in the exchange's timezone.
SEE_ALSO:: time, year, month, dayofmonth, dayofweek, minute
--- Entry: indicator ---
NAME:: indicator
TYPE:: function
DESCRIPTION:: Declaration statement that designates the script as an indicator and configures various display properties and calculation settings.
SEE_ALSO:: strategy, library
--- Entry: input ---
NAME:: input
TYPE:: function (6 overloads)
DESCRIPTION:: Creates an input option in the script's Settings tab, automatically inferring the input widget type from the default value (defval).
SEE_ALSO:: input.bool, input.color, input.int, input.float, input.string
--- Entry: input.bool ---
NAME:: input.bool
TYPE:: function
DESCRIPTION:: Creates a boolean input (a checkmark box) in the script's Settings tab.
SEE_ALSO:: input.int, input.float, input
--- Entry: input.color ---
NAME:: input.color
TYPE:: function
DESCRIPTION:: Creates a color input (a color picker) in the script's Settings tab, allowing selection of color and transparency.
SEE_ALSO:: input.bool, input.float, input
--- Entry: input.enum ---
NAME:: input.enum
TYPE:: function
DESCRIPTION:: Creates a dropdown input with options based on fields from an enum declaration.
SEE_ALSO:: input.bool, input.string, input
--- Entry: input.float ---
NAME:: input.float
TYPE:: function (2 overloads)
DESCRIPTION:: Creates a floating-point number input field in the script's Settings tab.
SEE_ALSO:: input.int, input.bool, input
--- Entry: input.int ---
NAME:: input.int
TYPE:: function (2 overloads)
DESCRIPTION:: Creates an integer number input field in the script's Settings tab.
SEE_ALSO:: input.float, input.bool, input
--- Entry: input.price ---
NAME:: input.price
TYPE:: function
DESCRIPTION:: Creates a price input field, optionally enabling interactive mode for selection directly on the chart.
SEE_ALSO:: input.float, input.time, input
--- Entry: input.session ---
NAME:: input.session
TYPE:: function
DESCRIPTION:: Creates a pair of dropdowns that allow the user to specify the start and end of a session, returning the result as a session string.
SEE_ALSO:: input.timeframe, time, input
--- Entry: input.source ---
NAME:: input.source
TYPE:: function
DESCRIPTION:: Creates a dropdown input that allows the user to select a data series (e.g., close, hl2) or the output of another indicator as the calculation source.
SEE_ALSO:: input.bool, input.float, input
--- Entry: input.string ---
NAME:: input.string
TYPE:: function
DESCRIPTION:: Creates a single-line text field input in the script's Settings tab, which accepts a string value.
SEE_ALSO:: input.text_area, input.int, input
--- Entry: input.symbol ---
NAME:: input.symbol
TYPE:: function
DESCRIPTION:: Creates an input field that allows the user to search and select a specific trading symbol (e.g., "NASDAQ:GOOGL"), which is returned as a string.
SEE_ALSO:: input.timeframe, input.string, request.security
--- Entry: input.text_area ---
NAME:: input.text_area
TYPE:: function
DESCRIPTION:: Creates a multi-line text input field (text box) in the script's Settings tab.
SEE_ALSO:: input.string, input.bool, input
--- Entry: input.time ---
NAME:: input.time
TYPE:: function
DESCRIPTION:: Creates date and time input widgets, which return a UNIX timestamp, with an option for interactive selection on the chart.
SEE_ALSO:: input.price, input.session, input
--- Entry: input.timeframe ---
NAME:: input.timeframe
TYPE:: function
DESCRIPTION:: Creates a dropdown input that allows the user to select a specific chart timeframe (e.g., 'D', 'W') and returns it as a string.
SEE_ALSO:: input.symbol, request.security, input
--- Entry: int ---
NAME:: int
TYPE:: function (4 overloads)
DESCRIPTION:: Casts an input value (typically na) to an integer (int) type by truncating any decimal part.
SEE_ALSO:: float, bool, color, string
--- Entry: label ---
NAME:: label
TYPE:: function
DESCRIPTION:: Casts an input value (typically na) to a label object type.
SEE_ALSO:: float, int, bool, color, string, line
--- Entry: label.copy ---
NAME:: label.copy
TYPE:: function
DESCRIPTION:: Creates a clone (copy) of the specified label object and returns the ID of the new label.
SEE_ALSO:: label.new, label.delete
--- Entry: label.delete ---
NAME:: label.delete
TYPE:: function
DESCRIPTION:: Deletes the specified label object. Does nothing if the object is already deleted.
SEE_ALSO:: label.new
--- Entry: label.get_text ---
NAME:: label.get_text
TYPE:: function
DESCRIPTION:: Returns the text string currently displayed by the label object.
SEE_ALSO:: label.new, label.set_text
--- Entry: label.get_x ---
NAME:: label.get_x
TYPE:: function
DESCRIPTION:: Returns the X-coordinate (UNIX time or bar index, depending on xloc) of the label's position.
SEE_ALSO:: label.new, label.set_x, label.get_y
--- Entry: label.get_y ---
NAME:: label.get_y
TYPE:: function
DESCRIPTION:: Returns the Y-coordinate (price value) of the label's position.
SEE_ALSO:: label.new, label.set_y, label.get_x
--- Entry: label.new ---
NAME:: label.new
TYPE:: function (2 overloads)
DESCRIPTION:: Creates a new label object on the chart with specified coordinates, text, and visual style.
SEE_ALSO:: label.delete, label.set_xy, label.style_circle
--- Entry: label.set_color ---
NAME:: label.set_color
TYPE:: function
DESCRIPTION:: Sets the color of the label's border and arrow/background.
SEE_ALSO:: label.new, label.set_textcolor
--- Entry: label.set_point ---
NAME:: label.set_point
TYPE:: function
DESCRIPTION:: Sets the location of the label using a chart.point object.
SEE_ALSO:: label.new, chart.point.new
--- Entry: label.set_size ---
NAME:: label.set_size
TYPE:: function
DESCRIPTION:: Sets the size of the label's arrow and text.
SEE_ALSO:: label.new, size.large, size.small
--- Entry: label.set_style ---
NAME:: label.set_style
TYPE:: function
DESCRIPTION:: Sets the style (shape) of the label object.
SEE_ALSO:: label.new, label.style_label_up, label.style_arrowdown
--- Entry: label.set_text ---
NAME:: label.set_text
TYPE:: function
DESCRIPTION:: Sets the text content displayed by the label.
SEE_ALSO:: label.new, label.get_text
--- Entry: label.set_text_font_family ---
NAME:: label.set_text_font_family
TYPE:: function
DESCRIPTION:: Sets the font family for the text inside the label (e.g., default or monospace).
SEE_ALSO:: label.new, font.family_monospace
--- Entry: label.set_textalign ---
NAME:: label.set_textalign
TYPE:: function
DESCRIPTION:: Sets the horizontal alignment (left, center, or right) for the label text.
SEE_ALSO:: label.new, text.align_center
--- Entry: label.set_textcolor ---
NAME:: label.set_textcolor
TYPE:: function
DESCRIPTION:: Sets the color of the text displayed inside the label.
SEE_ALSO:: label.new, label.set_color
--- Entry: label.set_tooltip ---
NAME:: label.set_tooltip
TYPE:: function
DESCRIPTION:: Sets the tooltip text that appears when the user hovers over the label on the chart.
SEE_ALSO:: label.new
--- Entry: label.set_x ---
NAME:: label.set_x
TYPE:: function
DESCRIPTION:: Sets the X-coordinate (bar index or time) of the label's position.
SEE_ALSO:: label.new, label.set_xy, label.set_xloc
--- Entry: label.set_xloc ---
NAME:: label.set_xloc
TYPE:: function
DESCRIPTION:: Sets the X-coordinate value and specifies whether it should be interpreted as a bar index or a time value.
SEE_ALSO:: label.new, xloc.bar_index, xloc.bar_time
--- Entry: label.set_xy ---
NAME:: label.set_xy
TYPE:: function
DESCRIPTION:: Sets both the X-coordinate (bar index/time) and Y-coordinate (price) of the label's position simultaneously.
SEE_ALSO:: label.new, label.set_x, label.set_y
--- Entry: label.set_y ---
NAME:: label.set_y
TYPE:: function
DESCRIPTION:: Sets the Y-coordinate (price value) of the label's position.
SEE_ALSO:: label.new, label.set_xy, label.set_yloc
--- Entry: label.set_yloc ---
NAME:: label.set_yloc
TYPE:: function
DESCRIPTION:: Sets the Y-location calculation algorithm, determining how the y coordinate is interpreted (yloc.price, yloc.abovebar, yloc.belowbar).
SEE_ALSO:: label.new, yloc.price, yloc.abovebar
--- Entry: library ---
NAME:: library
TYPE:: declaration statement
DESCRIPTION:: Identifies a script as a library, making its exported functions available for import and reuse in other scripts.
SEE_ALSO:: indicator, strategy
--- Entry: line ---
NAME:: line
TYPE:: function
DESCRIPTION:: Casts an input value (typically na) to a line object type.
SEE_ALSO:: float, int, bool, color, string, label
--- Entry: line.copy ---
NAME:: line.copy
TYPE:: function
DESCRIPTION:: Creates a clone (copy) of the specified line object and returns the ID of the new line.
SEE_ALSO:: line.new, line.delete
--- Entry: line.delete ---
NAME:: line.delete
TYPE:: function
DESCRIPTION:: Deletes the specified line object. Does nothing if the object is already deleted.
SEE_ALSO:: line.new
--- Entry: line.get_price ---
NAME:: line.get_price
TYPE:: function
DESCRIPTION:: Returns the calculated price level of the line object at a specific bar index.
SEE_ALSO:: line.new, line.get_x1, line.get_y1
--- Entry: line.get_x1 ---
NAME:: line.get_x1
TYPE:: function
DESCRIPTION:: Returns the X-coordinate (UNIX time or bar index) of the first point of the line.
SEE_ALSO:: line.new, line.get_x2
--- Entry: line.get_x2 ---
NAME:: line.get_x2
TYPE:: function
DESCRIPTION:: Returns the X-coordinate (UNIX time or bar index) of the second point of the line.
SEE_ALSO:: line.new, line.get_x1
--- Entry: line.get_y1 ---
NAME:: line.get_y1
TYPE:: function
DESCRIPTION:: Returns the price value (Y-coordinate) of the first point of the line.
SEE_ALSO:: line.new, line.get_y2
--- Entry: line.get_y2 ---
NAME:: line.get_y2
TYPE:: function
DESCRIPTION:: Returns the price value (Y-coordinate) of the second point of the line.
SEE_ALSO:: line.new, line.get_y1
--- Entry: line.new ---
NAME:: line.new
TYPE:: function (2 overloads)
DESCRIPTION:: Creates a new line object on the chart, defined by two points and various style parameters (color, width, extension).
SEE_ALSO:: line.delete, line.copy, line.get_price
--- Entry: line.set_color ---
NAME:: line.set_color
TYPE:: function
DESCRIPTION:: Sets the color of the specified line object.
SEE_ALSO:: line.new, line.set_style
--- Entry: line.set_extend ---
NAME:: line.set_extend
TYPE:: function
DESCRIPTION:: Sets how the line object should extend beyond its endpoints (extend.none, extend.right, extend.left, or extend.both).
SEE_ALSO:: line.new, extend.none, extend.both
--- Entry: line.set_first_point ---
NAME:: line.set_first_point
TYPE:: function
DESCRIPTION:: Sets the coordinates of the first point of the line object using a chart.point object.
SEE_ALSO:: line.new, line.set_second_point, chart.point.new
--- Entry: line.set_second_point ---
NAME:: line.set_second_point
TYPE:: function
DESCRIPTION:: Sets the coordinates of the second point of the line object using a chart.point object.
SEE_ALSO:: line.new, line.set_first_point, chart.point.new
--- Entry: line.set_style ---
NAME:: line.set_style
TYPE:: function
DESCRIPTION:: Sets the style (e.g., solid, dotted, dashed, arrowed) of the line object.
SEE_ALSO:: line.new, line.style_solid, line.style_arrow_left
--- Entry: line.set_width ---
NAME:: line.set_width
TYPE:: function
DESCRIPTION:: Sets the width (in pixels) of the line object.
SEE_ALSO:: line.new
--- Entry: line.set_x1 ---
NAME:: line.set_x1
TYPE:: function
DESCRIPTION:: Sets the X-coordinate (bar index or time) of the first point of the line.
SEE_ALSO:: line.new, line.set_y1, line.set_xy1
--- Entry: line.set_x2 ---
NAME:: line.set_x2
TYPE:: function
DESCRIPTION:: Sets the X-coordinate (bar index or time) of the second point of the line.
SEE_ALSO:: line.new, line.set_y2, line.set_xy2
--- Entry: line.set_xloc ---
NAME:: line.set_xloc
TYPE:: function
DESCRIPTION:: Sets both the X-coordinates (for point 1 and point 2) and the X-location mode (xloc.bar_index or xloc.bar_time) for the line object.
SEE_ALSO:: line.new, xloc.bar_index, xloc.bar_time
--- Entry: line.set_xy1 ---
NAME:: line.set_xy1
TYPE:: function
DESCRIPTION:: Sets both the X-coordinate and Y-coordinate (price) of the first point of the line.
SEE_ALSO:: line.new, line.set_x1, line.set_y1
--- Entry: line.set_xy2 ---
NAME:: line.set_xy2
TYPE:: function
DESCRIPTION:: Sets both the X-coordinate and Y-coordinate (price) of the second point of the line.
SEE_ALSO:: line.new, line.set_x2, line.set_y2
--- Entry: line.set_y1 ---
NAME:: line.set_y1
TYPE:: function
DESCRIPTION:: Sets the price value (Y-coordinate) of the first point of the line.
SEE_ALSO:: line.new, line.set_x1, line.set_xy1
--- Entry: line.set_y2 ---
NAME:: line.set_y2
TYPE:: function
DESCRIPTION:: Sets the price value (Y-coordinate) of the second point of the line.
SEE_ALSO:: line.new, line.set_x2, line.set_xy2
--- Entry: linefill ---
NAME:: linefill
TYPE:: function
DESCRIPTION:: Casts an input value (typically na) to a linefill object type.
SEE_ALSO:: float, int, line, linefill.new
--- Entry: linefill.delete ---
NAME:: linefill.delete
TYPE:: function
DESCRIPTION:: Deletes the specified linefill object.
SEE_ALSO:: linefill.new
--- Entry: linefill.get_line1 ---
NAME:: linefill.get_line1
TYPE:: function
DESCRIPTION:: Returns the ID of the first line object used to create the area fill.
SEE_ALSO:: linefill.new, linefill.get_line2, line.get_y1
--- Entry: linefill.get_line2 ---
NAME:: linefill.get_line2
TYPE:: function
DESCRIPTION:: Returns the ID of the second line object used to create the area fill.
SEE_ALSO:: linefill.new, linefill.get_line1, line.get_y2
--- Entry: linefill.new ---
NAME:: linefill.new
TYPE:: function
DESCRIPTION:: Creates a new area fill object, coloring the space between two existing line objects.
SEE_ALSO:: linefill.delete, linefill.set_color, line.new
--- Entry: linefill.set_color ---
NAME:: linefill.set_color
TYPE:: function
DESCRIPTION:: Sets the color of the linefill object.
SEE_ALSO:: linefill.new, color.new
--- Entry: log.error ---
NAME:: log.error
TYPE:: function (2 overloads)
DESCRIPTION:: Sends a formatted string message with an "error" debug level to the "Pine logs" menu for debugging and monitoring script issues.
SEE_ALSO:: log.info, log.warning, str.format
--- Entry: log.info ---
NAME:: log.info
TYPE:: function (2 overloads)
DESCRIPTION:: Sends a formatted string message with an "info" debug level to the "Pine logs" menu for general script status and tracing.
SEE_ALSO:: log.error, log.warning, str.format
--- Entry: log.warning ---
NAME:: log.warning
TYPE:: function (2 overloads)
DESCRIPTION:: Sends a formatted string message with a "warning" debug level to the "Pine logs" menu for non-critical, yet notable, script events.
SEE_ALSO:: log.error, log.info, str.format
--- Entry: map.clear ---
NAME:: map.clear
TYPE:: function
DESCRIPTION:: Removes all key-value pairs from the specified map object, resetting it to an empty state.
SEE_ALSO:: map.new, map.size, map.remove
--- Entry: map.contains ---
NAME:: map.contains
TYPE:: function
DESCRIPTION:: Checks if a specific key exists within the map object and returns true or false.
SEE_ALSO:: map.new, map.get, map.keys
--- Entry: map.copy ---
NAME:: map.copy
TYPE:: function
DESCRIPTION:: Creates and returns an independent copy (clone) of an existing map object.
SEE_ALSO:: map.new, map.put, map.get
--- Entry: map.get ---
NAME:: map.get
TYPE:: function
DESCRIPTION:: Retrieves the value associated with a specified key in the map object.
SEE_ALSO:: map.new, map.put, map.contains
--- Entry: map.keys ---
NAME:: map.keys
TYPE:: function
DESCRIPTION:: Returns an array containing all the keys present in the map, in insertion order.
SEE_ALSO:: map.new, map.values, array.new
--- Entry: map.new<type,type> ---
NAME:: map.new<keyType, valueType>
TYPE:: function
DESCRIPTION:: Creates and returns a new map object (a collection of unique key-value pairs) with specified types for its keys and values.
SEE_ALSO:: map.put, map.get, array.new
--- Entry: map.put ---
NAME:: map.put
TYPE:: function
DESCRIPTION:: Inserts a new key-value pair into the map. If the key already exists, the old value is replaced, and the previous value is returned.
SEE_ALSO:: map.new, map.put_all, map.remove
--- Entry: map.put_all ---
NAME:: map.put_all
TYPE:: function
DESCRIPTION:: Copies all key-value pairs from one map (id2) into another map (id).
SEE_ALSO:: map.new, map.put, map.copy
--- Entry: map.remove ---
NAME:: map.remove
TYPE:: function
DESCRIPTION:: Deletes a key-value pair from the map based on the provided key and returns the value that was removed, or na if the key wasn't found.
SEE_ALSO:: map.new, map.put, map.clear
--- Entry: map.size ---
NAME:: map.size
TYPE:: function
DESCRIPTION:: Returns the total number of key-value pairs currently stored in the map.
SEE_ALSO:: map.new, map.keys, map.values
--- Entry: map.values ---
NAME:: map.values
TYPE:: function
DESCRIPTION:: Returns an array containing all the values present in the map, in insertion order.
SEE_ALSO:: map.new, map.keys, array.new
--- Entry: math.abs ---
NAME:: math.abs
TYPE:: function (8 overloads)
DESCRIPTION:: Calculates the absolute value of a number (i.e., the non-negative distance from zero).
SEE_ALSO:: math.sign
--- Entry: math.acos ---
NAME:: math.acos
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the principal value of the arc cosine (inverse cosine) of a number, in radians.
SEE_ALSO:: math.cos, math.asin
--- Entry: math.asin ---
NAME:: math.asin
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the principal value of the arc sine (inverse sine) of a number, in radians.
SEE_ALSO:: math.sin, math.acos
--- Entry: math.atan ---
NAME:: math.atan
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the principal value of the arc tangent (inverse tangent) of a number, in radians.
SEE_ALSO:: math.tan
--- Entry: math.avg ---
NAME:: math.avg
TYPE:: function (2 overloads)
DESCRIPTION:: Calculates the average (arithmetic mean) of a sequence of numbers (element-wise for series).
SEE_ALSO:: math.sum, ta.sma
--- Entry: math.ceil ---
NAME:: math.ceil
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the smallest integer that is greater than or equal to the given number (rounds up).
SEE_ALSO:: math.floor, math.round
--- Entry: math.cos ---
NAME:: math.cos
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the trigonometric cosine of an angle measured in radians.
SEE_ALSO:: math.acos, math.sin
--- Entry: math.exp ---
NAME:: math.exp
TYPE:: function (4 overloads)
DESCRIPTION:: Calculates the value of Euler's number (e) raised to the power of the given number (e
x
).
SEE_ALSO:: math.pow, math.log
--- Entry: math.floor ---
NAME:: math.floor
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the largest integer that is less than or equal to the given number (rounds down).
SEE_ALSO:: math.ceil, math.round
--- Entry: math.log ---
NAME:: math.log
TYPE:: function (4 overloads)
DESCRIPTION:: Calculates the natural logarithm (base e) of a number.
SEE_ALSO:: math.log10, math.exp
--- Entry: math.log10 ---
NAME:: math.log10
TYPE:: function (4 overloads)
DESCRIPTION:: Calculates the common logarithm (base 10) of a number.
SEE_ALSO:: math.log
--- Entry: math.max ---
NAME:: math.max
TYPE:: function (8 overloads)
DESCRIPTION:: Returns the greatest (largest) value among the provided arguments.
SEE_ALSO:: math.min
--- Entry: math.min ---
NAME:: math.min
TYPE:: function (8 overloads)
DESCRIPTION:: Returns the smallest value among the provided arguments.
SEE_ALSO:: math.max
--- Entry: math.pow ---
NAME:: math.pow
TYPE:: function (4 overloads)
DESCRIPTION:: Calculates the mathematical power of a base raised to an exponent (base
exponent
).
SEE_ALSO:: math.sqrt, math.exp
--- Entry: math.random ---
NAME:: math.random
TYPE:: function
DESCRIPTION:: Generates a pseudo-random floating-point value within a specified range. A seed can be used for repeatable sequences.
SEE_ALSO:: math.round
--- Entry: math.round ---
NAME:: math.round
TYPE:: function (8 overloads)
DESCRIPTION:: Rounds a number to the nearest integer (ties round up) or to a specified number of decimal places.
SEE_ALSO:: math.ceil, math.floor
--- Entry: math.round_to_mintick ---
NAME:: math.round_to_mintick
TYPE:: function (2 overloads)
DESCRIPTION:: Rounds a number to the nearest value that is a multiple of the symbol's minimum tick size (syminfo.mintick).
SEE_ALSO:: math.round, syminfo.mintick
--- Entry: math.sign ---
NAME:: math.sign
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the sign of a number: 1.0 for positive, -1.0 for negative, and 0.0 for zero.
SEE_ALSO:: math.abs
--- Entry: math.sin ---
NAME:: math.sin
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the trigonometric sine of an angle measured in radians.
SEE_ALSO:: math.asin, math.cos
--- Entry: math.sqrt ---
NAME:: math.sqrt
TYPE:: function (4 overloads)
DESCRIPTION:: Calculates the square root of a non-negative number.
SEE_ALSO:: math.pow
--- Entry: math.sum ---
NAME:: math.sum
TYPE:: function
DESCRIPTION:: Calculates the sum of the last length number of non-na values in the source series.
SEE_ALSO:: math.avg, ta.cum
--- Entry: math.tan ---
NAME:: math.tan
TYPE:: function (4 overloads)
DESCRIPTION:: Returns the trigonometric tangent of an angle measured in radians.
SEE_ALSO:: math.atan, math.sin
--- Entry: math.todegrees ---
NAME:: math.todegrees
TYPE:: function
DESCRIPTION:: Converts an angle value from radians to degrees.
SEE_ALSO:: math.toradians
--- Entry: math.toradians ---
NAME:: math.toradians
TYPE:: function
DESCRIPTION:: Converts an angle value from degrees to radians.
SEE_ALSO:: math.todegrees
--- Entry: max_bars_back ---
NAME:: max_bars_back
TYPE:: function
DESCRIPTION:: Manually sets the maximum history buffer size for a series variable. This is critical for avoiding runtime errors when referencing historical values using a non-constant lookback (e.g., v[i] where i changes).
SEE_ALSO:: indicator, strategy
--- Entry: minute ---
NAME:: minute
TYPE:: function (2 overloads)
DESCRIPTION:: Returns the minute (0-59) component of a given UNIX time, based on the exchange's timezone.
SEE_ALSO:: time, hour, second, month
--- Entry: month ---
NAME:: month
TYPE:: function (2 overloads)
DESCRIPTION:: Returns the month (1-12) component of a given UNIX time, based on the exchange's timezone.
SEE_ALSO:: time, year, dayofmonth, hour
--- Entry: na ---
NAME:: na
TYPE:: function (2 overloads)
DESCRIPTION:: Tests if a value is Not a Number (na) and returns true if it is, and false otherwise.
SEE_ALSO:: nz, fixnan
--- Entry: nz ---
NAME:: nz
TYPE:: function (16 overloads)
DESCRIPTION:: Replaces an na value in a series with zero (0) or a specified replacement value.
SEE_ALSO:: na, fixnan
--- Entry: plot ---
NAME:: plot
TYPE:: function
DESCRIPTION:: Plots a line, step line, area, histogram, or other shape using a single series of data on the chart.
SEE_ALSO:: plotshape, plotarrow, fill
--- Entry: plotarrow ---
NAME:: plotarrow
TYPE:: function
DESCRIPTION:: Plots up and down arrows on the chart, with height corresponding to the absolute value of the input series.
SEE_ALSO:: plot, plotshape, barcolor
--- Entry: plotbar ---
NAME:: plotbar
TYPE:: function
DESCRIPTION:: Plots custom OHLC bars (similar to the chart's native bars but based on custom series) on the chart.
SEE_ALSO:: plotcandle
--- Entry: plotcandle ---
NAME:: plotcandle
TYPE:: function
DESCRIPTION:: Plots custom candlesticks (based on custom OHLC series) on the chart, allowing control over body and wick colors.
SEE_ALSO:: plotbar
--- Entry: plotchar ---
NAME:: plotchar
TYPE:: function
DESCRIPTION:: Plots a single Unicode character (like σ or α) as a shape on the chart at specific points.
SEE_ALSO:: plot, plotshape
--- Entry: plotshape ---
NAME:: plotshape
TYPE:: function
DESCRIPTION:: Plots built-in visual shapes (like a triangle, cross, or circle) on the chart at specific points.
SEE_ALSO:: plot, plotchar
--- Entry: polyline.delete ---
NAME:: polyline.delete
TYPE:: function
DESCRIPTION:: Deletes the specified polyline drawing object from the chart.
SEE_ALSO:: polyline.new
--- Entry: polyline.new ---
NAME:: polyline.new
TYPE:: function
DESCRIPTION:: Creates a new drawing object by sequentially connecting an array of points (chart.point objects) with lines, which can be straight or curved.
SEE_ALSO:: polyline.delete, chart.point.new
--- Entry: request.currency_rate ---
NAME:: request.currency_rate
TYPE:: function
DESCRIPTION:: Retrieves a daily foreign exchange rate to convert a value between two specified currencies.
SEE_ALSO:: syminfo.currency, currency.USD
--- Entry: request.dividends ---
NAME:: request.dividends
TYPE:: function
DESCRIPTION:: Requests dividend data (gross or net) for a specified stock symbol, with options for data merge strategy, lookahead, and currency conversion. Essential for fundamental analysis for investors.
SEE_ALSO:: request.earnings, request.splits, request.security
--- Entry: request.earnings ---
NAME:: request.earnings
TYPE:: function
DESCRIPTION:: Requests earnings data (actual, estimate, or standardized) for a specified stock symbol, including options for data merge strategy, lookahead, and currency conversion.
SEE_ALSO:: request.dividends, request.splits, request.security
--- Entry: request.economic ---
NAME:: request.economic
TYPE:: function
DESCRIPTION:: Requests data for an economic metric (e.g., GDP, inflation) associated with a specific country or region code.
SEE_ALSO:: request.financial, request.quandl
--- Entry: request.financial ---
NAME:: request.financial
TYPE:: function
DESCRIPTION:: Requests detailed financial statement data (e.g., net income, accounts payable) for a symbol based on a specified reporting period (e.g., FY, FQ, TTM).
SEE_ALSO:: request.security, syminfo.tickerid
--- Entry: request.quandl ---
NAME:: request.quandl
TYPE:: function
DESCRIPTION:: Requests data from Nasdaq Data Link (formerly Quandl) for specialized external time series datasets.
SEE_ALSO:: request.security
--- Entry: request.security ---
NAME:: request.security
TYPE:: function
DESCRIPTION:: The primary function for requesting the result of a Pine Script expression calculated from a different symbol, timeframe, or both. Crucial for multi-timeframe analysis.
SEE_ALSO:: ticker.modify, request.security_lower_tf
--- Entry: request.security_lower_tf ---
NAME:: request.security_lower_tf
TYPE:: function
DESCRIPTION:: Requests expression results from a lower or equal timeframe and returns the results for the chart bar's duration as an array.
SEE_ALSO:: request.security
--- Entry: request.seed ---
NAME:: request.seed
TYPE:: function
DESCRIPTION:: Requests custom, user-maintained data from a specified GitHub repository (CSV data source), returning the results as a series.
SEE_ALSO:: request.security
--- Entry: request.splits ---
NAME:: request.splits
TYPE:: function
DESCRIPTION:: Requests stock split data (denominator or numerator of the split) for a specified stock symbol.
SEE_ALSO:: request.earnings, request.dividends, request.security
--- Entry: runtime.error ---
NAME:: runtime.error
TYPE:: function
DESCRIPTION:: Immediately halts script execution at the point of call and generates a runtime error with a custom message. Useful for debugging and enforcing constraints.
--- Entry: second ---
NAME:: second
TYPE:: function (2 overloads)
DESCRIPTION:: Returns the second (0-59) component of a given UNIX time, based on the exchange's timezone.
SEE_ALSO:: time, hour, minute
--- Entry: str.contains ---
NAME:: str.contains
TYPE:: function (3 overloads)
DESCRIPTION:: Checks if a substring (str) is present within a larger source string and returns a boolean (true/false). Useful for identifying asset types like continuous futures tickers (e.g., checks for !).
SEE_ALSO:: str.pos, str.match
--- Entry: str.endswith ---
NAME:: str.endswith
TYPE:: function (3 overloads)
DESCRIPTION:: Checks if the source string concludes with the specified substring and returns a boolean (true/false).
SEE_ALSO:: str.startswith
--- Entry: str.format ---
NAME:: str.format
TYPE:: function (2 overloads)
DESCRIPTION:: Creates a formatted string by replacing placeholders (e.g., {0}, {1}) with specified values, allowing for custom formatting of numbers (decimals, currency, percentage).
SEE_ALSO:: str.tostring
--- Entry: str.format_time ---
NAME:: str.format_time
TYPE:: function
DESCRIPTION:: Converts a UNIX time timestamp into a human-readable date/time string based on a specified format and timezone.
SEE_ALSO:: str.format, time
--- Entry: str.length ---
NAME:: str.length
TYPE:: function (3 overloads)
DESCRIPTION:: Returns the total number of characters (an integer) in a given string.
SEE_ALSO:: str.substring
--- Entry: str.lower ---
NAME:: str.lower
TYPE:: function (3 overloads)
DESCRIPTION:: Returns a new string with all alphabetic characters converted to lowercase.
SEE_ALSO:: str.upper
--- Entry: str.match ---
NAME:: str.match
TYPE:: function (2 overloads)
DESCRIPTION:: Searches a source string for a pattern defined by a regular expression (regex) and returns the first matching substring, or an empty string if none is found.
SEE_ALSO:: str.contains, str.substring
--- Entry: str.pos ---
NAME:: str.pos
TYPE:: function (3 overloads)
DESCRIPTION:: Returns the starting index position (0-based) of the first occurrence of a substring within a source string, or na if not found.
SEE_ALSO:: str.contains, str.substring
--- Entry: str.repeat ---
NAME:: str.repeat
TYPE:: function (4 overloads)
DESCRIPTION:: Constructs a new string by repeating the source string a specified number of times, optionally inserting a separator between each instance.
SEE_ALSO:: str.length
--- Entry: str.replace ---
NAME:: str.replace
TYPE:: function (3 overloads)
DESCRIPTION:: Returns a new string where the Nth occurrence (occurrence index) of a target string is replaced by a replacement string.
SEE_ALSO:: str.replace_all
--- Entry: str.replace_all ---
NAME:: str.replace_all
TYPE:: function (2 overloads)
DESCRIPTION:: Returns a new string where every occurrence of a target string is replaced by a replacement string.
SEE_ALSO:: str.replace
--- Entry: str.split ---
NAME:: str.split
TYPE:: function
DESCRIPTION:: Divides a string into an array of substrings based on a specified separator string.
SEE_ALSO:: array.new, str.substring
--- Entry: str.startswith ---
NAME:: str.startswith
TYPE:: function (3 overloads)
DESCRIPTION:: Checks if the source string begins with the specified substring and returns a boolean (true/false).
SEE_ALSO:: str.endswith
--- Entry: str.substring ---
NAME:: str.substring
TYPE:: function (6 overloads)
DESCRIPTION:: Extracts and returns a portion of a string based on an inclusive beginning position and an optional exclusive end position.
SEE_ALSO:: str.pos, str.length
--- Entry: str.tonumber ---
NAME:: str.tonumber
TYPE:: function (4 overloads)
DESCRIPTION:: Converts a value represented as a string into its numerical float equivalent, or na if conversion fails.
SEE_ALSO:: str.tostring
--- Entry: str.tostring ---
NAME:: str.tostring
TYPE:: function (4 overloads)
DESCRIPTION:: Converts a numerical value (int or float) into its string representation, with options for custom formatting (e.g., volume, mintick).
SEE_ALSO:: str.tonumber, str.format
--- Entry: str.trim ---
NAME:: str.trim
TYPE:: function (4 overloads)
DESCRIPTION:: Removes all leading and trailing whitespace and control characters (e.g., \n, \t) from a string.
SEE_ALSO:: str.lower
--- Entry: str.upper ---
NAME:: str.upper
TYPE:: function (3 overloads)
DESCRIPTION:: Returns a new string with all alphabetic characters converted to uppercase.
SEE_ALSO:: str.lower
--- Entry: strategy ---
NAME:: strategy
TYPE:: declaration statement
DESCRIPTION:: The mandatory declaration statement that designates a script as a strategy and sets the global properties for backtesting. This includes parameters for order size (default_qty_value), risk control (pyramiding, margin_long, margin_short), backtest realism (slippage, commission), and calculation mode (calc_on_every_tick).
REMARKS:: Only one strategy() call is allowed per script. As a day trader, pay close attention to calc_on_every_tick (real-time vs. close-only calculations) and slippage/commission for accurate futures backtesting.
SEE_ALSO:: indicator, library
--- Entry: strategy.cancel ---
NAME:: strategy.cancel
TYPE:: function
DESCRIPTION:: Cancels a single pending or unfilled price-based order (like a limit order) using its specific string identifier (id).
SEE_ALSO:: strategy.cancel_all
--- Entry: strategy.cancel_all ---
NAME:: strategy.cancel_all
TYPE:: function
DESCRIPTION:: Cancels all pending or unfilled orders regardless of their identifiers. Useful for quickly flattening your order book when conditions change.
SEE_ALSO:: strategy.cancel
--- Entry: strategy.close ---
NAME:: strategy.close
TYPE:: function
DESCRIPTION:: Creates a market order to close (or partially close via qty or qty_percent) a position that was opened by entry orders with a specific entry identifier (id).
SEE_ALSO:: strategy.exit, strategy.entry
--- Entry: strategy.cancel_all ---
NAME:: strategy.cancel_all
TYPE:: function
DESCRIPTION:: Cancels all pending or unfilled orders (regardless of their ID), providing a quick way to flatten the order book. Most effective for price-based orders like limits.
SEE_ALSO:: strategy.cancel
--- Entry: strategy.close ---
NAME:: strategy.close
TYPE:: function
DESCRIPTION:: Generates a market order to exit a position, or a portion of a position, based on a specific entry identifier (id). Allows for partial exits using qty or qty_percent.
SEE_ALSO:: strategy.exit, strategy.entry
--- Entry: strategy.close_all ---
NAME:: strategy.close_all
TYPE:: function (2 overloads)
DESCRIPTION:: Generates a market order to close the entire open position completely, regardless of which entry orders built that position.
SEE_ALSO:: strategy.close, strategy.exit
--- Entry: strategy.closedtrades.commission ---
NAME:: strategy.closedtrades.commission
TYPE:: function
DESCRIPTION:: Returns the total commission paid (entry + exit fees) for a specified closed trade number (trade_num), expressed in the strategy's account currency.
SEE_ALSO:: strategy.closedtrades.profit, strategy.opentrades.commission
--- Entry: strategy.closedtrades.entry_bar_index ---
NAME:: strategy.closedtrades.entry_bar_index
TYPE:: function
DESCRIPTION:: Returns the bar index at which the specified closed trade was entered. Useful for calculating hold time in bars.
SEE_ALSO:: strategy.closedtrades.exit_bar_index, bar_index
--- Entry: strategy.closedtrades.entry_comment ---
NAME:: strategy.closedtrades.entry_comment
TYPE:: function
DESCRIPTION:: Returns the comment string that was associated with the entry order of the specified closed trade.
SEE_ALSO:: strategy.closedtrades.exit_comment, strategy.entry
--- Entry: strategy.closedtrades.entry_id ---
NAME:: strategy.closedtrades.entry_id
TYPE:: function
DESCRIPTION:: Returns the string ID of the entry order that opened the specified closed trade.
SEE_ALSO:: strategy.closedtrades.exit_id, strategy.entry
--- Entry: strategy.closedtrades.entry_price ---
NAME:: strategy.closedtrades.entry_price
TYPE:: function
DESCRIPTION:: Returns the actual fill price at which the specified closed trade was entered. Crucial for calculating per-trade P&L.
SEE_ALSO:: strategy.closedtrades.exit_price, strategy.closedtrades.entry_time
--- Entry: strategy.closedtrades.entry_time ---
NAME:: strategy.closedtrades.entry_time
TYPE:: function
DESCRIPTION:: Returns the UNIX timestamp (in milliseconds) for when the specified closed trade was entered. Useful for measuring exact trade duration.
SEE_ALSO:: strategy.closedtrades.exit_time, time
--- Entry: strategy.closedtrades.exit_bar_index ---
NAME:: strategy.closedtrades.exit_bar_index
TYPE:: function
DESCRIPTION:: Returns the bar index at which the specified closed trade was exited.
SEE_ALSO:: strategy.closedtrades.entry_bar_index, bar_index
--- Entry: strategy.closedtrades.exit_comment ---
NAME:: strategy.closedtrades.exit_comment
TYPE:: function
DESCRIPTION:: Returns the optional comment string (e.g., "SL," "TP") associated with the exit order of the specified closed trade.
SEE_ALSO:: strategy.closedtrades.entry_comment, strategy.exit
--- Entry: strategy.closedtrades.exit_id ---
NAME:: strategy.closedtrades.exit_id
TYPE:: function
DESCRIPTION:: Returns the string ID of the exit order (e.g., from strategy.exit or strategy.close) that closed the specified trade.
SEE_ALSO:: strategy.closedtrades.entry_id, strategy.exit
--- Entry: strategy.closedtrades.exit_price ---
NAME:: strategy.closedtrades.exit_price
TYPE:: function
DESCRIPTION:: Returns the actual fill price at which the specified closed trade was exited.
SEE_ALSO:: strategy.closedtrades.entry_price, strategy.closedtrades.exit_time
--- Entry: strategy.closedtrades.exit_time ---
NAME:: strategy.closedtrades.exit_time
TYPE:: function
DESCRIPTION:: Returns the UNIX timestamp (in milliseconds) for when the specified closed trade was exited.
SEE_ALSO:: strategy.closedtrades.entry_time, time
--- Entry: strategy.closedtrades.max_drawdown ---
NAME:: strategy.closedtrades.max_drawdown
TYPE:: function
DESCRIPTION:: Returns the maximum possible loss (in account currency) that the specified closed trade experienced during its open period.
SEE_ALSO:: strategy.closedtrades.max_drawdown_percent, strategy.closedtrades.max_runup
--- Entry: strategy.closedtrades.max_drawdown_percent ---
NAME:: strategy.closedtrades.max_drawdown_percent
TYPE:: function
DESCRIPTION:: Returns the maximum possible loss (as a percentage of entry value) that the specified closed trade experienced during its open period.
SEE_ALSO:: strategy.closedtrades.max_drawdown, strategy.closedtrades.max_runup_percent
--- Entry: strategy.closedtrades.max_runup ---
NAME:: strategy.closedtrades.max_runup
TYPE:: function
DESCRIPTION:: Returns the maximum possible profit (in account currency) that the specified closed trade experienced during its open period.
SEE_ALSO:: strategy.closedtrades.max_runup_percent, strategy.closedtrades.max_drawdown
--- Entry: strategy.closedtrades.max_runup_percent ---
NAME:: strategy.closedtrades.max_runup_percent
TYPE:: function
DESCRIPTION:: Returns the maximum possible profit (as a percentage of entry value) that the specified closed trade experienced during its open period.
SEE_ALSO:: strategy.closedtrades.max_runup, strategy.closedtrades.max_drawdown_percent
--- Entry: strategy.closedtrades.profit ---
NAME:: strategy.closedtrades.profit
TYPE:: function
DESCRIPTION:: Returns the final net profit or loss (in account currency) of the specified closed trade, excluding commissions and slippage.
SEE_ALSO:: strategy.closedtrades.commission, strategy.net_profit
--- Entry: strategy.closedtrades.profit_percent ---
NAME:: strategy.closedtrades.profit_percent
TYPE:: function
DESCRIPTION:: Returns the net profit or loss for the specified closed trade, expressed as a percentage of the trade's entry value.
SEE_ALSO:: strategy.closedtrades.profit, strategy.closedtrades.size
--- Entry: strategy.closedtrades.size ---
NAME:: strategy.closedtrades.size
TYPE:: function
DESCRIPTION:: Returns the size (in contracts/units) of the closed trade. A positive value indicates a long trade, and a negative value indicates a short trade.
SEE_ALSO:: strategy.opentrades.size, strategy.position_size
--- Entry: strategy.convert_to_account ---
NAME:: strategy.convert_to_account
TYPE:: function
DESCRIPTION:: Converts a value from the chart's symbol currency (syminfo.currency) to the strategy's account currency (strategy.account_currency).
SEE_ALSO:: strategy.convert_to_symbol
--- Entry: strategy.convert_to_symbol ---
NAME:: strategy.convert_to_symbol
TYPE:: function
DESCRIPTION:: Converts a value from the strategy's account currency (strategy.account_currency) to the chart's symbol currency (syminfo.currency).
SEE_ALSO:: strategy.convert_to_account
--- Entry: strategy.default_entry_qty ---
NAME:: strategy.default_entry_qty
TYPE:: function
DESCRIPTION:: Calculates the default order quantity based on the strategy settings (default_qty_type, default_qty_value, etc.) if the order were to fill at the specified fill_price. Does not account for existing open positions.
SEE_ALSO:: strategy.entry, strategy.order
--- Entry: strategy.entry ---
NAME:: strategy.entry
TYPE:: function
DESCRIPTION:: Creates an order to open or add to a position. This is the primary function for entering trades, and its orders are affected by the pyramiding setting. Can generate market, limit, stop, or stop-limit orders based on arguments.
REMARKS:: When entering in the opposite direction of a current position, it will typically reverse the position (exit the old, open the new).
SEE_ALSO:: strategy.order, strategy.exit, strategy.close
--- Entry: strategy.exit ---
NAME:: strategy.exit
TYPE:: function
DESCRIPTION:: Creates price-based orders to exit a portion or all of an open position. Can create take-profit, stop-loss, and trailing stop orders. Orders from this command reserve quantity until they fill or are canceled.
REMARKS:: This function does not create market orders; use strategy.close or strategy.close_all for market exits.
SEE_ALSO:: strategy.close, strategy.entry
--- Entry: strategy.opentrades.commission ---
NAME:: strategy.opentrades.commission
TYPE:: function
DESCRIPTION:: Returns the sum of entry fees paid so far for a specified open trade number (trade_num), expressed in the strategy's account currency.
SEE_ALSO:: strategy.closedtrades.commission, strategy.opentrades.profit
--- Entry: strategy.opentrades.entry_bar_index ---
NAME:: strategy.opentrades.entry_bar_index
TYPE:: function
DESCRIPTION:: Returns the bar index at which the specified open trade was entered.
SEE_ALSO:: strategy.opentrades.exit_bar_index (N/A), strategy.closedtrades.entry_bar_index
--- Entry: strategy.opentrades.entry_comment ---
NAME:: strategy.opentrades.entry_comment
TYPE:: function
DESCRIPTION:: Returns the comment string that was associated with the entry order of the specified open trade. Useful for attaching external data (like a target price) to the entry.
SEE_ALSO:: strategy.entry, strategy.closedtrades.entry_comment
--- Entry: strategy.opentrades.entry_id ---
NAME:: strategy.opentrades.entry_id
TYPE:: function
DESCRIPTION:: Returns the string ID of the entry order that opened the specified open trade. Crucial for matching exits (strategy.exit) to specific entries.
SEE_ALSO:: strategy.entry, strategy.closedtrades.entry_id
--- Entry: strategy.opentrades.entry_price ---
NAME:: strategy.opentrades.entry_price
TYPE:: function
DESCRIPTION:: Returns the actual fill price at which the specified open trade was entered. Used to calculate real-time P&L for individual trades.
SEE_ALSO:: strategy.closedtrades.entry_price, strategy.opentrades.profit
--- Entry: strategy.opentrades.entry_time ---
NAME:: strategy.opentrades.entry_time
TYPE:: function
DESCRIPTION:: Returns the UNIX timestamp (in milliseconds) for when the specified open trade was entered. Useful for monitoring how long a trade has been open.
SEE_ALSO:: strategy.closedtrades.entry_time, time
--- Entry: strategy.opentrades.max_drawdown ---
NAME:: strategy.opentrades.max_drawdown
TYPE:: function
DESCRIPTION:: Returns the maximum possible loss (in account currency) that the specified open trade has experienced so far during its lifetime.
SEE_ALSO:: strategy.opentrades.max_drawdown_percent, strategy.max_drawdown
--- Entry: strategy.opentrades.max_drawdown_percent ---
NAME:: strategy.opentrades.max_drawdown_percent
TYPE:: function
DESCRIPTION:: Returns the maximum possible loss (as a percentage of entry value) that the specified open trade has experienced so far.
SEE_ALSO:: strategy.opentrades.max_drawdown, strategy.max_drawdown
--- Entry: strategy.opentrades.max_runup ---
NAME:: strategy.opentrades.max_runup
TYPE:: function
DESCRIPTION:: Returns the maximum possible profit (in account currency) that the specified open trade has achieved so far during its lifetime.
SEE_ALSO:: strategy.opentrades.max_runup_percent, strategy.max_runup
--- Entry: strategy.opentrades.max_runup_percent ---
NAME:: strategy.opentrades.max_runup_percent
TYPE:: function
DESCRIPTION:: Returns the maximum possible profit (as a percentage of entry value) that the specified open trade has achieved so far.
SEE_ALSO:: strategy.opentrades.max_runup, strategy.max_runup
--- Entry: strategy.opentrades.profit ---
NAME:: strategy.opentrades.profit
TYPE:: function
DESCRIPTION:: Returns the current real-time profit/loss (in account currency) of the specified open trade. Losses are negative values.
SEE_ALSO:: strategy.openprofit, strategy.opentrades.profit_percent
--- Entry: strategy.opentrades.profit_percent ---
NAME:: strategy.opentrades.profit_percent
TYPE:: function
DESCRIPTION:: Returns the current real-time profit/loss of the specified open trade, expressed as a percentage. Losses are negative values.
SEE_ALSO:: strategy.opentrades.profit, strategy.openprofit
--- Entry: strategy.opentrades.size ---
NAME:: strategy.opentrades.size
TYPE:: function
DESCRIPTION:: Returns the current size (in contracts/units) of the open trade. Positive value for long, negative for short.
SEE_ALSO:: strategy.position_size, strategy.closedtrades.size
--- Entry: strategy.order ---
NAME:: strategy.order
TYPE:: function
DESCRIPTION:: Creates a new order to open, add to, or exit a position. Unlike strategy.entry, orders from this function are NOT affected by the pyramiding setting, offering precise control over trade size and direction. It will close a position before opening a new one in the opposite direction.
REMARKS:: This function is for flexible order creation (market, limit, stop, stop-limit) and does not automatically reverse a position; it simply executes the specified quantity.
SEE_ALSO:: strategy.entry, strategy.exit, strategy.close
--- Entry: strategy.risk.allow_entry_in ---
NAME:: strategy.risk.allow_entry_in
TYPE:: risk management function
DESCRIPTION:: Restricts the direction in which strategy.entry() is permitted to open new positions. Possible values are strategy.direction.all, strategy.direction.long, or strategy.direction.short.
REMARKS:: If a forbidden entry is called, it will be executed as a position-closing order instead of a reversal.
SEE_ALSO:: strategy.entry
--- Entry: strategy.risk.max_cons_loss_days ---
NAME:: strategy.risk.max_cons_loss_days
TYPE:: risk management function
DESCRIPTION:: A strategy-wide rule that stops all trading (cancels pending orders, closes open positions) if the specified count of consecutive days end with a loss.
SEE_ALSO:: strategy.risk.max_drawdown, strategy.netprofit
--- Entry: strategy.risk.max_drawdown ---
NAME:: strategy.risk.max_drawdown
TYPE:: risk management function
DESCRIPTION:: A strategy-wide rule that stops all trading if the total equity drawdown from its peak exceeds the specified value. The value can be set as a percentage of maximum equity (strategy.percent\_of\_equity) or an absolute cash amount (strategy.cash).
SEE_ALSO:: strategy.risk.max_intraday_loss, strategy.max_drawdown
--- Entry: strategy.risk.max_intraday_filled_orders ---
NAME:: strategy.risk.max_intraday_filled_orders
TYPE:: risk management function
DESCRIPTION:: A strategy-wide rule that stops new orders for the current day once the maximum allowed number of filled orders (count) is reached. Ensures strict control over trading frequency.
REMARKS:: A market order to exit a current open position is still allowed, even after the limit is reached.
SEE_ALSO:: strategy.risk.max_intraday_loss
--- Entry: strategy.risk.max_intraday_loss ---
NAME:: strategy.risk.max_intraday_loss
TYPE:: risk management function
DESCRIPTION:: A strategy-wide rule that stops all trading if the loss incurred during the current day exceeds the specified value. Value can be set in cash or as a percentage of intraday equity.
REMARKS:: This is a critical tool for day traders to enforce a daily "stop-loss" on the entire strategy.
SEE_ALSO:: strategy.risk.max_drawdown
--- Entry: strategy.risk.max_position_size ---
NAME:: strategy.risk.max_position_size
TYPE:: risk management function
DESCRIPTION:: Limits the maximum total size of the position (long or short) that can be opened. The quantity of new strategy.entry orders will be reduced if necessary to prevent exceeding this limit.
SEE_ALSO:: strategy.position_size, strategy.entry
--- Entry: string ---
NAME:: string
TYPE:: function (Type Casting)
DESCRIPTION:: A function used to cast (convert) a variable of any type (e.g., na, int, float, bool) into a string for display or concatenation purposes.
--- Entry: syminfo.prefix ---
NAME:: syminfo.prefix
TYPE:: constant/function
DESCRIPTION:: Returns the exchange prefix of the specified symbol, such as "NASDAQ", "NYSE", or "BINANCE". Useful for creating custom tickers.
SEE_ALSO:: syminfo.ticker, ticker.new
--- Entry: syminfo.ticker ---
NAME:: syminfo.ticker
TYPE:: constant/function
DESCRIPTION:: Returns the base symbol name without the exchange prefix, such as "AAPL", "GOOG", or "BTCUSDT". Useful for creating custom tickers.
SEE_ALSO:: syminfo.prefix, ticker.new
--- Entry: ta.alma ---
NAME:: ta.alma
TYPE:: function
DESCRIPTION:: Calculates the Arnaud Legoux Moving Average (ALMA). This is a smoother, more responsive MA that uses a Gaussian distribution to weigh prices, centering the weight near the middle rather than the end of the lookback length.
ARGUMENTS:: series (data to process), length (bars), offset (smoothness vs. responsiveness, 0 to 1), sigma (smoothing factor, larger = smoother).
SEE_ALSO:: ta.sma, ta.ema, ta.wma
--- Entry: ta.atr ---
NAME:: ta.atr
TYPE:: function
DESCRIPTION:: Calculates the Average True Range (ATR). It's the RMA (Running Moving Average) of the True Range (which is the greatest of: current high minus current low, absolute value of current high minus previous close, or absolute value of current low minus previous close). ATR is a key measure of market volatility.
SEE_ALSO:: ta.tr, ta.rma
--- Entry: ta.barssince ---
NAME:: ta.barssince
TYPE:: function
DESCRIPTION:: Counts the number of bars that have passed since the specified condition was true. Returns na if the condition has never been met.
REMARKS:: This function can cause indicator repainting on the last bar due to its look-back behavior.
SEE_ALSO:: ta.valuewhen
--- Entry: ta.bb ---
NAME:: ta.bb
TYPE:: function
DESCRIPTION:: Calculates the Bollinger Bands (BB). Returns a tuple of three series: the Middle Band (Simple Moving Average), the Upper Band (Middle Band + mult * Standard Deviation), and the Lower Band (Middle Band - mult * Standard Deviation).
SEE_ALSO:: ta.sma, ta.stdev, ta.bbw
--- Entry: ta.bbw ---
NAME:: ta.bbw
TYPE:: function
DESCRIPTION:: Calculates the Bollinger Bands Width (BBW). It is the normalized difference between the Upper and Lower bands, often used to identify volatility extremes.
FORMULA:: (Upper Band - Lower Band) / Middle Band
SEE_ALSO:: ta.bb
--- Entry: ta.cci ---
NAME:: ta.cci
TYPE:: function
DESCRIPTION:: Calculates the Commodity Channel Index (CCI). A momentum-based oscillator that measures the difference between a price and its moving average, scaled by the mean absolute deviation. Used to identify cyclical turns and overbought/oversold conditions.
--- Entry: ta.change ---
NAME:: ta.change
TYPE:: function
DESCRIPTION:: Compares the current value of a source series to its value from length bars ago, and returns the difference. If the source is a boolean, it returns true if the current value is different from the previous.
SEE_ALSO:: ta.mom
--- Entry: ta.cmo ---
NAME:: ta.cmo
TYPE:: function
DESCRIPTION:: Calculates the Chande Momentum Oscillator (CMO). This oscillator calculates the difference between the sum of recent gains and the sum of recent losses, divided by the total movement. Used to measure momentum strength and trend.
SEE_ALSO:: ta.rsi
--- Entry: ta.cog ---
NAME:: ta.cog
TYPE:: function
DESCRIPTION:: Calculates the Center of Gravity (COG). A zero-lag, adaptive oscillator based on statistics, where recent prices are weighted more heavily.
SEE_ALSO:: ta.stoch
--- Entry: ta.correlation ---
NAME:: ta.correlation
TYPE:: function
DESCRIPTION:: Calculates the Correlation Coefficient between two series over a specified length. The result ranges from -1.0 (perfect inverse correlation) to +1.0 (perfect positive correlation).
--- Entry: ta.cross ---
NAME:: ta.cross
TYPE:: function
DESCRIPTION:: Returns true if two series, source1 and source2, cross each other on the current bar, regardless of direction (crossover or crossunder).
SEE_ALSO:: ta.crossover, ta.crossunder
--- Entry: ta.crossover ---
NAME:: ta.crossover
TYPE:: function
DESCRIPTION:: Returns true if source1 is now greater than source2, AND on the previous bar, source1 was less than or equal to source2.
SEE_ALSO:: ta.crossunder
--- Entry: ta.crossunder ---
NAME:: ta.crossunder
TYPE:: function
DESCRIPTION:: Returns true if source1 is now less than source2, AND on the previous bar, source1 was greater than or equal to source2.
SEE_ALSO:: ta.crossover
--- Entry: ta.cum ---
NAME:: ta.cum
TYPE:: function
DESCRIPTION:: Calculates the Cumulative (total) sum of all elements in the source series from the beginning of the chart up to the current bar.
SEE_ALSO:: math.sum
--- Entry: ta.dev ---
NAME:: ta.dev
TYPE:: function
DESCRIPTION:: Calculates the Mean Absolute Deviation (MAD). This measures the average absolute difference between the source series and its Simple Moving Average (ta.sma) over a specified length.
SEE_ALSO:: ta.variance, ta.stdev
--- Entry: ta.dmi ---
NAME:: ta.dmi
TYPE:: function
DESCRIPTION:: Calculates the Directional Movement Index (DMI), which includes the Positive Directional Indicator (+DI), the Negative Directional Indicator (-DI), and the Average Directional Index (ADX). ADX measures trend strength.
RETURNS:: A tuple: [+DI, -DI, ADX]
SEE_ALSO:: ta.atr
--- Entry: ta.ema ---
NAME:: ta.ema
TYPE:: function
DESCRIPTION:: Calculates the Exponentially Weighted Moving Average (EMA). This MA applies more weight to recent prices, resulting in a more responsive indicator compared to a Simple Moving Average (SMA).
FORMULA:: EMA=α×source+(1−α)×EMA[1], where α=2/(length+1).
SEE_ALSO:: ta.sma, ta.rma
--- Entry: ta.falling ---
NAME:: ta.falling
TYPE:: function
DESCRIPTION:: Returns true if the current value of the source series is lower than its value on every bar for the specified length lookback. Confirms a short-term downward trend.
SEE_ALSO:: ta.rising, ta.lowest
--- Entry: ta.rising ---
NAME:: ta.rising
TYPE:: function
DESCRIPTION:: Returns true if the current value of the source series is higher than its value on every bar for the specified length lookback. Confirms a short-term upward trend.
SEE_ALSO:: ta.falling, ta.highest
--- Entry: ta.highest ---
NAME:: ta.highest
TYPE:: function
DESCRIPTION:: Returns the highest value of the source series (or high price if one argument is used) over the specified length of bars.
SEE_ALSO:: ta.lowest, ta.highestbars
--- Entry: ta.highestbars ---
NAME:: ta.highestbars
TYPE:: function
DESCRIPTION:: Returns the bar index offset (distance from the current bar) to the bar where the highest value occurred over the specified length lookback.
--- Entry: ta.lowest ---
NAME:: ta.lowest
TYPE:: function
DESCRIPTION:: Returns the lowest value of the source series (or low price if one argument is used) over the specified length of bars.
SEE_ALSO:: ta.highest, ta.lowestbars
--- Entry: ta.lowestbars ---
NAME:: ta.lowestbars
TYPE:: function
DESCRIPTION:: Returns the bar index offset (distance from the current bar) to the bar where the lowest value occurred over the specified length lookback.
--- Entry: ta.max ---
NAME:: ta.max
TYPE:: function
DESCRIPTION:: Returns the all-time high value of the source series from the very beginning of the chart up to the current bar.
--- Entry: ta.min ---
NAME:: ta.min
TYPE:: function
DESCRIPTION:: Returns the all-time low value of the source series from the very beginning of the chart up to the current bar.
Moving Averages & Price Channels
--- Entry: ta.hma ---
NAME:: ta.hma
TYPE:: function
DESCRIPTION:: Calculates the Hull Moving Average (HMA). It's a faster, smoother moving average designed to follow price action closely while minimizing lag.
SEE_ALSO:: ta.wma, ta.ema
--- Entry: ta.kc ---
NAME:: ta.kc
TYPE:: function
DESCRIPTION:: Calculates Keltner Channels. Returns a tuple of three series: Middle Band (Exponential Moving Average, EMA), Upper Channel (EMA + mult * ATR/True Range), and Lower Channel (EMA - mult * ATR/True Range). Keltner channels are useful for identifying trade setups based on volatility.
RETURNS:: A tuple: [Middle, Upper, Lower]
SEE_ALSO:: ta.ema, ta.atr, ta.bb
--- Entry: ta.kcw ---
NAME:: ta.kcw
TYPE:: function
DESCRIPTION:: Calculates the Keltner Channels Width (KCW). Measures the distance between the upper and lower channel lines, often normalized by the middle line. Useful for assessing volatility contraction/expansion.
SEE_ALSO:: ta.kc, ta.bbw
--- Entry: ta.linreg ---
NAME:: ta.linreg
TYPE:: function
DESCRIPTION:: Calculates the Linear Regression Curve. This is a straight line that best fits the price data over a length period using the least squares method. It is often used as a responsive and less lagged alternative to a moving average.
Statistics & Percentiles
--- Entry: ta.median ---
NAME:: ta.median
TYPE:: function
DESCRIPTION:: Returns the median (the middle value) of the source series over the specified length of bars.
--- Entry: ta.mode ---
NAME:: ta.mode
TYPE:: function
DESCRIPTION:: Returns the mode (the most frequently occurring value) of the source series over the specified length.
--- Entry: ta.percentile_linear_interpolation ---
NAME:: ta.percentile_linear_interpolation
TYPE:: function
DESCRIPTION:: Calculates the P-th percentile of the source series over length bars using the linear interpolation method. The result may or may not be an actual value from the input data set.
SEE_ALSO:: ta.percentile_nearest_rank
--- Entry: ta.percentile_nearest_rank ---
NAME:: ta.percentile_nearest_rank
TYPE:: function
DESCRIPTION:: Calculates the P-th percentile of the source series over length bars using the nearest rank method. The result is always an actual value from the input data set.
SEE_ALSO:: ta.percentile_linear_interpolation
--- Entry: ta.percentrank ---
NAME:: ta.percentrank
TYPE:: function
DESCRIPTION:: Calculates the percent rank. This tells you what percentage of the previous length values were less than or equal to the current source value.
--- Entry: ta.range ---
NAME:: ta.range
TYPE:: function
DESCRIPTION:: Returns the range of the source series over a specified length, calculated as the difference between the maximum and minimum values in that window.
Indicators & Price Points
--- Entry: ta.macd ---
NAME:: ta.macd
TYPE:: function
DESCRIPTION:: Calculates the Moving Average Convergence/Divergence (MACD). Returns a tuple of three series: the MACD Line, the Signal Line, and the Histogram Line. A crucial momentum and trend-following indicator.
RETURNS:: A tuple: [MACD Line, Signal Line, Histogram Line]
--- Entry: ta.mfi ---
NAME:: ta.mfi
TYPE:: function
DESCRIPTION:: Calculates the Money Flow Index (MFI). An oscillator that uses both price and volume to measure buying and selling pressure and identify overbought/oversold conditions.
SEE_ALSO:: ta.rsi
--- Entry: ta.mom ---
NAME:: ta.mom
TYPE:: function
DESCRIPTION:: Calculates Momentum. This is the simple difference between the current source price and the price length bars ago. Formula: source - source[length].
SEE_ALSO:: ta.change
--- Entry: ta.pivot_point_levels ---
NAME:: ta.pivot_point_levels
TYPE:: function
DESCRIPTION:: Calculates an array of up to 11 Pivot Point Levels (e.g., P, R1-R5, S1-S5) based on a specified type (Traditional, Fibonacci, Camarilla, etc.) and an anchor condition (often a new day/week/month).
RETURNS:: An array of floats: [P, R1, S1, R2, S2, R3, S3, R4, S4, R5, S5]
--- Entry: ta.pivothigh ---
NAME:: ta.pivothigh
TYPE:: function
DESCRIPTION:: Identifies and returns the price of a Pivot High point. A bar is a Pivot High if it is the highest value within a window defined by leftbars and rightbars. Returns NaN if no pivot is found.
SEE_ALSO:: ta.pivotlow
--- Entry: ta.pivotlow ---
NAME:: ta.pivotlow
TYPE:: function
DESCRIPTION:: Identifies and returns the price of a Pivot Low point. A bar is a Pivot Low if it is the lowest value within a window defined by leftbars and rightbars. Returns NaN if no pivot is found.
SEE_ALSO:: ta.pivothigh
--- Entry: ta.range ---
NAME:: ta.range
TYPE:: function
DESCRIPTION:: Returns the difference between the maximum and minimum values in the source series over the specified length. It's a simple measure of absolute volatility or price spread within a window.
--- Entry: ta.rising ---
NAME:: ta.rising
TYPE:: function
DESCRIPTION:: Returns true if the current value of the source series is greater than its value on every bar for the specified length lookback. Confirms a short-term, uninterrupted upward trend.
SEE_ALSO:: ta.falling
--- Entry: ta.rma ---
NAME:: ta.rma
TYPE:: function
DESCRIPTION:: Calculates the Running Moving Average (RMA). This is a specific type of Exponential Moving Average (EMA) where the smoothing factor α is fixed at 1/length. It is notably used as the smoothing component in the Average True Range (ATR) and the Relative Strength Index (RSI).
FORMULA:: α=1/length
SEE_ALSO:: ta.ema, ta.rsi, ta.atr
--- Entry: ta.roc ---
NAME:: ta.roc
TYPE:: function
DESCRIPTION:: Calculates the Rate of Change (ROC). It's the percentage change between the current source value and its value length bars ago.
FORMULA:: 100×(source−source[length])/source[length]
--- Entry: ta.rsi ---
NAME:: ta.rsi
TYPE:: function
DESCRIPTION:: Calculates the Relative Strength Index (RSI). This momentum oscillator measures the speed and change of price movements, based on the ta.rma of upward and downward price changes. A key tool for identifying overbought/oversold conditions.
SEE_ALSO:: ta.rma
--- Entry: ta.sar ---
NAME:: ta.sar
TYPE:: function
DESCRIPTION:: Calculates the Parabolic Stop and Reverse (SAR). This indicator provides trailing stop levels and is used to determine the prevailing market direction and potential trend reversals.
ARGUMENTS:: start (initial acceleration factor), inc (increment), max (maximum acceleration factor).
--- Entry: ta.sma ---
NAME:: ta.sma
TYPE:: function
DESCRIPTION:: Returns the Simple Moving Average (SMA), which is the arithmetic mean (sum) of the source values over the specified length, divided by length.
SEE_ALSO:: ta.ema, ta.rma, ta.wma
--- Entry: ta.stdev ---
NAME:: ta.stdev
TYPE:: function
DESCRIPTION:: Calculates the Standard Deviation. Measures the dispersion of the source series around its mean, indicating market volatility. It is the square root of the variance.
ARGUMENTS:: biased determines the calculation method (population vs. sample estimate).
SEE_ALSO:: ta.variance, ta.dev
--- Entry: ta.stoch ---
NAME:: ta.stoch
TYPE:: function
DESCRIPTION:: Calculates the Stochastic Oscillator. This momentum indicator compares a particular closing price to a range of its prices over a time period, often used to identify overbought/oversold conditions and potential reversals.
FORMULA:: 100×(close−lowest(low))/(highest(high)−lowest(low))
--- Entry: ta.supertrend ---
NAME:: ta.supertrend
TYPE:: function
DESCRIPTION:: Calculates the Supertrend Indicator. A trend-following indicator that uses the Average True Range (ATR) to set dynamic trailing stop levels.
RETURNS:: A tuple: [Supertrend line, Direction], where direction is 1 (down/short) or -1 (up/long).
SEE_ALSO:: ta.atr
--- Entry: ta.swma ---
NAME:: ta.swma
TYPE:: function
DESCRIPTION:: Calculates the Symmetrically Weighted Moving Average (SWMA) with a fixed length of 4. It uses weights [1/6, 2/6, 2/6, 1/6] and is a very responsive type of moving average.
--- Entry: ta.tr ---
NAME:: ta.tr
TYPE:: function
DESCRIPTION:: Returns the True Range. This is the greatest of: (current high - current low), (absolute value of current high - previous close), or (absolute value of current low - previous close). It is the basis for ATR.
SEE_ALSO:: ta.atr
--- Entry: ta.tsi ---
NAME:: ta.tsi
TYPE:: function
DESCRIPTION:: Calculates the True Strength Index (TSI). This is a momentum oscillator based on double-smoothed exponential moving averages of the underlying price momentum. It produces smoother, less erratic signals.
RETURNS:: A value in the range [−1,1].
--- Entry: ta.valuewhen ---
NAME:: ta.valuewhen
TYPE:: function
DESCRIPTION:: Returns the value of the source series from the bar where the specified condition was true at the occurrence count (0 is the most recent, 1 is the second, etc.). Useful for marking prices at key events.
REMARKS:: This function can cause indicator repainting.
SEE_ALSO:: ta.barssince
--- Entry: ta.variance ---
NAME:: ta.variance
TYPE:: function
DESCRIPTION:: Calculates the Variance. This is the expectation of the squared deviation of a series from its mean (SMA). It quantifies volatility and is the measure before the square root is taken to get the Standard Deviation.
ARGUMENTS:: biased determines the calculation method (population vs. sample estimate).
SEE_ALSO:: ta.stdev, ta.dev
--- Entry: ta.vwap ---
NAME:: ta.vwap
TYPE:: function
DESCRIPTION:: Calculates the Volume Weighted Average Price (VWAP). This benchmark reflects the average price based on the volume traded at each price point, often used by institutional traders. The calculation is reset when the anchor condition is met (e.g., Daily, Weekly reset).
RETURNS:: A VWAP series, or a tuple [vwap, upper_band, lower_band] if stdev_mult is specified to create standard deviation bands.
--- Entry: ta.vwma ---
NAME:: ta.vwma
TYPE:: function
DESCRIPTION:: Calculates the Volume-Weighted Moving Average (VWMA). It weights prices by volume, giving greater significance to periods of high trading activity.
FORMULA:: SMA(source×volume,length)/SMA(volume,length)
SEE_ALSO:: ta.sma, ta.vwap
--- Entry: ta.wma ---
NAME:: ta.wma
TYPE:: function
DESCRIPTION:: Calculates the Weighted Moving Average (WMA). It weights data points in arithmetical progression, giving the most weight to the most recent data and decreasing linearly backward in time.
SEE_ALSO:: ta.sma, ta.ema
--- Entry: ta.wpr ---
NAME:: ta.wpr
TYPE:: function
DESCRIPTION:: Calculates Williams %R (Williams Percent Range). This momentum oscillator shows the current close in relation to the highest high and lowest low over a lookback period. It's used to identify overbought/oversold levels.
RETURNS:: A value in the range [−100,0].
Table Management (table.*)
These functions are used to create, manage, and display data tables directly on the chart, which is highly effective for displaying real-time metrics for day trading strategies.
--- Entry: table ---
NAME:: table
TYPE:: function
DESCRIPTION:: Used primarily for type-casting na (not applicable) values to a table type, often as an initial placeholder when defining a table object.
--- Entry: table.cell ---
NAME:: table.cell
TYPE:: function
DESCRIPTION:: Defines a cell within an existing table object (table_id) and sets all of its attributes (text, color, alignment, etc.) in a single call.
REMARKS:: This function overwrites all previous cell properties. For individual updates, use the table.cell_set_* functions.
--- Entry: table.cell_set_* (Multiple Functions) ---
NAME:: table.cell_set_bgcolor, table.cell_set_text, etc.
TYPE:: functions
DESCRIPTION:: A set of functions (e.g., table.cell_set_text, table.cell_set_bgcolor, table.cell_set_width) used to individually modify a single property of a specified cell in an existing table. They are more efficient for updates than table.cell.
--- Entry: table.clear ---
NAME:: table.clear
TYPE:: function
DESCRIPTION:: Removes the content (cells) within a specified rectangular region (defined by column/row range) of the table, making the space transparent.
--- Entry: table.delete ---
NAME:: table.delete
TYPE:: function
DESCRIPTION:: Completely removes the specified table object from the chart. This is often used on the last real-time bar to clear the display.
SEE_ALSO:: table.new
--- Entry: table.merge_cells ---
NAME:: table.merge_cells
TYPE:: function
DESCRIPTION:: Combines a contiguous rectangular block of cells (defined by top-left and bottom-right coordinates) into a single, larger cell. Useful for creating headers or formatting display panels.
REMARKS:: The resulting merged cell's properties are inherited from the top-left cell (start_column:start_row), which is also the coordinate used to modify the merged cell later with table.cell_set_* functions.
--- Entry: table.new ---
NAME:: table.new
TYPE:: function
DESCRIPTION:: Creates a new table object on the chart, specifying its initial size (rows/columns), position (e.g., position.top_right), and global appearance (frame, borders, background color).
RETURNS:: The ID of the new table object, which is required for all other table.* functions.
REMARKS:: For performance, this is almost always used with the var keyword or inside an if barstate.islast block so it only runs once.
--- Entry: table.set_* (Multiple Functions) ---
NAME:: table.set_bgcolor, table.set_position, etc.
TYPE:: functions
DESCRIPTION:: A set of functions (e.g., table.set_bgcolor, table.set_frame_width, table.set_position) used to individually modify the global properties of the entire table object (not just a single cell).
Ticker Manipulation (ticker.*)
These functions are critical when using request.security() to fetch data for non-standard chart types or different markets within your script, a common need for a retail futures day trader analyzing intermarket relationships.
--- Entry: ticker.heikinashi ---
NAME:: ticker.heikinashi
TYPE:: function
DESCRIPTION:: Creates a special Heikin Ashi ticker ID. This ID can be passed to request.security() to retrieve data that has been calculated using the Heikin Ashi formula.
SEE_ALSO:: request.security
--- Entry: ticker.inherit ---
NAME:: ticker.inherit
TYPE:: function
DESCRIPTION:: Creates a new ticker ID for a specified symbol that inherits all modifiers (like Heikin Ashi, Extended Hours, Renko, currency conversion, etc.) from an existing from_tickerid. This simplifies requesting data with complex settings applied to multiple symbols.
--- Entry: ticker.kagi ---
NAME:: ticker.kagi
TYPE:: function
DESCRIPTION:: Creates a special Kagi chart ticker ID using a defined reversal amount. This ID can be passed to request.security() to fetch Kagi values.
SEE_ALSO:: request.security
--- Entry: ticker.linebreak ---
NAME:: ticker.linebreak
TYPE:: function
DESCRIPTION:: Creates a special Line Break chart ticker ID using a defined number_of_lines parameter. This ID can be passed to request.security() to fetch Line Break values.
SEE_ALSO:: request.security
--- Entry: ticker.modify ---
NAME:: ticker.modify
TYPE:: function
DESCRIPTION:: Creates a new ticker ID by modifying specific parameters (session, adjustment, back-adjustment, settlement_as_close) of an existing tickerid. This is efficient for taking an already complex ticker (like a Heikin Ashi one) and simply changing one setting, like switching to the extended session.
ARGUMENTS:: Key arguments include:
session: session.regular or session.extended.
adjustment: adjustment.none, adjustment.splits, or adjustment.dividends.
backadjustment: Crucial for continuous futures contracts (backadjustment.on/off).
settlement\_as\_close: Essential for futures data on daily+ timeframes (settlement_as_close.on/off).
--- Entry: ticker.new ---
NAME:: ticker.new
TYPE:: function
DESCRIPTION:: Creates a new standard ticker ID from scratch using the prefix (exchange) and ticker (symbol) name, along with all optional parameters (session, adjustment, back-adjustment, settlement_as_close). It is the base function for generating new ticker IDs.
REMARKS:: The output can be used as the input for functions like ticker.heikinashi or ticker.modify.
--- Entry: ticker.pointfigure ---
NAME:: ticker.pointfigure
TYPE:: function
DESCRIPTION:: Creates a special Point & Figure chart ticker ID. This allows you to request the unique bar data (like close) generated by a Point & Figure calculation (using specific source, style, param, and reversal settings) via request.security().
SEE_ALSO:: request.security
--- Entry: ticker.renko ---
NAME:: ticker.renko
TYPE:: function
DESCRIPTION:: Creates a special Renko chart ticker ID. This allows you to request the unique bar data generated by a Renko calculation (using specific style, box size/ATR length, and wick settings) via request.security().
REMARKS:: Set request_wicks = true to get the actual high and low of the underlying price moves, which is typically desired for detailed analysis.
--- Entry: ticker.standard ---
NAME:: ticker.standard
TYPE:: function
DESCRIPTION:: Creates a standard ticker ID that is unaffected by any non-standard modifiers (Heikin Ashi, Renko, Extended Session, etc.). This is primarily used to request the underlying standard price data when your script is running on a non-standard chart type.
RETURNS:: A string in "prefix:ticker" format.
Time and Timeframe (time.*, timeframe.*, timestamp.*, year, weekofyear)
--- Entry: time ---
NAME:: time
TYPE:: function
DESCRIPTION:: Returns the UNIX time (milliseconds since Jan 1, 1970 UTC) of the current bar's open for a specified timeframe and optional session. If the bar falls outside the specified session, it returns na.
--- Entry: time_close ---
NAME:: time_close
TYPE:: function
DESCRIPTION:: Returns the UNIX time of the current bar's close for a specified timeframe and optional session.
--- Entry: timeframe.change ---
NAME:: timeframe.change
TYPE:: function
DESCRIPTION:: Returns true on the first bar of a new period for the specified timeframe (e.g., timeframe.change("1D") is true on the first bar of a new trading day). Crucial for setting up higher timeframe logic or anchors.
--- Entry: timeframe.from_seconds ---
NAME:: timeframe.from_seconds
TYPE:: function
DESCRIPTION:: Converts a number of seconds into the corresponding valid Pine Script timeframe string (e.g., 60 seconds returns "1").
--- Entry: timeframe.in_seconds ---
NAME:: timeframe.in_seconds
TYPE:: function
DESCRIPTION:: Converts a timeframe string (e.g., "1D", "60", "1W") into the equivalent number of seconds.
--- Entry: timestamp ---
NAME:: timestamp
TYPE:: function
DESCRIPTION:: Converts a human-readable date and time (either as a string or discrete year/month/day arguments) into its corresponding UNIX time integer. Useful for defining fixed points in time for lookbacks or alerts.
--- Entry: weekofyear ---
NAME:: weekofyear
TYPE:: function
DESCRIPTION:: Returns the week number of the year for the provided UNIX time (bar open).
--- Entry: year ---
NAME:: year
TYPE:: function
DESCRIPTION:: Returns the year for the provided UNIX time (bar open).
SEE_ALSO:: month, dayofmonth, hour, minute, second
# ----------------------------------------------------------------------------------------------------------
# KEYWORDS
--- Entry: and ---
NAME:: and
TYPE:: keyword (Logical Operator)
DESCRIPTION:: The logical AND operator. Returns true only if both expr1 and expr2 evaluate to true. Applicable to boolean expressions.
SEE_ALSO:: or, not
--- Entry: enum ---
NAME:: enum
TYPE:: keyword (Declaration)
DESCRIPTION:: Allows the creation of an enumeration, a group of predefined, named constants (fields). Each field can have an optional const string title.
USE_CASE:: Excellent for creating user-friendly dropdown menus using input.enum, where the options displayed are the enum field titles. Can also be used to restrict data types in collections (like map<enumName, float>).
--- Entry: export ---
NAME:: export
TYPE:: keyword (Modifier)
DESCRIPTION:: Used in libraries (library() scripts) to prefix the declaration of functions or user-defined types (type) that should be available for use in other scripts that import the library.
REMARKS:: Exported functions have restrictions: they cannot use mutable or array variables from the global scope and cannot use request.*() functions.
--- Entry: for ---
NAME:: for
TYPE:: keyword (Loop)
DESCRIPTION:: A traditional loop structure that allows the repeated execution of a block of statements based on an incrementing counter.
SYNTAX:: for counter = from_num to to_num [by step_num]
CONTROLS:: continue (skips to the next iteration) and break (exits the loop).
--- Entry: for...in ---
NAME:: for...in
TYPE:: keyword (Loop)
DESCRIPTION:: A simplified loop structure designed for iterating over every element in an array (or row in a matrix, or key/value in a map's key array).
SYNTAX:: for array_element in array_id or for [index, array_element] in array_id
--- Entry: if ---
NAME:: if
TYPE:: keyword (Control Flow)
DESCRIPTION:: Defines what block of statements should be executed based on whether a condition is satisfied (true or false). Supports else if and else blocks.
RETURNS:: An if statement can optionally return a value (assigned to a variable) from the last expression in the executed block. The return type must be consistent across all blocks.
USE_CASE:: The primary way to implement conditional logic, such as a strategy's entry or exit conditions.
--- Entry: import ---
NAME:: import
TYPE:: keyword (Module)
DESCRIPTION:: Used to load an external, published library into the current script and bind its exported functions to a specified alias (namespace).
SYNTAX:: import {username}/{libraryName}/{libraryVersion} as {alias}
--- Entry: method ---
NAME:: method
TYPE:: keyword (Modifier)
DESCRIPTION:: Used to prefix a function declaration, allowing it to be invoked using dot notation (like a function built into a data type). The first parameter defines the type the method applies to, and is omitted in the dot notation call.
EXAMPLE:: prices.maintainArray(50, close) (where prices is the first parameter).
--- Entry: not ---
NAME:: not
TYPE:: keyword (Logical Operator)
DESCRIPTION:: The logical NOT operator (negation). Reverses the boolean value of an expression (i.e., not true is false).
--- Entry: or ---
NAME:: or
TYPE:: keyword (Logical Operator)
DESCRIPTION:: The logical OR operator. Returns true if at least one of expr1 or expr2 evaluates to true.
SEE_ALSO:: and, not
--- Entry: switch ---
NAME:: switch
TYPE:: keyword (Control Flow)
DESCRIPTION:: Transfers control to one of several statements based on matching an expression to various value cases, or by evaluating a series of boolean conditions.
USE_CASE:: Much cleaner than nested if-else if blocks for handling multiple possible values or states (e.g., choosing which moving average to plot based on a user input).
--- Entry: type ---
NAME:: type
TYPE:: keyword (Declaration)
DESCRIPTION:: Allows the declaration of a User-Defined Type (UDT), which is a composite type containing an arbitrary number of fields of various types. UDTs are instantiated using the UDT_identifier.new() method.
USE_CASE:: Enables Object-Oriented Programming (OOP) concepts in Pine Script, which is ideal for managing complex data structures, such as combining OHLC data and timestamps for an off-chart bar.
--- Entry: var ---
NAME:: var
TYPE:: keyword (Variable Declaration)
DESCRIPTION:: Used for the one-time initialization and assignment of a variable on the first bar of the chart. On subsequent bars, the variable retains its last calculated value (state) unless explicitly reassigned using the mutable assignment operator (:=).
USE_CASE:: Essential for variables that need to persist their value across bars, such as cumulative counts, maximum/minimum values, or the initial creation of drawing objects (var table t = table.new(...)).
--- Entry: varip ---
NAME:: varip
TYPE:: keyword (Variable Declaration)
DESCRIPTION:: Short for "var intrabar persist." It's similar to var, but variables or UDT fields declared with varip retain their values between successive executions of the script on the same real-time bar.
USE_CASE:: Critical for scripts (especially strategies) that execute multiple times per bar (tick updates). It ensures the variable state is not reset (rolled back) at the start of a new intrabar execution, allowing for tick-by-tick state tracking.
--- Entry: while ---
NAME:: while
TYPE:: keyword (Loop)
DESCRIPTION:: A loop structure that executes a block of code repeatedly as long as a specified condition remains true.
CONTROLS:: continue (skips to the next iteration) and break (exits the loop).
# ----------------------------------------------------------------------------------------------------------
# TYPES
--- Entry: array ---
NAME:: array
TYPE:: keyword (Collection Type)
DESCRIPTION:: Used to explicitly declare a one-dimensional list/collection of values of a specified type (e.g., array<float>). Array objects are mutable and manipulated using array.* functions.
SEE_ALSO:: array.new, array.from
--- Entry: box ---
NAME:: box
TYPE:: keyword (Drawing Type)
DESCRIPTION:: Used to declare a Box object ID, which draws a rectangular shape on the chart, created with box.new.
--- Entry: chart.point ---
NAME:: chart.point
TYPE:: keyword (Data Structure Type)
DESCRIPTION:: Represents a specific (X, Y) coordinate on the chart, defined by a combination of index (bar number), time (UNIX timestamp), and price (float).
--- Entry: label ---
NAME:: label
TYPE:: keyword (Drawing Type)
DESCRIPTION:: Used to declare a Label object ID, which draws a piece of text (with an optional pointer) at a specified point, created with label.new.
--- Entry: line ---
NAME:: line
TYPE:: keyword (Drawing Type)
DESCRIPTION:: Used to declare a Line object ID, which draws a straight line between two specified points, created with line.new.
--- Entry: linefill ---
NAME:: linefill
TYPE:: keyword (Drawing Type)
DESCRIPTION:: Used to declare a Linefill object ID, which shades the area between two existing Line objects, created with linefill.new.
--- Entry: map ---
NAME:: map
TYPE:: keyword (Collection Type)
DESCRIPTION:: Used to explicitly declare a key-value pair collection of specified types (e.g., map<string, float>). Map objects are mutable and manipulated using map.* functions.
--- Entry: matrix ---
NAME:: matrix
TYPE:: keyword (Collection Type)
DESCRIPTION:: Used to explicitly declare a two-dimensional grid (table) collection of values of a specified type (e.g., matrix<int>). Matrix objects are manipulated using matrix.* functions.
--- Entry: polyline ---
NAME:: polyline
TYPE:: keyword (Drawing Type)
DESCRIPTION:: Used to declare a Polyline object, which draws a sequence of connected line segments on the chart, built from multiple chart.point instances.
--- Entry: table ---
NAME:: table
TYPE:: keyword (Drawing Type)
DESCRIPTION:: Used to declare a Table object ID, which displays a customizable grid/panel on the chart in a fixed position, created with table.new.
Type Qualifiers
Qualifiers determine when a variable's value is determined (compile time, start of script, or every bar/update) and enforce rules on how it can be used in functions. The hierarchy of strength is const < input < simple < series.
--- Entry: const ---
NAME:: const
TYPE:: keyword (Qualifier)
DESCRIPTION:: Restricts a variable or parameter to a constant value that is set at compile time and never changes during the script's execution. It is the weakest qualifier.
USE_CASE:: For literal values like fixed strings, color codes, or plot titles.
--- Entry: simple ---
NAME:: simple
TYPE:: keyword (Qualifier)
DESCRIPTION:: Restricts a variable or parameter to a value that is calculated only once at the start of the script's execution. It remains constant for the life of the script run, but can change between different script runs.
USE_CASE:: Required for arguments in built-in functions (like ta.ema's length parameter) that cannot accept a value that changes every bar (series).
--- Entry: series ---
NAME:: series
TYPE:: keyword (Qualifier)
DESCRIPTION:: The strongest qualifier. Variables or parameters with this type can reference values that change on every bar (or every tick in real-time). The majority of Pine Script's built-in variables (e.g., close, high, open) are series.
USE_CASE:: For any value that needs to track price movement or other bar-to-bar calculations. A series value cannot be used where a simple or const is required.
# ---------------------------------------------------------------------------------------------
# OPERATORS
--- Entry: + ---
NAME:: +
TYPE:: Arithmetic/Concatenation Operator
DESCRIPTION:: Binary: Addition for numbers (expr1 + expr2). Concatenation for strings. Unary: Unary plus (+expr).
RETURNS:: Number (int/float) or concatenated string.
--- Entry: += ---
NAME:: +=
TYPE:: Addition/Concatenation Assignment
DESCRIPTION:: Shortcut for Addition Assignment or String Concatenation Assignment. Equivalent to expr1 = expr1 + expr2.
RETURNS:: Number or concatenated string.
--- Entry: - ---
NAME:: -
TYPE:: Arithmetic/Unary Operator
DESCRIPTION:: Binary: Subtraction for numbers (expr1 - expr2). Unary: Negation/Unary minus (-expr).
RETURNS:: Number (int/float).
--- Entry: -= ---
NAME:: -=
TYPE:: Subtraction Assignment
DESCRIPTION:: Shortcut for Subtraction Assignment. Equivalent to expr1 = expr1 - expr2.
RETURNS:: Number (int/float).
--- Entry: * ---
NAME:: *
TYPE:: Arithmetic Operator
DESCRIPTION:: Multiplication for numerical expressions.
RETURNS:: Number (int/float).
--- Entry: *= ---
NAME:: *=
TYPE:: Multiplication Assignment
DESCRIPTION:: Shortcut for Multiplication Assignment. Equivalent to expr1 = expr1 * expr2.
RETURNS:: Number (int/float).
--- Entry: / ---
NAME:: /
TYPE:: Arithmetic Operator
DESCRIPTION:: Division for numerical expressions.
RETURNS:: Number (int/float).
--- Entry: /= ---
NAME:: /=
TYPE:: Division Assignment
DESCRIPTION:: Shortcut for Division Assignment. Equivalent to expr1 = expr1 / expr2.
RETURNS:: Number (int/float).
--- Entry: % ---
NAME:: %
TYPE:: Arithmetic Operator
DESCRIPTION:: Modulo (Integer Remainder). Returns the remainder of division. Result has the same sign as the dividend.
RETURNS:: Number (int/float).
--- Entry: %= ---
NAME:: %=
TYPE:: Modulo Assignment
DESCRIPTION:: Shortcut for Modulo Assignment. Equivalent to expr1 = expr1 % expr2.
RETURNS:: Number (int/float).
--- Entry: == ---
NAME:: ==
TYPE:: Comparison Operator
DESCRIPTION:: Equal to. Returns true if expr1 is equal to expr2.
RETURNS:: Boolean.
--- Entry: != ---
NAME:: !=
TYPE:: Comparison Operator
DESCRIPTION:: Not equal to. Returns true if expr1 is not equal to expr2.
RETURNS:: Boolean.
--- Entry: > ---
NAME:: >
TYPE:: Comparison Operator
DESCRIPTION:: Greater than. Returns true if expr1 is greater than expr2.
RETURNS:: Boolean.
--- Entry: >= ---
NAME:: >=
TYPE:: Comparison Operator
DESCRIPTION:: Greater than or equal to. Returns true if expr1 is greater than or equal to expr2.
RETURNS:: Boolean.
--- Entry: < ---
NAME:: <
TYPE:: Comparison Operator
DESCRIPTION:: Less than. Returns true if expr1 is less than expr2.
RETURNS:: Boolean.
--- Entry: <= ---
NAME:: <=
TYPE:: Comparison Operator
DESCRIPTION:: Less than or equal to. Returns true if expr1 is less than or equal to expr2.
RETURNS:: Boolean.
--- Entry: := ---
NAME:: :=
TYPE:: Reassignment Operator
DESCRIPTION:: Used to assign a new value to a variable that was previously declared. Crucial for updating variables declared with var or within conditional blocks.
REMARKS:: This is the mutable assignment operator.
--- Entry: ?: ---
NAME:: ?:
TYPE:: Conditional (Ternary) Operator
DESCRIPTION:: expr1 ? expr2 : expr3. Returns expr2 if expr1 is true, otherwise returns expr3. A shorthand for a single-line if...else.
RETURNS:: The type of expr2 or expr3 (must match).
--- Entry: [] ---
NAME:: []
TYPE:: Indexing Operator (Series Subscript)
DESCRIPTION:: Series Subscript. Provides access to previous bar values of a series expression. The number in brackets is the lookback distance (e.g., close[1]).
RETURNS:: A series value of the indexed expression's type.
--- Entry: => ---
NAME:: =>
TYPE:: Function/Block Operator
DESCRIPTION:: Used in user-defined function declarations to separate the signature from the body/return, and in switch statements to separate a case from its corresponding block.
REMARKS:: Defines a function's structure.
# ---------------------------------------------------------------------------------------------------------------
# ANNOTATIONS
--- Entry: @version= ---
NAME:: @version=
USE:: Compiler Directive
DESCRIPTION:: Specifies the Pine Script language version to use for compiling the script (e.g., //@version=5). This should always be included for compatibility and access to modern features.
PLACEMENT:: Recommended at the very top of the script.
--- Entry: @description ---
NAME:: @description
USE:: Script/Library Documentation
DESCRIPTION:: Sets a custom description for the entire script, particularly used when a script is declared as a library. This text pre-fills the "Description" field in the publication dialog.
PLACEMENT:: Generally near the top, often after //@version=.
--- Entry: @function ---
NAME:: @function
USE:: Function Documentation
DESCRIPTION:: Adds a custom description for a function. This text is displayed in the Pine Editor's autosuggest tooltips when a user hovers over the function name.
PLACEMENT:: Immediately above the function declaration.
--- Entry: @param ---
NAME:: @param
USE:: Function Parameter Documentation
DESCRIPTION:: Adds a custom description for a specific function parameter. Syntax requires the parameter name followed by its description (e.g., //@param length The lookback period in bars.).
PLACEMENT:: Below //@function and above the function declaration.
--- Entry: @returns ---
NAME:: @returns
USE:: Function Return Documentation
DESCRIPTION:: Adds a custom description for what the function returns (its output).
PLACEMENT:: Below //@param annotations and above the function declaration.
--- Entry: @type ---
NAME:: @type
USE:: User-Defined Type Documentation
DESCRIPTION:: Adds a custom description for a User-Defined Type (type). This is used for tooltips in the Pine Editor.
PLACEMENT:: Immediately above the type declaration.
--- Entry: @enum ---
NAME:: @enum
USE:: Enumeration Documentation
DESCRIPTION:: Adds a custom description for an enumeration (enum) declaration. This is used for tooltips and library publication descriptions.
PLACEMENT:: Immediately above the enum declaration.
--- Entry: @field ---
NAME:: @field
USE:: Type/Enum Field Documentation
DESCRIPTION:: Adds a custom description for a specific field within a type or enum. Syntax requires the field name followed by its description (e.g., //@field price The y-coordinate of the point.).
PLACEMENT:: Below the //@type or //@enum annotation.
--- Entry: @variable ---
NAME:: @variable
USE:: Variable Documentation
DESCRIPTION:: Adds a custom description for a variable declaration. This appears in the Pine Editor's tooltips when hovering over the variable name.
PLACEMENT:: Immediately above the variable declaration.
--- Entry: @strategy_alert_message ---
NAME:: @strategy_alert_message
USE:: Strategy Alert Message
DESCRIPTION:: Provides a default message to pre-fill the "Message" field in the alert creation dialog for a strategy script. Supports placeholder variables like {{ticker}}.
PLACEMENT:: Near the top, after the strategy() call.
Overview
The runnable code is a minimal indicator that plots the bar index in a separate pane and plots the close only after bar 5000, otherwise zero. It has one input defined for a bar count, and notes that bar index based logic can repaint. It is a learning aid, not an analysis tool.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Bars Count:
int
100
lastBarsFilterInput
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t
This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div
Range Volume Change compares volume inside a chosen session window with the same window on the previous day and plots that change as a percentage. It accumulates volume during the window and, when enabled, volume outside it, drawing growing columns in a separa
This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome
This indicator plots the Average Directional Index in a separate pane and colors the line teal or maroon according to whether plus DI is above minus DI. A horizontal key level and a silver background mark periods when ADX exceeds that threshold. With labels en
The Mojito v3 Strategy indicator evaluates volatility term structure by calculating the ratio between front-month and second-month VIX futures contracts. It smooths this ratio using a configurable median filter and compares the result against user-defined uppe