Pine Script Learning Resources
A curated collection of the best Pine Script resources, documentation, tutorials, and tools to accelerate your trading automation journey.
Where can I find Pine Script strategy examples and reference?
Your language reference is TradingView's own Pine Script v6 User Manual, and it is free. For worked examples, three places pay off, and the largest of them is the least reliable. The manual is authoritative, the public script library is the biggest collection of real code, and the PineCoders community writes the conventions the other two mostly ignore.
TradingView gives a script two minutes to compile, and after three consecutive warnings it enforces a one-hour ban on compilation attempts.
TradingView Pine Script v6 User Manual, Limitations. Source checked 28 October 2026.
Pine Script Documentation Hub
Every Pine Script version, its documentation, and a searchable reference manual, in one place.
Key Features
Interactive Reference Manual
v6Every entry of TradingView's Pine Script v6 reference, searchable. Open any row to land on it in the official reference.
935 entries
Press / to search- -operatorbuilt-in
Subtraction or unary minus. Applicable to numerical expressions.
expr1 - expr2
- -=operatorbuilt-in
Subtraction assignment. Applicable to numerical expressions.
expr1 -= expr2
- :=operatorbuilt-in
Reassignment operator. It is used to assign a new value to a previously declared variable.
<var_name> := <new_value>
- !=operatorbuilt-in
Inequality operator. Returns true if the operands are considered not equal, and false otherwise. This operator is compatible with all value types, including "int", "float", "bool", "color", and "string". The operator can also compare two line or label IDs.
expr1 != expr2
- ?:operatorbuilt-in
Ternary conditional operator.
expr1 ? expr2 : expr3
- []operatorbuilt-in
Series subscript. Provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical. Floats will be rounded down.
expr1[expr2]
- *operatorbuilt-in
Multiplication. Applicable to numerical expressions.
expr1 * expr2
- *=operatorbuilt-in
Multiplication assignment. Applicable to numerical expressions.
expr1 *= expr2
- /operatorbuilt-in
Division. Applicable to numerical expressions.
expr1 / expr2
- /=operatorbuilt-in
Division assignment. Applicable to numerical expressions.
expr1 /= expr2
- %operatorbuilt-in
Modulo (integer remainder). Applicable to numerical expressions.
expr1 % expr2
- %=operatorbuilt-in
Modulo assignment. Applicable to numerical expressions.
expr1 %= expr2
- +operatorbuilt-in
Addition or unary plus. Applicable to numerical expressions or strings.
expr1 + expr2
- +=operatorbuilt-in
Addition assignment. Applicable to numerical expressions or strings.
expr1 += expr2
- <operatorbuilt-in
Less than. Applicable to numerical expressions.
expr1 < expr2
- <=operatorbuilt-in
Less than or equal to. Applicable to numerical expressions.
expr1 <= expr2
- =operatorbuilt-in
Assignment operator. Assigns an initial value or reference to a declared variable. It means this is a new variable, and it starts with this value.
<var_name> := <initial_value>
- ==operatorbuilt-in
Equality operator. Returns true if the operands are considered equal, and false otherwise. This operator is compatible with all value types, including "int", "float", "bool", "color", and "string". The operator can also compare two line or label IDs.
expr1 == expr2
- =>operatorbuilt-in
The '=>' operator is used in user-defined function declarations and in switch statements.
<identifier>([<parameter_name>[=<default_value>]], ...) => <local_block> <function_result>
- >operatorbuilt-in
Greater than. Applicable to numerical expressions.
expr1 > expr2
- >=operatorbuilt-in
Greater than or equal to. Applicable to numerical expressions.
expr1 >= expr2
- adjustment.dividendsvariableadjustment
Constant for dividends adjustment type (dividends adjustment is applied).
- adjustment.nonevariableadjustment
Constant for none adjustment type (no adjustment is applied).
- adjustment.splitsvariableadjustment
Constant for splits adjustment type (splits adjustment is applied).
- alertfunctionbuilt-in
Creates an alert trigger for an indicator or strategy, with a specified frequency, when called on the latest realtime bar. To activate alerts for a script containing calls to this function, open the "Create Alert" dialog box, then select the script name and "Any alert() function…
alert(message, freq) → void
- alert.freq_allvariablealert
A named constant for use with the freq parameter of the alert() function.
- alert.freq_once_per_barvariablealert
A named constant for use with the freq parameter of the alert() function.
- alert.freq_once_per_bar_closevariablealert
A named constant for use with the freq parameter of the alert() function.
- alertconditionfunctionbuilt-in
Creates alert condition, that is available in Create Alert dialog. Please note, that alertcondition() does NOT create an alert, it just gives you more options in Create Alert dialog. Also, alertcondition() effect is invisible on chart.
alertcondition(condition, title, message) → void
- andkeywordbuilt-in
Logical AND. Applicable to boolean expressions.
expr1 and expr2
- arraytypebuilt-in
Keyword used to explicitly declare the "array" type of a variable or a parameter. Array objects (or IDs) can be created with the array.new<type>(), array.from() function.
- array.absfunctionarray
Returns an array containing the absolute value of each element in the original array.
array.abs(id) → array<float>
- array.avgfunctionarray
The function returns the mean of an array's elements.
array.avg(id) → series float
- array.binary_searchfunctionarray
Performs a binary search through a sorted array to locate an element corresponding to a target value. The function returns an element's index if the value from that element equals the target value. Otherwise, it returns -1.
array.binary_search(id, val) → series int
- array.binary_search_leftmostfunctionarray
Performs a binary search through a sorted array to locate an element corresponding to a target value. If the function locates the target value in the array's elements or referenced object fields, it returns the index of the first element whose retrieved value equals that value.
array.binary_search_leftmost(id, val) → series int
- array.binary_search_rightmostfunctionarray
Performs a binary search through a sorted array to locate an element corresponding to a target value. If the function locates the target value in the array's elements or referenced object fields, it returns the index of the last element whose retrieved value equals that value.
array.binary_search_rightmost(id, val) → series int
- array.clearfunctionarray
The function removes all elements from an array.
array.clear(id) → void
- array.concatfunctionarray
The function is used to merge two arrays. It pushes all elements from the second array to the first array, and returns the first array.
array.concat(id1, id2) → array<type>
- array.copyfunctionarray
The function creates a copy of an existing array.
array.copy(id) → array<type>
- array.covariancefunctionarray
The function returns the covariance of two arrays.
array.covariance(id1, id2, biased) → series float
- array.everyfunctionarray
Returns true if all elements of the id array are true, false otherwise.
array.every(id) → series bool
- array.fillfunctionarray
The function sets elements of an array to a single value. If no index is specified, all elements are set. If only a start index (default 0) is supplied, the elements starting at that index are set.
array.fill(id, value, index_from, index_to) → void
- array.firstfunctionarray
Returns the array's first element. Throws a runtime error if the array is empty.
array.first(id) → series <type>
- array.fromfunctionarray
The function takes a variable number of arguments with one of the types: int, float, bool, string, label, line, color, box, table, linefill, and returns an array of the corresponding type.
array.from(arg0, arg1, ...) → array<type>
- array.getfunctionarray
The function returns the value of the element at the specified index.
array.get(id, index) → series <type>
- array.includesfunctionarray
The function returns true if the value was found in an array, false otherwise.
array.includes(id, value) → series bool
- array.indexoffunctionarray
The function returns the index of the first occurrence of the value, or -1 if the value is not found.
array.indexof(id, value) → series int
- array.insertfunctionarray
The function changes the contents of an array by adding new elements in place.
array.insert(id, index, value) → void
- array.joinfunctionarray
The function creates and returns a new string by concatenating all the elements of an array, separated by the specified separator string.
array.join(id, separator) → series string
- array.lastfunctionarray
Returns the array's last element. Throws a runtime error if the array is empty.
array.last(id) → series <type>
- array.lastindexoffunctionarray
The function returns the index of the last occurrence of the value, or -1 if the value is not found.
array.lastindexof(id, value) → series int
- array.maxfunctionarray
The function returns the greatest value, or the nth greatest value in a given array.
array.max(id, nth) → series float
- array.medianfunctionarray
The function returns the median of an array's elements.
array.median(id) → series float
- array.minfunctionarray
The function returns the smallest value, or the nth smallest value in a given array.
array.min(id, nth) → series float
- array.modefunctionarray
The function returns the mode of an array's elements. If there are several values with the same frequency, it returns the smallest value.
array.mode(id) → series float
- array.new_boolfunctionarray
The function creates a new array object of bool type elements.
array.new_bool(size, initial_value) → array<bool>
- array.new_boxfunctionarray
The function creates a new array object of box type elements.
array.new_box(size, initial_value) → array<box>
- array.new_colorfunctionarray
The function creates a new array object of color type elements.
array.new_color(size, initial_value) → array<color>
- array.new_floatfunctionarray
The function creates a new array object of float type elements.
array.new_float(size, initial_value) → array<float>
- array.new_intfunctionarray
The function creates a new array object of int type elements.
array.new_int(size, initial_value) → array<int>
- array.new_labelfunctionarray
The function creates a new array object of label type elements.
array.new_label(size, initial_value) → array<label>
- array.new_linefunctionarray
The function creates a new array object of line type elements.
array.new_line(size, initial_value) → array<line>
- array.new_linefillfunctionarray
The function creates a new array object of linefill type elements.
array.new_linefill(size, initial_value) → array<linefill>
- array.new_stringfunctionarray
The function creates a new array object of string type elements.
array.new_string(size, initial_value) → array<string>
- array.new_tablefunctionarray
The function creates a new array object of table type elements.
array.new_table(size, initial_value) → array<table>
- array.new<type>functionarray
The function creates a new array object of <type> elements.
array.new<type>(size, initial_value) → array<type>
- array.percentile_linear_interpolationfunctionarray
Returns the value for which the specified percentage of array values (percentile) are less than or equal to it, using linear interpolation.
array.percentile_linear_interpolation(id, percentage) → series float
- array.percentile_nearest_rankfunctionarray
Returns the value for which the specified percentage of array values (percentile) are less than or equal to it, using the nearest-rank method.
array.percentile_nearest_rank(id, percentage) → series float
- array.percentrankfunctionarray
Returns the percentile rank of the element at the specified index.
array.percentrank(id, index) → series float
- array.popfunctionarray
The function removes the last element from an array and returns its value.
array.pop(id) → series <type>
- array.pushfunctionarray
The function appends a value to an array.
array.push(id, value) → void
- array.rangefunctionarray
The function returns the difference between the min and max values from a given array.
array.range(id) → series float
- array.removefunctionarray
The function changes the contents of an array by removing the element with the specified index.
array.remove(id, index) → series <type>
- array.reversefunctionarray
The function reverses an array. The first array element becomes the last, and the last array element becomes the first.
array.reverse(id) → void
- array.setfunctionarray
The function sets the value of the element at the specified index.
array.set(id, index, value) → void
- array.shiftfunctionarray
The function removes an array's first element and returns its value.
array.shift(id) → series <type>
- array.sizefunctionarray
The function returns the number of elements in an array.
array.size(id) → series int
- array.slicefunctionarray
Creates an array representing a slice of an existing array. Setting a slice's element to a new value changes the corresponding element in the original array to that value.
array.slice(id, index_from, index_to) → array<type>
- array.somefunctionarray
Returns true if at least one element of the id array is true, false otherwise.
array.some(id) → series bool
- array.sortfunctionarray
The function sorts the elements of an array.
array.sort(id, order) → void
- array.sort_indicesfunctionarray
Returns an array of indices which, when used to index the original array, will access its elements in their sorted order. It does not modify the original array.
array.sort_indices(id, order) → array<int>
- array.standardizefunctionarray
The function returns the array of standardized elements.
array.standardize(id) → array<float>
- array.stdevfunctionarray
The function returns the standard deviation of an array's elements.
array.stdev(id, biased) → series float
- array.sumfunctionarray
The function returns the sum of an array's elements.
array.sum(id) → series float
- array.unshiftfunctionarray
The function inserts the value at the beginning of the array.
array.unshift(id, value) → void
- array.variancefunctionarray
The function returns the variance of an array's elements.
array.variance(id, biased) → series float
- askvariablebuilt-in
The ask price at the time of the current tick, which represents the lowest price an active seller will accept for the instrument at its current value. This information is available only on the "1T" timeframe. On other timeframes, the variable's value is na.
- backadjustment.inheritvariablebackadjustment
A constant to specify the value of the backadjustment parameter in ticker.new() and ticker.modify() functions.
- backadjustment.offvariablebackadjustment
A constant to specify the value of the backadjustment parameter in ticker.new() and ticker.modify() functions.
- backadjustment.onvariablebackadjustment
A constant to specify the value of the backadjustment parameter in ticker.new() and ticker.modify() functions.
- bar_indexvariablebuilt-in
Current bar index. Numbering is zero-based, index of the first bar is 0.
- barcolorfunctionbuilt-in
Set color of bars.
barcolor(color, offset, editable, show_last, title, display) → void
- barmerge.gaps_offvariablebarmerge
Merge strategy for requested data. Data is merged continuously without gaps, all the gaps are filled with the previous nearest existing value.
- barmerge.gaps_onvariablebarmerge
Merge strategy for requested data. Data is merged with possible gaps (na values).
- barmerge.lookahead_offvariablebarmerge
Merge strategy for the requested data position. Requested barset is merged with current barset in the order of sorting bars by their close time. This merge strategy disables effect of getting data from "future" on calculation on history.
- barmerge.lookahead_onvariablebarmerge
Merge strategy for the requested data position. Requested barset is merged with current barset in the order of sorting bars by their opening time. This merge strategy can lead to undesirable effect of getting data from "future" on calculation on history.
- barstate.isconfirmedvariablebarstate
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.
- barstate.isfirstvariablebarstate
Returns true if current bar is first bar in barset, false otherwise.
- barstate.ishistoryvariablebarstate
Returns true if current bar is a historical bar, false otherwise.
- barstate.islastvariablebarstate
Returns true if current bar is the last bar in barset, false otherwise. This condition is true for all real-time bars in barset.
- barstate.islastconfirmedhistoryvariablebarstate
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.
- barstate.isnewvariablebarstate
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.
- barstate.isrealtimevariablebarstate
Returns true if current bar is a real-time bar, false otherwise.
- bgcolorfunctionbuilt-in
Fill background of bars with specified color.
bgcolor(color, offset, editable, show_last, title, display, force_overlay) → void
- bidvariablebuilt-in
The bid price at the time of the current tick, which represents the highest price an active buyer is willing to pay for the instrument at its current value. This information is available only on the "1T" timeframe. On other timeframes, the variable's value is na.
- booltypebuilt-in
Keyword used to explicitly declare the "bool" (boolean) type of a variable or a parameter. "Bool" variables can have values true or false.
- boolfunctionbuilt-in
Converts the x value to a bool value. Returns false if x is na, false, or an int/float value equal to 0. Returns true for all other possible values.
bool(x) → const bool
- boxtypebuilt-in
Keyword used to explicitly declare the "box" type of a variable or a parameter. Box objects (or IDs) can be created with the box.new() function.
- boxfunctionbuilt-in
Casts na to box.
box(x) → series box
- box.allvariablebox
Returns an array filled with all the current boxes drawn by the script.
- box.copyfunctionbox
Clones the box object.
box.copy(id) → series box
- box.deletefunctionbox
Deletes the specified box object. If it has already been deleted, does nothing.
box.delete(id) → void
- box.get_bottomfunctionbox
Returns the price value of the bottom border of the box.
box.get_bottom(id) → series float
- box.get_leftfunctionbox
Returns the bar index or the UNIX time (depending on the last value used for 'xloc') of the left border of the box.
box.get_left(id) → series int
- box.get_rightfunctionbox
Returns the bar index or the UNIX time (depending on the last value used for 'xloc') of the right border of the box.
box.get_right(id) → series int
- box.get_topfunctionbox
Returns the price value of the top border of the box.
box.get_top(id) → series float
- box.newfunctionbox
Creates a new box object.
box.new(top_left, bottom_right, border_color, border_width, border_style, extend, xloc, bgcolor, text, text_size, text_color, text_halign, text_valign, text_wrap, text_font_family, force_overlay, text_formatting) → series box
- box.set_bgcolorfunctionbox
Sets the background color of the box.
box.set_bgcolor(id, color) → void
- box.set_border_colorfunctionbox
Sets the border color of the box.
box.set_border_color(id, color) → void
- box.set_border_stylefunctionbox
Sets the border style of the box.
box.set_border_style(id, style) → void
- box.set_border_widthfunctionbox
Sets the border width of the box.
box.set_border_width(id, width) → void
- box.set_bottomfunctionbox
Sets the bottom coordinate of the box.
box.set_bottom(id, bottom) → void
- box.set_bottom_right_pointfunctionbox
Sets the bottom-right corner location of the id box to point.
box.set_bottom_right_point(id, point) → void
- box.set_extendfunctionbox
Sets extending type of the border of this box object. When extend.none is used, the horizontal borders start at the left border and end at the right border.
box.set_extend(id, extend) → void
- box.set_leftfunctionbox
Sets the left coordinate of the box.
box.set_left(id, left) → void
- box.set_lefttopfunctionbox
Sets the left and top coordinates of the box.
box.set_lefttop(id, left, top) → void
- box.set_rightfunctionbox
Sets the right coordinate of the box.
box.set_right(id, right) → void
- box.set_rightbottomfunctionbox
Sets the right and bottom coordinates of the box.
box.set_rightbottom(id, right, bottom) → void
- box.set_textfunctionbox
The function sets the text in the box.
box.set_text(id, text) → void
- box.set_text_colorfunctionbox
The function sets the color of the text inside the box.
box.set_text_color(id, text_color) → void
- box.set_text_font_familyfunctionbox
The function sets the font family of the text inside the box.
box.set_text_font_family(id, text_font_family) → void
- box.set_text_formattingfunctionbox
Sets the formatting attributes the drawing applies to displayed text.
box.set_text_formatting(id, text_formatting) → void
- box.set_text_halignfunctionbox
The function sets the horizontal alignment of the box's text.
box.set_text_halign(id, text_halign) → void
- box.set_text_sizefunctionbox
The function sets the size of the box's text.
box.set_text_size(id, text_size) → void
- box.set_text_valignfunctionbox
The function sets the vertical alignment of a box's text.
box.set_text_valign(id, text_valign) → void
- box.set_text_wrapfunctionbox
The function sets the mode of wrapping of the text inside the box.
box.set_text_wrap(id, text_wrap) → void
- box.set_topfunctionbox
Sets the top coordinate of the box.
box.set_top(id, top) → void
- box.set_top_left_pointfunctionbox
Sets the top-left corner location of the id box to point.
box.set_top_left_point(id, point) → void
- box.set_xlocfunctionbox
Sets the left and right borders of a box and updates its xloc property.
box.set_xloc(id, left, right, xloc) → void
- chart.bg_colorvariablechart
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.
- chart.fg_colorvariablechart
Returns a color providing optimal contrast with chart.bg_color.
- chart.is_heikinashivariablechart
simple bool
- chart.is_kagivariablechart
simple bool
- chart.is_linebreakvariablechart
simple bool
- chart.is_pnfvariablechart
simple bool
- chart.is_rangevariablechart
simple bool
- chart.is_renkovariablechart
simple bool
- chart.is_standardvariablechart
simple bool
- chart.left_visible_bar_timevariablechart
The time of the leftmost bar currently visible on the chart.
- chart.pointtypechart
Keyword to explicitly declare the type of a variable or parameter as chart.point. Scripts can produce chart.point instances using the chart.point.from_time(), chart.point.from_index(), chart.point.now(), and chart.point.new() functions.
- chart.point.copyfunctionchart
Creates a copy of a chart.point object with the specified id.
chart.point.copy(id) → chart.point
- chart.point.from_indexfunctionchart
Returns a chart.point object with index as its x-coordinate and price as its y-coordinate.
chart.point.from_index(index, price) → chart.point
- chart.point.from_timefunctionchart
Returns a chart.point object with time as its x-coordinate and price as its y-coordinate.
chart.point.from_time(time, price) → chart.point
- chart.point.newfunctionchart
Creates a new chart.point object with the specified time, index, and price.
chart.point.new(time, index, price) → chart.point
- chart.point.nowfunctionchart
Returns a chart.point object with price as the y-coordinate
chart.point.now(price) → chart.point
- chart.right_visible_bar_timevariablechart
The time of the rightmost bar currently visible on the chart.
- closevariablebuilt-in
Close price of the current bar when it has closed, or last traded price of a yet incomplete, realtime bar.
- colortypebuilt-in
Keyword used to explicitly declare the "color" type of a variable or a parameter.
- colorfunctionbuilt-in
Casts na to color
color(x) → const color
- color.aquavariablecolor
Is a named constant for #00BCD4 color.
- color.bfunctioncolor
Retrieves the value of the color's blue component.
color.b(color) → const float
- color.blackvariablecolor
Is a named constant for #363A45 color.
- color.bluevariablecolor
Is a named constant for #2962ff color.
- color.from_gradientfunctioncolor
Based on the relative position of value in the bottom_value to top_value range, the function returns a color from the gradient defined by bottom_color to top_color.
color.from_gradient(value, bottom_value, top_value, bottom_color, top_color) → series color
- color.fuchsiavariablecolor
Is a named constant for #E040FB color.
- color.gfunctioncolor
Retrieves the value of the color's green component.
color.g(color) → const float
- color.grayvariablecolor
Is a named constant for #787B86 color.
- color.greenvariablecolor
Is a named constant for #4CAF50 color.
- color.limevariablecolor
Is a named constant for #00E676 color.
- color.maroonvariablecolor
Is a named constant for #880E4F color.
- color.navyvariablecolor
Is a named constant for #311B92 color.
- color.newfunctioncolor
Function color applies the specified transparency to the given color.
color.new(color, transp) → const color
- color.olivevariablecolor
Is a named constant for #808000 color.
- color.orangevariablecolor
Is a named constant for #FF9800 color.
- color.purplevariablecolor
Is a named constant for #9C27B0 color.
- color.rfunctioncolor
Retrieves the value of the color's red component.
color.r(color) → const float
- color.redvariablecolor
Is a named constant for #F23645 color.
- color.rgbfunctioncolor
Creates a new color with transparency using the RGB color model.
color.rgb(red, green, blue, transp) → const color
- color.silvervariablecolor
Is a named constant for #B2B5BE color.
- color.tfunctioncolor
Retrieves the color's transparency.
color.t(color) → const float
- color.tealvariablecolor
Is a named constant for #089981 color.
- color.whitevariablecolor
Is a named constant for #FFFFFF color.
- color.yellowvariablecolor
Is a named constant for #FDD835 color.
- consttypebuilt-in
The const keyword explicitly assigns the "const" type qualifier to variables and the parameters of non-exported functions. Variables and parameters with the "const" qualifier reference values established at compile time that never change in the script's execution.
[method ]<functionName>([const <paramType> ]<paramName>[ = <defaultValue>]) [var/varip ]const <variableType> <variableName> = <variableValue>
- currency.AEDvariablecurrency
Arab Emirates Dirham.
- currency.ARSvariablecurrency
Argentine Pesos.
- currency.AUDvariablecurrency
Australian dollar.
- currency.BDTvariablecurrency
Bangladeshi Taka.
- currency.BHDvariablecurrency
Bahraini Dinar.
- currency.BRLvariablecurrency
Brazilian real.
- currency.BTCvariablecurrency
Bitcoin.
- currency.CADvariablecurrency
Canadian dollar.
- currency.CHFvariablecurrency
Swiss franc.
- currency.CLPvariablecurrency
Chilean Peso.
- currency.CNYvariablecurrency
Chinese Yuan.
- currency.COPvariablecurrency
Colombian Peso.
- currency.CZKvariablecurrency
Czech Koruna.
- currency.DKKvariablecurrency
Danish Krone.
- currency.EGPvariablecurrency
Egyptian pound.
- currency.ETHvariablecurrency
Ethereum.
- currency.EURvariablecurrency
Euro.
- currency.GBPvariablecurrency
Pound sterling.
- currency.HKDvariablecurrency
Hong Kong dollar.
- currency.HUFvariablecurrency
Hungarian Forint.
- currency.IDRvariablecurrency
Indonesian Rupiah.
- currency.ILSvariablecurrency
Israeli New Shekel.
- currency.INRvariablecurrency
Indian rupee.
- currency.ISKvariablecurrency
Icelandic Krona.
- currency.JPYvariablecurrency
Japanese yen.
- currency.KESvariablecurrency
Kenyan Shilling.
- currency.KRWvariablecurrency
South Korean won.
- currency.KWDvariablecurrency
Kuwaiti Dinar.
- currency.LKRvariablecurrency
Sri Lankan Rupee.
- currency.MADvariablecurrency
Moroccan Dirham.
- currency.MXNvariablecurrency
Mexican Peso.
- currency.MYRvariablecurrency
Malaysian ringgit.
- currency.NGNvariablecurrency
Nigerian Naira.
- currency.NOKvariablecurrency
Norwegian krone.
- currency.NONEvariablecurrency
Unspecified currency.
- currency.NZDvariablecurrency
New Zealand dollar.
- currency.PENvariablecurrency
Peruvian sol.
- currency.PHPvariablecurrency
Philippine Peso.
- currency.PKRvariablecurrency
Pakistani rupee.
- currency.PLNvariablecurrency
Polish zloty.
- currency.QARvariablecurrency
Qatari Riyal.
- currency.RONvariablecurrency
Romanian Leu.
- currency.RSDvariablecurrency
Serbian Dinar.
- currency.RUBvariablecurrency
Russian ruble.
- currency.SARvariablecurrency
Saudi Riyal.
- currency.SEKvariablecurrency
Swedish krona.
- currency.SGDvariablecurrency
Singapore dollar.
- currency.THBvariablecurrency
Thai Baht.
- currency.TNDvariablecurrency
Tunisian Dinar.
- currency.TRYvariablecurrency
Turkish lira.
- currency.TWDvariablecurrency
New Taiwan Dollar.
- currency.USDvariablecurrency
United States dollar.
- currency.USDTvariablecurrency
Tether.
- currency.VESvariablecurrency
Venezuelan Bolivar.
- currency.VNDvariablecurrency
Vietnamese Dong.
- currency.ZARvariablecurrency
South African rand.
- dayofmonthvariablebuilt-in
The day number of the month, in the exchange time zone, calculated from the bar's opening UNIX timestamp.
- dayofmonthfunctionbuilt-in
Calculates the day number of the month, in a specified time zone, from a UNIX timestamp.
dayofmonth(time, timezone) → series int
- dayofweekvariablebuilt-in
The day number of the week, in the exchange time zone, calculated from the bar's opening UNIX timestamp.
- dayofweekfunctionbuilt-in
Calculates the day number of the week, in a specified time zone, from a UNIX timestamp.
dayofweek(time, timezone) → series int
- dayofweek.fridayvariabledayofweek
Is a named constant for return value of dayofweek() function and value of dayofweek variable.
- dayofweek.mondayvariabledayofweek
Is a named constant for return value of dayofweek() function and value of dayofweek variable.
- dayofweek.saturdayvariabledayofweek
Is a named constant for return value of dayofweek() function and value of dayofweek variable.
- dayofweek.sundayvariabledayofweek
Is a named constant for return value of dayofweek() function and value of dayofweek variable.
- dayofweek.thursdayvariabledayofweek
Is a named constant for return value of dayofweek() function and value of dayofweek variable.
- dayofweek.tuesdayvariabledayofweek
Is a named constant for return value of dayofweek() function and value of dayofweek variable.
- dayofweek.wednesdayvariabledayofweek
Is a named constant for return value of dayofweek() function and value of dayofweek variable.
- display.allvariabledisplay
A named constant for use with the display parameter of the plot*(), input*(), fill(), bgcolor(), barcolor(), and hline() functions. Specifies that the values or visuals appear in all possible locations by default.
- display.data_windowvariabledisplay
A named constant for use with the display parameter of the plot*() and input*() functions. Specifies that the values are available in the Data Window by default. The Data Window tab is accessible by clicking the "Object Tree and Data Window" icon in the chart's right sidebar.
- display.nonevariabledisplay
A named constant for use with the display parameter of the plot*(), input*(), fill(), bgcolor(), barcolor(), and hline() functions. Specifies that the values or visuals are not displayed anywhere by default.
- display.panevariabledisplay
A named constant for use with the display parameter of the plot*() functions. Specifies that the plotted values are displayed in a chart pane by default.
- display.pine_screenervariabledisplay
A named constant for use with the display parameter of the plot() function. Specifies that, by default, the Pine Screener displays a column for the plot's values when the user applies the indicator to the chosen watchlist.
- display.price_scalevariabledisplay
A named constant for use with the display parameter of the plot*() functions. Specifies that the price scale displays a label for the plot's data, but only if the chart's settings allow it.
- display.status_linevariabledisplay
A named constant for use with the display parameter of the plot*() and input*() functions. Specifies that the values are available in the script's status line, but only if the chart's settings allow it.
- dividends.future_amountvariabledividends
Returns the payment amount of the upcoming dividend in the currency of the current instrument, or na if this data isn't available.
- dividends.future_ex_datevariabledividends
Returns the Ex-dividend date (Ex-date) of the current instrument's next dividend payment, or na if this data isn't available. Ex-dividend date signifies when investors are no longer entitled to a payout from the most recent dividend.
- dividends.future_pay_datevariabledividends
Returns the Payment date (Pay date) of the current instrument's next dividend payment, or na if this data isn't available. Payment date signifies the day when eligible investors will receive the dividend payment.
- dividends.grossvariabledividends
A named constant for the request.dividends() function. Is used to request the dividends return on a stock before deductions.
- dividends.netvariabledividends
A named constant for the request.dividends() function. Is used to request the dividends return on a stock after deductions.
- earnings.actualvariableearnings
A named constant for the request.earnings() function. Is used to request the earnings value as it was reported.
- earnings.estimatevariableearnings
A named constant for the request.earnings() function. Is used to request the estimated earnings value.
- earnings.future_epsvariableearnings
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.
- earnings.future_period_end_timevariableearnings
Checks the data for the next earnings report and returns the UNIX timestamp of the day when the financial period covered by those earnings ends, or na if this data isn't available.
- earnings.future_revenuevariableearnings
Returns the estimated Revenue of the next earnings report in the currency of the instrument, or na if this data isn't available.
- earnings.future_timevariableearnings
Returns a UNIX timestamp indicating the expected time of the next earnings report, or na if this data isn't available.
- earnings.standardizedvariableearnings
A named constant for the request.earnings() function. Is used to request the standardized earnings value.
- enumkeywordbuilt-in
This keyword allows the creation of an enumeration, enum for short. Enums are unique constructs that hold groups of predefined constants.
[export ]enum <enumName> <field_1> [= <title_1>] <field_2> [= <title_2>] ... <field_N> [= <title_N>]
- exportkeywordbuilt-in
Used in libraries to prefix the declaration of functions or user-defined type definitions that will be available from other scripts importing the library.
- extend.bothvariableextend
A named constant for line.new() and line.set_extend() functions.
- extend.leftvariableextend
A named constant for line.new() and line.set_extend() functions.
- extend.nonevariableextend
A named constant for line.new() and line.set_extend() functions.
- extend.rightvariableextend
A named constant for line.new() and line.set_extend() functions.
- falsevariablebuilt-in
Literal representing a bool value, and result of a comparison operation.
- fillfunctionbuilt-in
Fills background between two plots or hlines with a given color.
fill(hline1, hline2, color, title, editable, fillgaps, display) → void
- fixnanfunctionbuilt-in
For a given series replaces NaN values with previous nearest non-NaN value.
fixnan(source) → series color
- floattypebuilt-in
Keyword used to explicitly declare the "float" (floating point) type of a variable or a parameter.
- floatfunctionbuilt-in
Casts na to float
float(x) → const float
- font.family_defaultvariablefont
Default text font for box.new(), box.set_text_font_family(), label.new(), label.set_text_font_family(), table.cell() and table.cell_set_text_font_family() functions.
- font.family_monospacevariablefont
Monospace text font for box.new(), box.set_text_font_family(), label.new(), label.set_text_font_family(), table.cell() and table.cell_set_text_font_family() functions.
- footprinttypebuilt-in
A keyword that explicitly declares the type of a variable or parameter as footprint. Scripts create objects of the footprint type by calling the request.footprint() function.
- footprint.buy_volumefunctionfootprint
Calculates the total "buy" volume for the volume footprint represented by a footprint object.
footprint.buy_volume(id) → series float
- footprint.deltafunctionfootprint
Calculates the overall volume delta for the volume footprint represented by a footprint object. The value represents the difference between the footprint's total "buy" volume and "sell" volume.
footprint.delta(id) → series float
- footprint.get_row_by_pricefunctionfootprint
Analyzes the volume footprint represented by a footprint object to find the row whose price range includes the specified price level. If the price belongs to one of the rows, the function returns the ID of the volume_row object that contains the data for that row.
footprint.get_row_by_price(id, price) → volume_row
- footprint.pocfunctionfootprint
Finds the Point of Control (POC) row for the volume footprint represented by a footprint object, then returns the ID of a volume_row object containing the data for that row.
footprint.poc(id) → volume_row
- footprint.rowsfunctionfootprint
Creates an array containing all volume_row IDs from a footprint object. Each volume_row object referenced in the array contains data for one row in the calculated volume footprint, where the first object represents the lowest row and the last one represents the highest row.
footprint.rows(id) → array<volume_row>
- footprint.sell_volumefunctionfootprint
Calculates the total "sell" volume for the volume footprint represented by a footprint object.
footprint.sell_volume(id) → series float
- footprint.total_volumefunctionfootprint
Calculates the sum of the total "buy" volume and "sell" volume for the volume footprint represented by a footprint object.
footprint.total_volume(id) → series float
- footprint.vahfunctionfootprint
Finds the Value Area High (VAH) row for the volume footprint represented by a footprint object, then returns the ID of a volume_row object containing the data for that row.
footprint.vah(id) → volume_row
- footprint.valfunctionfootprint
Finds the Value Area Low (VAL) row for the volume footprint represented by a footprint object, then returns the ID of a volume_row object containing the data for that row.
footprint.val(id) → volume_row
- forkeywordbuilt-in
Creates a count-controlled loop, which uses a counter variable to manage the iterative executions of its local code block. The loop continues new iterations until the counter reaches a specified final value.
[variables =|:=] for counter = from_num to to_num [by step_num] statements | continue | break return_expression
- for...inkeywordfor
Creates a collection-controlled loop, which iterates over the elements of an array, the rows of a matrix, or the key-value pairs of a map in order. The loop's local code block executes once for each element, row, or pair in the specified collection.
[variables = | :=] for item in collection_id statements | continue | break return_expression [variables = | :=] for [index, item] in collection_id statements | continue | break return_expression
- format.inheritvariableformat
Is a named constant for selecting the formatting of the script output values from the parent series in the indicator() function.
- format.mintickvariableformat
Is a named constant to use with the str.tostring() function. Passing a number to str.tostring() with this argument rounds the number to the nearest value that can be divided by syminfo.mintick, without the remainder, with ties rounding up, and returns the string version of said…
- format.percentvariableformat
Is a named constant for selecting the formatting of the script output values as a percentage in the indicator function. It adds a percent sign after values.
- format.pricevariableformat
Is a named constant for selecting the formatting of the script output values as prices in the indicator() function.
- format.volumevariableformat
Is a named constant for selecting the formatting of the script output values as volume in the indicator() function, e.g. '5183' will be formatted as '5.183K'.
- highvariablebuilt-in
Current high price.
- hl2variablebuilt-in
Is a shortcut for (high + low)/2
- hlc3variablebuilt-in
Is a shortcut for (high + low + close)/3
- hlcc4variablebuilt-in
Is a shortcut for (high + low + close + close)/4
- hlinefunctionbuilt-in
Renders a horizontal line at a given fixed price level.
hline(price, title, color, linestyle, linewidth, editable, display) → hline
- hline.style_dashedvariablehline
Is a named constant for dashed linestyle of hline() function.
- hline.style_dottedvariablehline
Is a named constant for dotted linestyle of hline() function.
- hline.style_solidvariablehline
Is a named constant for solid linestyle of hline() function.
- hourvariablebuilt-in
Current bar hour in exchange timezone.
- hourfunctionbuilt-in
time (series int) UNIX time in milliseconds.
hour(time, timezone) → series int
- ifkeywordbuilt-in
If statement defines what block of statements must be executed when conditions of the expression are satisfied.
var_declarationX = if condition var_decl_then0 var_decl_then1 … var_decl_thenN else if [optional block] var_decl_else0 var_decl_else1 … var_decl_elseN else var_decl_else0 var_decl_else1 … var_decl_elseN return_expression_else
- importkeywordbuilt-in
Used to load an external library() into a script and bind its functions to a namespace. The importing script can be an indicator, a strategy, or another library. A library must be published (privately or publicly) before it can be imported.
import {username}/{libraryName}/{libraryVersion} as {alias}
- indicatorfunctionbuilt-in
A declaration statement that identifies the script as an indicator and sets specific script-wide properties.
indicator(title, shorttitle, overlay, format, precision, scale, max_bars_back, timeframe, timeframe_gaps, explicit_plot_zorder, max_lines_count, max_labels_count, max_boxes_count, calc_bars_count, max_polylines_count, dynamic_requests, behind_chart) → void
- inputfunctionbuilt-in
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function automatically detects the type of the argument used for 'defval' and uses the corresponding input widget.
input(defval, title, tooltip, inline, group, display, active) → input color
- input.boolfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a checkmark to the script's inputs.
input.bool(defval, title, tooltip, inline, group, confirm, display, active) → input bool
- input.colorfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a color picker that allows the user to select a color and transparency, either from a palette or a hex value.
input.color(defval, title, tooltip, inline, group, confirm, display, active) → input color
- input.enumfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a dropdown with options based on the enum fields passed to its defval and options parameters.
input.enum(defval, title, options, tooltip, inline, group, confirm, display, active) → input enum
- input.floatfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a field for a float input to the script's inputs.
input.float(defval, title, options, tooltip, inline, group, confirm, display, active) → input float
- input.intfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a field for an integer input to the script's inputs.
input.int(defval, title, options, tooltip, inline, group, confirm, display, active) → input int
- input.pricefunctioninput
Adds a price input to the script's "Settings/Inputs" tab. The user can change the price in the settings or by selecting the indicator and dragging the price line.
input.price(defval, title, tooltip, inline, group, confirm, display, active) → input float
- input.sessionfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds two dropdowns that allow the user to specify the beginning and the end of a session using the session selector and returns the result…
input.session(defval, title, options, tooltip, inline, group, confirm, display, active) → input string
- input.sourcefunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a dropdown that allows the user to select a source for the calculation, e.g. close, hl2, etc.
input.source(defval, title, tooltip, inline, group, display, active, confirm) → series float
- input.stringfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a field for a string input to the script's inputs.
input.string(defval, title, options, tooltip, inline, group, confirm, display, active) → input string
- input.symbolfunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a field that allows the user to select a specific symbol using the symbol search and returns that symbol, paired with its exchange…
input.symbol(defval, title, tooltip, inline, group, confirm, display, active) → input string
- input.text_areafunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a field for a multiline text input.
input.text_area(defval, title, tooltip, group, confirm, display, active) → input string
- input.timefunctioninput
Adds two inputs to the script's "Settings/Inputs" tab on the same line: one for the date and one for the time. The user can change the price in the settings or by selecting the indicator and dragging the price line. The function returns a date/time value in UNIX format.
input.time(defval, title, tooltip, inline, group, confirm, display, active) → input int
- input.timeframefunctioninput
Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a dropdown that allows the user to select a specific timeframe via the timeframe selector and returns it as a string.
input.timeframe(defval, title, options, tooltip, inline, group, confirm, display, active) → input string
- inttypebuilt-in
Keyword used to explicitly declare the "int" (integer) type of a variable or a parameter.
- intfunctionbuilt-in
Casts na or truncates float value to int
int(x) → const int
- labeltypebuilt-in
Keyword used to explicitly declare the "label" type of a variable or a parameter. Label objects (or IDs) can be created with the label.new() function.
- labelfunctionbuilt-in
Casts na to label
label(x) → series label
- label.allvariablelabel
Returns an array filled with all the current labels drawn by the script.
- label.copyfunctionlabel
Clones the label object.
label.copy(id) → series label
- label.deletefunctionlabel
Deletes the specified label object. If it has already been deleted, does nothing.
label.delete(id) → void
- label.get_textfunctionlabel
Returns the text of this label object.
label.get_text(id) → series string
- label.get_xfunctionlabel
Returns UNIX time or bar index (depending on the last xloc value set) of this label's position.
label.get_x(id) → series int
- label.get_yfunctionlabel
Returns price of this label's position.
label.get_y(id) → series float
- label.newfunctionlabel
Creates new label object.
label.new(point, text, xloc, yloc, color, style, textcolor, size, textalign, tooltip, text_font_family, force_overlay, text_formatting) → series label
- label.set_colorfunctionlabel
Sets label border and arrow color.
label.set_color(id, color) → void
- label.set_pointfunctionlabel
Sets the location of the id label to point.
label.set_point(id, point) → void
- label.set_sizefunctionlabel
Sets arrow and text size of the specified label object.
label.set_size(id, size) → void
- label.set_stylefunctionlabel
Sets label style.
label.set_style(id, style) → void
- label.set_textfunctionlabel
Sets label text
label.set_text(id, text) → void
- label.set_text_font_familyfunctionlabel
The function sets the font family of the text inside the label.
label.set_text_font_family(id, text_font_family) → void
- label.set_text_formattingfunctionlabel
Sets the formatting attributes the drawing applies to displayed text.
label.set_text_formatting(id, text_formatting) → void
- label.set_textalignfunctionlabel
Sets the alignment for the label text.
label.set_textalign(id, textalign) → void
- label.set_textcolorfunctionlabel
Sets color of the label text.
label.set_textcolor(id, textcolor) → void
- label.set_tooltipfunctionlabel
Sets the tooltip text.
label.set_tooltip(id, tooltip) → void
- label.set_xfunctionlabel
Sets bar index or bar time (depending on the xloc) of the label position.
label.set_x(id, x) → void
- label.set_xlocfunctionlabel
Sets x-location and new bar index/time value.
label.set_xloc(id, x, xloc) → void
- label.set_xyfunctionlabel
Sets bar index/time and price of the label position.
label.set_xy(id, x, y) → void
- label.set_yfunctionlabel
Sets price of the label position
label.set_y(id, y) → void
- label.set_ylocfunctionlabel
Sets new y-location calculation algorithm.
label.set_yloc(id, yloc) → void
- label.style_arrowdownvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_arrowupvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_circlevariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_crossvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_diamondvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_flagvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_centervariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_downvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_leftvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_lower_leftvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_lower_rightvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_rightvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_upvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_upper_leftvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_label_upper_rightvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_nonevariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_squarevariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_text_outlinevariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_triangledownvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_triangleupvariablelabel
Label style for label.new() and label.set_style() functions.
- label.style_xcrossvariablelabel
Label style for label.new() and label.set_style() functions.
- last_bar_indexvariablebuilt-in
Bar index of the last chart bar. Bar indices begin at zero on the first bar.
- last_bar_timevariablebuilt-in
Time in UNIX format of the last chart bar. It is the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970.
- libraryfunctionbuilt-in
Declaration statement identifying a script as a library.
library(title, overlay, dynamic_requests) → void
- linetypebuilt-in
Keyword used to explicitly declare the "line" type of a variable or a parameter. Line objects (or IDs) can be created with the line.new() function.
- linefunctionbuilt-in
Casts na to line
line(x) → series line
- line.allvariableline
Returns an array filled with all the current lines drawn by the script.
- line.copyfunctionline
Clones the line object.
line.copy(id) → series line
- line.deletefunctionline
Deletes the specified line object. If it has already been deleted, does nothing.
line.delete(id) → void
- line.get_pricefunctionline
Returns the price level of a line at a given bar index.
line.get_price(id, x) → series float
- line.get_x1functionline
Returns UNIX time or bar index (depending on the last xloc value set) of the first point of the line.
line.get_x1(id) → series int
- line.get_x2functionline
Returns UNIX time or bar index (depending on the last xloc value set) of the second point of the line.
line.get_x2(id) → series int
- line.get_y1functionline
Returns price of the first point of the line.
line.get_y1(id) → series float
- line.get_y2functionline
Returns price of the second point of the line.
line.get_y2(id) → series float
- line.newfunctionline
Creates new line object.
line.new(first_point, second_point, xloc, extend, color, style, width, force_overlay) → series line
- line.set_colorfunctionline
Sets the line color
line.set_color(id, color) → void
- line.set_extendfunctionline
Sets extending type of this line object. If extend=extend.none, draws segment starting at point (x1, y1) and ending at point (x2, y2). If extend is equal to extend.right or extend.left, draws a ray starting at point (x1, y1) or (x2, y2), respectively.
line.set_extend(id, extend) → void
- line.set_first_pointfunctionline
Sets the first point of the id line to point.
line.set_first_point(id, point) → void
- line.set_second_pointfunctionline
Sets the second point of the id line to point.
line.set_second_point(id, point) → void
- line.set_stylefunctionline
Sets the line style
line.set_style(id, style) → void
- line.set_widthfunctionline
Sets the line width.
line.set_width(id, width) → void
- line.set_x1functionline
Sets bar index or bar time (depending on the xloc) of the first point.
line.set_x1(id, x) → void
- line.set_x2functionline
Sets bar index or bar time (depending on the xloc) of the second point.
line.set_x2(id, x) → void
- line.set_xlocfunctionline
Sets x-location and new bar index/time values.
line.set_xloc(id, x1, x2, xloc) → void
- line.set_xy1functionline
Sets bar index/time and price of the first point.
line.set_xy1(id, x, y) → void
- line.set_xy2functionline
Sets bar index/time and price of the second point
line.set_xy2(id, x, y) → void
- line.set_y1functionline
Sets price of the first point
line.set_y1(id, y) → void
- line.set_y2functionline
Sets price of the second point.
line.set_y2(id, y) → void
- line.style_arrow_bothvariableline
Line style for line.new() and line.set_style() functions. Solid line with arrows on both points.
- line.style_arrow_leftvariableline
Line style for line.new() and line.set_style() functions. Solid line with arrow on the first point.
- line.style_arrow_rightvariableline
Line style for line.new() and line.set_style() functions. Solid line with arrow on the second point.
- line.style_dashedvariableline
Line style for line.new() and line.set_style() functions.
- line.style_dottedvariableline
Line style for line.new() and line.set_style() functions.
- line.style_solidvariableline
Line style for line.new() and line.set_style() functions.
- linefilltypebuilt-in
Keyword used to explicitly declare the "linefill" type of a variable or a parameter. Linefill objects (or IDs) can be created with the linefill.new() function.
- linefillfunctionbuilt-in
Casts na to linefill.
linefill(x) → series linefill
- linefill.allvariablelinefill
Returns an array filled with all the current linefill objects drawn by the script.
- linefill.deletefunctionlinefill
Deletes the specified linefill object. If it has already been deleted, does nothing.
linefill.delete(id) → void
- linefill.get_line1functionlinefill
Returns the ID of the first line used in the id linefill.
linefill.get_line1(id) → series line
- linefill.get_line2functionlinefill
Returns the ID of the second line used in the id linefill.
linefill.get_line2(id) → series line
- linefill.newfunctionlinefill
Creates a new linefill object and displays it on the chart, filling the space between line1 and line2 with the color specified in color.
linefill.new(line1, line2, color) → series linefill
- linefill.set_colorfunctionlinefill
The function sets the color of the linefill object passed to it.
linefill.set_color(id, color) → void
- location.abovebarvariablelocation
Location value for plotshape(), plotchar() functions. Shape is plotted above main series bars.
- location.absolutevariablelocation
Location value for plotshape(), plotchar() functions. Shape is plotted on chart using indicator value as a price coordinate.
- location.belowbarvariablelocation
Location value for plotshape(), plotchar() functions. Shape is plotted below main series bars.
- location.bottomvariablelocation
Location value for plotshape(), plotchar() functions. Shape is plotted near the bottom chart border.
- location.topvariablelocation
Location value for plotshape(), plotchar() functions. Shape is plotted near the top chart border.
- log.errorfunctionlog
Converts the formatting string and value(s) into a formatted string, and sends the result to the "Pine logs" menu tagged with the "error" debug level.
log.error(message) → void
- log.infofunctionlog
Converts the formatting string and value(s) into a formatted string, and sends the result to the "Pine logs" menu tagged with the "info" debug level.
log.info(message) → void
- log.warningfunctionlog
Converts the formatting string and value(s) into a formatted string, and sends the result to the "Pine logs" menu tagged with the "warning" debug level.
log.warning(message) → void
- lowvariablebuilt-in
Current low price.
- maptypebuilt-in
Keyword used to explicitly declare the "map" type of a variable or a parameter. Map objects (or IDs) can be created with the map.new<type,type>() function.
- map.clearfunctionmap
Clears the map, removing all key-value pairs from it.
map.clear(id) → void
- map.containsfunctionmap
Returns true if the key was found in the id map, false otherwise.
map.contains(id, key) → series bool
- map.copyfunctionmap
Creates a copy of an existing map.
map.copy(id) → map<keyType, valueType>
- map.getfunctionmap
Returns the value associated with the specified key in the id map.
map.get(id, key) → <value_type>
- map.keysfunctionmap
Returns an array of all the keys in the id map. The resulting array is a copy and any changes to it are not reflected in the original map.
map.keys(id) → array<type>
- map.new<type,type>functionmap
Creates a new map object: a collection that consists of key-value pairs, where all keys are of the keyType, and all values are of the valueType.
map.new<keyType, valueType>() → map<keyType, valueType>
- map.putfunctionmap
Puts a new key-value pair into the id map.
map.put(id, key, value) → <value_type>
- map.put_allfunctionmap
Puts all key-value pairs from the id2 map into the id map.
map.put_all(id, id2) → void
- map.removefunctionmap
Removes a key-value pair from the id map.
map.remove(id, key) → <value_type>
- map.sizefunctionmap
Returns the number of key-value pairs in the id map.
map.size(id) → series int
- map.valuesfunctionmap
Returns an array of all the values in the id map. The resulting array is a copy and any changes to it are not reflected in the original map.
map.values(id) → array<type>
- math.absfunctionmath
Absolute value of number is number if number >= 0, or -number otherwise.
math.abs(number) → const int
- math.acosfunctionmath
The acos function returns the arccosine (in radians) of number such that cos(acos(y)) = y for y in range [-1, 1].
math.acos(angle) → const float
- math.asinfunctionmath
The asin function returns the arcsine (in radians) of number such that sin(asin(y)) = y for y in range [-1, 1].
math.asin(angle) → const float
- math.atanfunctionmath
The atan function returns the arctangent (in radians) of number such that tan(atan(y)) = y for any y.
math.atan(angle) → const float
- math.avgfunctionmath
Calculates average of all given series (elementwise).
math.avg(number0, number1, ...) → simple float
- math.ceilfunctionmath
Rounds the specified number up to the smallest whole number ("int" value) that is greater than or equal to it.
math.ceil(number) → const int
- math.cosfunctionmath
The cos function returns the trigonometric cosine of an angle.
math.cos(angle) → const float
- math.evariablemath
Is a named constant for Euler's number. It is equal to 2.7182818284590452.
- math.expfunctionmath
The exp function of number is e raised to the power of number, where e is Euler's number.
math.exp(number) → const float
- math.floorfunctionmath
Rounds the specified number down to the largest whole number ("int" value) that is less than or equal to it.
math.floor(number) → const int
- math.logfunctionmath
Natural logarithm of any number > 0 is the unique y such that e^y = number.
math.log(number) → const float
- math.log10functionmath
The common (or base 10) logarithm of number is the power to which 10 must be raised to obtain the number. 10^y = number.
math.log10(number) → const float
- math.maxfunctionmath
Returns the greatest of multiple values.
math.max(number0, number1, ...) → const int
- math.minfunctionmath
Returns the smallest of multiple values.
math.min(number0, number1, ...) → const int
- math.phivariablemath
Is a named constant for the golden ratio. It is equal to 1.6180339887498948.
- math.pivariablemath
Is a named constant for Archimedes' constant. It is equal to 3.1415926535897932.
- math.powfunctionmath
Mathematical power function.
math.pow(base, exponent) → const float
- math.randomfunctionmath
Returns a pseudo-random value. The function will generate a different sequence of values for each script execution. Using the same value for the optional seed argument will produce a repeatable sequence.
math.random(min, max, seed) → series float
- math.roundfunctionmath
Returns the value of number rounded to the nearest integer, with ties rounding up. If the precision parameter is used, returns a float value rounded to that amount of decimal places.
math.round(number) → const int
- math.round_to_mintickfunctionmath
Returns the value rounded to the symbol's mintick, i.e. the nearest value that can be divided by syminfo.mintick, without the remainder, with ties rounding up.
math.round_to_mintick(number) → simple float
- math.rphivariablemath
Is a named constant for the golden ratio conjugate. It is equal to 0.6180339887498948.
- math.signfunctionmath
Sign (signum) of number is zero if number is zero, 1.0 if number is greater than zero, -1.0 if number is less than zero.
math.sign(number) → const float
- math.sinfunctionmath
The sin function returns the trigonometric sine of an angle.
math.sin(angle) → const float
- math.sqrtfunctionmath
Square root of any number >= 0 is the unique y >= 0 such that y^2 = number.
math.sqrt(number) → const float
- math.sumfunctionmath
The sum function returns the sliding sum of last y values of x.
math.sum(source, length) → series float
- math.tanfunctionmath
The tan function returns the trigonometric tangent of an angle.
math.tan(angle) → const float
- math.todegreesfunctionmath
Returns an approximately equivalent angle in degrees from an angle measured in radians.
math.todegrees(radians) → series float
- math.toradiansfunctionmath
Returns an approximately equivalent angle in radians from an angle measured in degrees.
math.toradians(degrees) → series float
- matrixtypebuilt-in
Keyword used to explicitly declare the "matrix" type of a variable or a parameter. Matrix objects (or IDs) can be created with the matrix.new<type>() function.
- matrix.add_colfunctionmatrix
Inserts a new column at the column index of the id matrix.
matrix.add_col(id, column, array_id) → void
- matrix.add_rowfunctionmatrix
Inserts a new row at the row index of the id matrix.
matrix.add_row(id, row, array_id) → void
- matrix.avgfunctionmatrix
The function calculates the average of all elements in the matrix.
matrix.avg(id) → series float
- matrix.colfunctionmatrix
The function creates a one-dimensional array from the elements of a matrix column.
matrix.col(id, column) → array<type>
- matrix.columnsfunctionmatrix
The function returns the number of columns in the matrix.
matrix.columns(id) → series int
- matrix.concatfunctionmatrix
The function appends the m2 matrix to the m1 matrix.
matrix.concat(id1, id2) → matrix<type>
- matrix.copyfunctionmatrix
The function creates a new matrix which is a copy of the original.
matrix.copy(id) → matrix<type>
- matrix.detfunctionmatrix
The function returns the determinant of a square matrix.
matrix.det(id) → series float
- matrix.difffunctionmatrix
The function returns a new matrix resulting from the subtraction between matrices id1 and id2, or of matrix id1 and an id2 scalar (a numerical value).
matrix.diff(id1, id2) → matrix<int>
- matrix.eigenvaluesfunctionmatrix
The function returns an array containing the eigenvalues of a square matrix.
matrix.eigenvalues(id) → array<float>
- matrix.eigenvectorsfunctionmatrix
Returns a matrix of eigenvectors, in which each column is an eigenvector of the id matrix.
matrix.eigenvectors(id) → matrix<float>
- matrix.elements_countfunctionmatrix
The function returns the total number of all matrix elements.
matrix.elements_count(id) → series int
- matrix.fillfunctionmatrix
The function fills a rectangular area of the id matrix defined by the indices from_column to to_column (not including it) and from_row to to_row(not including it) with the value.
matrix.fill(id, value, from_row, to_row, from_column, to_column) → void
- matrix.getfunctionmatrix
The function returns the element with the specified index of the matrix.
matrix.get(id, row, column) → <matrix_type>
- matrix.invfunctionmatrix
The function returns the inverse of a square matrix.
matrix.inv(id) → matrix<float>
- matrix.is_antidiagonalfunctionmatrix
The function determines if the matrix is anti-diagonal (all elements outside the secondary diagonal are zero).
matrix.is_antidiagonal(id) → series bool
- matrix.is_antisymmetricfunctionmatrix
The function determines if a matrix is antisymmetric (its transpose equals its negative).
matrix.is_antisymmetric(id) → series bool
- matrix.is_binaryfunctionmatrix
The function determines if the matrix is binary (when all elements of the matrix are 0 or 1).
matrix.is_binary(id) → series bool
- matrix.is_diagonalfunctionmatrix
The function determines if the matrix is diagonal (all elements outside the main diagonal are zero).
matrix.is_diagonal(id) → series bool
- matrix.is_identityfunctionmatrix
The function determines if a matrix is an identity matrix (elements with ones on the main diagonal and zeros elsewhere).
matrix.is_identity(id) → series bool
- matrix.is_squarefunctionmatrix
The function determines if the matrix is square (it has the same number of rows and columns).
matrix.is_square(id) → series bool
- matrix.is_stochasticfunctionmatrix
The function determines if the matrix is stochastic.
matrix.is_stochastic(id) → series bool
- matrix.is_symmetricfunctionmatrix
The function determines if a square matrix is symmetric (elements are symmetric with respect to the main diagonal).
matrix.is_symmetric(id) → series bool
- matrix.is_triangularfunctionmatrix
The function determines if the matrix is triangular (if all elements above or below the main diagonal are zero).
matrix.is_triangular(id) → series bool
- matrix.is_zerofunctionmatrix
The function determines if all elements of the matrix are zero.
matrix.is_zero(id) → series bool
- matrix.kronfunctionmatrix
The function returns the Kronecker product for the id1 and id2 matrices.
matrix.kron(id1, id2) → matrix<float>
- matrix.maxfunctionmatrix
The function returns the largest value from the matrix elements.
matrix.max(id) → series float
- matrix.medianfunctionmatrix
The function calculates the median ("the middle" value) of matrix elements.
matrix.median(id) → series float
- matrix.minfunctionmatrix
The function returns the smallest value from the matrix elements.
matrix.min(id) → series float
- matrix.modefunctionmatrix
The function calculates the mode of the matrix, which is the most frequently occurring value from the matrix elements. When there are multiple values occurring equally frequently, the function returns the smallest of those values.
matrix.mode(id) → series float
- matrix.multfunctionmatrix
The function returns a new matrix resulting from the product between the matrices id1 and id2, or between an id1 matrix and an id2 scalar (a numerical value), or between an id1 matrix and an id2 vector (an array of values).
matrix.mult(id1, id2) → array<int>
- matrix.new<type>functionmatrix
The function creates a new matrix object. A matrix is a two-dimensional data structure containing rows and columns. All elements in the matrix must be of the type specified in the type template ("<type>").
matrix.new<type>(rows, columns, initial_value) → matrix<type>
- matrix.pinvfunctionmatrix
The function returns the pseudoinverse of a matrix.
matrix.pinv(id) → matrix<float>
- matrix.powfunctionmatrix
The function calculates the product of the matrix by itself power times.
matrix.pow(id, power) → matrix<float>
- matrix.rankfunctionmatrix
The function calculates the rank of the matrix.
matrix.rank(id) → series int
- matrix.remove_colfunctionmatrix
The function removes the column at column index of the id matrix and returns an array containing the removed column's values.
matrix.remove_col(id, column) → array<type>
- matrix.remove_rowfunctionmatrix
The function removes the row at row index of the id matrix and returns an array containing the removed row's values.
matrix.remove_row(id, row) → array<type>
- matrix.reshapefunctionmatrix
The function rebuilds the id matrix to rows x cols dimensions.
matrix.reshape(id, rows, columns) → void
- matrix.reversefunctionmatrix
The function reverses the order of rows and columns in the matrix id. The first row and first column become the last, and the last become the first.
matrix.reverse(id) → void
- matrix.rowfunctionmatrix
The function creates a one-dimensional array from the elements of a matrix row.
matrix.row(id, row) → array<type>
- matrix.rowsfunctionmatrix
The function returns the number of rows in the matrix.
matrix.rows(id) → series int
- matrix.setfunctionmatrix
The function assigns value to the element at the row and column of the id matrix.
matrix.set(id, row, column, value) → void
- matrix.sortfunctionmatrix
The function rearranges the rows in the id matrix following the sorted order of the values in the column.
matrix.sort(id, column, order) → void
- matrix.submatrixfunctionmatrix
The function extracts a submatrix of the id matrix within the specified indices.
matrix.submatrix(id, from_row, to_row, from_column, to_column) → matrix<type>
- matrix.sumfunctionmatrix
The function returns a new matrix resulting from the sum of two matrices id1 and id2, or of an id1 matrix and an id2 scalar (a numerical value).
matrix.sum(id1, id2) → matrix<int>
- matrix.swap_columnsfunctionmatrix
The function swaps the columns at the index column1 and column2 in the id matrix.
matrix.swap_columns(id, column1, column2) → void
- matrix.swap_rowsfunctionmatrix
The function swaps the rows at the index row1 and row2 in the id matrix.
matrix.swap_rows(id, row1, row2) → void
- matrix.tracefunctionmatrix
The function calculates the trace of a matrix (the sum of the main diagonal's elements).
matrix.trace(id) → series float
- matrix.transposefunctionmatrix
The function creates a new, transposed version of the id. This interchanges the row and column index of each element.
matrix.transpose(id) → matrix<type>
- max_bars_backfunctionbuilt-in
Explicitly sets the minimum length of the historical buffer for a built-in or user-defined variable. The historical buffer determines the maximum span of past values that the script can access from the variable's series by using the [] history-referencing operator or functions…
max_bars_back(var, num) → void
- methodkeywordbuilt-in
This keyword is used to prefix a function declaration, indicating it can then be invoked using dot notation by appending its name to a variable of the type of its first parameter and omitting that first parameter.
[export] method <functionName>(<paramType> <paramName> [= <defaultValue>], …) => <functionBlock>
- minutevariablebuilt-in
Current bar minute in exchange timezone.
- minutefunctionbuilt-in
time (series int) UNIX time in milliseconds.
minute(time, timezone) → series int
- monthvariablebuilt-in
Current bar month in exchange timezone.
- monthfunctionbuilt-in
time (series int) UNIX time in milliseconds.
month(time, timezone) → series int
- navariablebuilt-in
A keyword signifying "not available", indicating that a variable has no assigned value.
- nafunctionbuilt-in
Tests if x is na.
na(x) → simple bool
- notkeywordbuilt-in
Logical negation (NOT). Applicable to boolean expressions.
not expr1
- nzfunctionbuilt-in
Replaces na (undefined) values with either a type-specific default value or a specified replacement.
nz(source, replacement) → simple color
- ohlc4variablebuilt-in
Is a shortcut for (open + high + low + close)/4
- oncekeywordbuilt-in
Defines a conditional structure that executes a single block of code when a specified condition evaluates to true. After the local block executes for the first time on a closed bar, it does not execute again on any subsequent bars, regardless of the condition.
once [condition] statements
- openvariablebuilt-in
Current open price.
- orkeywordbuilt-in
Logical OR. Applicable to boolean expressions.
expr1 or expr2
- order.ascendingvariableorder
Determines the sort order of the array from the smallest to the largest value.
- order.descendingvariableorder
Determines the sort order of the array from the largest to the smallest value.
- plotfunctionbuilt-in
Plots a series of data on the chart.
plot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display, format, precision, force_overlay, linestyle) → plot
- plot.linestyle_dashedvariableplot
A named constant for use with the plot() function's linestyle parameter, which modifies the appearance of plotted lines. If the style argument of the function call specifies a plot style that displays a line, using this constant as the linestyle argument specifies that the…
- plot.linestyle_dottedvariableplot
A named constant for use with the plot() function's linestyle parameter, which modifies the appearance of plotted lines. If the style argument of the function call specifies a plot style that displays a line, using this constant as the linestyle argument specifies that the…
- plot.linestyle_solidvariableplot
A named constant for use with the plot() function's linestyle parameter, which modifies the appearance of plotted lines. If the style argument of the function call specifies a plot style that displays a line, using this constant as the linestyle argument specifies that the…
- plot.style_areavariableplot
A named constant for the 'Area' style, to be used as an argument for the style parameter in the plot() function.
- plot.style_areabrvariableplot
A named constant for the 'Area With Breaks' style, to be used as an argument for the style parameter in the plot() function. Similar to plot.style_area, except the gaps in the data are not filled.
- plot.style_circlesvariableplot
A named constant for the 'Circles' style, to be used as an argument for the style parameter in the plot() function.
- plot.style_columnsvariableplot
A named constant for the 'Columns' style, to be used as an argument for the style parameter in the plot() function.
- plot.style_crossvariableplot
A named constant for the 'Cross' style, to be used as an argument for the style parameter in the plot() function.
- plot.style_histogramvariableplot
A named constant for the 'Histogram' style, to be used as an argument for the style parameter in the plot() function.
- plot.style_linevariableplot
A named constant for the 'Line' style, to be used as an argument for the style parameter in the plot() function.
- plot.style_linebrvariableplot
A named constant for the 'Line With Breaks' style, to be used as an argument for the style parameter in the plot() function. Similar to plot.style_line, except the gaps in the data are not filled.
- plot.style_steplinevariableplot
A named constant for the 'Step Line' style, to be used as an argument for the style parameter in the plot() function.
- plot.style_stepline_diamondvariableplot
A named constant for the 'Step Line With Diamonds' style, to be used as an argument for the style parameter in the plot() function. Similar to plot.style_stepline, except the data changes are also marked with the Diamond shapes.
- plot.style_steplinebrvariableplot
A named constant for the 'Step line with Breaks' style, to be used as an argument for the style parameter in the plot() function.
- plotarrowfunctionbuilt-in
Plots up and down arrows on the chart. Up arrow is drawn at every indicator positive value, down arrow is drawn at every negative value. If indicator returns na then no arrow is drawn. Arrows has different height, the more absolute indicator value the longer arrow is drawn.
plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display, format, precision, force_overlay) → void
- plotbarfunctionbuilt-in
Plots ohlc bars on the chart.
plotbar(open, high, low, close, title, color, editable, show_last, display, format, precision, force_overlay) → void
- plotcandlefunctionbuilt-in
Plots candles on the chart.
plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display, format, precision, force_overlay) → void
- plotcharfunctionbuilt-in
Plots visual shapes using any given one Unicode character on the chart.
plotchar(series, title, char, location, color, offset, text, textcolor, editable, size, show_last, display, format, precision, force_overlay) → void
- plotshapefunctionbuilt-in
Plots visual shapes on the chart.
plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display, format, precision, force_overlay) → void
- polylinetypebuilt-in
Keyword to explicitly declare the type of a variable or parameter as polyline. Scripts can produce polyline instances using the polyline.new() function.
- polyline.allvariablepolyline
Returns an array containing all current polyline instances drawn by the script.
- polyline.deletefunctionpolyline
Deletes the specified polyline object. It has no effect if the id doesn't exist.
polyline.delete(id) → void
- polyline.newfunctionpolyline
Creates a new polyline instance and displays it on the chart, sequentially connecting all of the points in the points array with line segments. The segments in the drawing can be straight or curved depending on the curved parameter.
polyline.new(points, curved, closed, xloc, line_color, fill_color, line_style, line_width, force_overlay) → series polyline
- position.bottom_centervariableposition
Table position is used in table.new(), table.cell() functions.
- position.bottom_leftvariableposition
Table position is used in table.new(), table.cell() functions.
- position.bottom_rightvariableposition
Table position is used in table.new(), table.cell() functions.
- position.middle_centervariableposition
Table position is used in table.new(), table.cell() functions.
- position.middle_leftvariableposition
Table position is used in table.new(), table.cell() functions.
- position.middle_rightvariableposition
Table position is used in table.new(), table.cell() functions.
- position.top_centervariableposition
Table position is used in table.new(), table.cell() functions.
- position.top_leftvariableposition
Table position is used in table.new(), table.cell() functions.
- position.top_rightvariableposition
Table position is used in table.new(), table.cell() functions.
- request.currency_ratefunctionrequest
Provides a daily rate that can be used to convert a value expressed in the from currency to another in the to currency.
request.currency_rate(from, to, ignore_invalid_currency) → series float
- request.dividendsfunctionrequest
Requests dividends data for the specified symbol.
request.dividends(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency) → series float
- request.earningsfunctionrequest
Requests earnings data for the specified symbol.
request.earnings(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency) → series float
- request.economicfunctionrequest
Requests economic data for a symbol. Economic data includes information such as the state of a country's economy (GDP, inflation rate, etc.) or of a particular industry (steel production, ICU beds, etc.).
request.economic(country_code, field, gaps, ignore_invalid_symbol) → series float
- request.financialfunctionrequest
Requests financial series for symbol.
request.financial(symbol, financial_id, period, gaps, ignore_invalid_symbol, currency) → series float
- request.footprintfunctionrequest
Requests the ID of a footprint object that contains data for calculating volume footprint information for the current chart bar. Scripts can use the returned ID in calls to the footprint.*() functions to retrieve footprint data, including footprint rows, categorized volume sums…
request.footprint(ticks_per_row, va_percent, imbalance_percent) → footprint
- request.quandlfunctionrequest
Note: This function has been deprecated due to the API change from NASDAQ Data Link. Requests for "QUANDL" symbols are no longer valid and requests for them return a runtime error.
request.quandl(ticker, gaps, index, ignore_invalid_symbol) → series float
- request.securityfunctionrequest
Requests the result of an expression from a specified context (symbol and timeframe).
request.security(symbol, timeframe, expression, gaps, lookahead, ignore_invalid_symbol, currency, calc_bars_count) → series <type>
- request.security_lower_tffunctionrequest
Requests the results of an expression from a specified symbol on a timeframe lower than or equal to the chart's timeframe. It returns an array containing one element for each lower-timeframe bar within the chart bar.
request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency, ignore_invalid_timeframe, calc_bars_count) → array<type>
- request.seedfunctionrequest
Requests the result of an expression evaluated on data from a user-maintained GitHub repository. **Note:**The creation of new Pine Seeds repositories is suspended; only existing repositories are currently supported. See the Pine Seeds documentation on GitHub to learn more.
request.seed(source, symbol, expression, ignore_invalid_symbol, calc_bars_count) → series <type>
- request.splitsfunctionrequest
Requests splits data for the specified symbol.
request.splits(ticker, field, gaps, lookahead, ignore_invalid_symbol) → series float
- runtime.calculation.modevariableruntime
References the calculation mode that the script is running in, allowing the script to use different logic depending on where it runs.
- runtime.calculation.mode.alertvariableruntime
A named constant for use with the runtime.calculation.mode variable.
- runtime.calculation.mode.chartvariableruntime
A named constant for use with the runtime.calculation.mode variable.
- runtime.errorfunctionruntime
When called, causes a runtime error with the error message specified in the message argument.
runtime.error(message) → void
- scale.leftvariablescale
A named constant for use as the scale argument in indicator() and strategy() declaration statements. Specifies that the script's price scale is on the left side of the pane.
- scale.nonevariablescale
A named constant for use as the scale argument in indicator() and strategy() declaration statements. A declaration statement can use this constant only if its overlay argument is true.
- scale.rightvariablescale
A named constant for use as the scale argument in indicator() and strategy() declaration statements. Specifies that the script's price scale is on the right side of the pane.
- secondvariablebuilt-in
Current bar second in exchange timezone.
- secondfunctionbuilt-in
time (series int) UNIX time in milliseconds.
second(time, timezone) → series int
- seriestypebuilt-in
The series keyword explicitly assigns the "series" type qualifier to variables and function parameters. Variables and parameters that use the "series" qualifier can reference values that change throughout a script's execution.
export [method ]<functionName>([[series ]<paramType>] <paramName>[ = <defaultValue>]) [method ]<functionName>([series <paramType> ]<paramName>[ = <defaultValue>]) [var/varip ]series <variableType> <variableName> = <variableValue>
- session.extendedvariablesession
Constant for extended session type (with extended hours data).
- session.isfirstbarvariablesession
Returns true if the current bar is the first bar of the day's session, false otherwise. If extended session information is used, only returns true on the first bar of the pre-market bars.
- session.isfirstbar_regularvariablesession
Returns true on the first regular session bar of the day, false otherwise. The result is the same whether extended session information is used or not.
- session.islastbarvariablesession
Returns true if the current bar is the last bar of the day's session, false otherwise. If extended session information is used, only returns true on the last bar of the post-market bars.
- session.islastbar_regularvariablesession
Returns true on the last regular session bar of the day, false otherwise. The result is the same whether extended session information is used or not.
- session.ismarketvariablesession
Returns true if the current bar is a part of the regular trading hours (i.e. market hours), false otherwise.
- session.ispostmarketvariablesession
Returns true if the current bar is a part of the post-market, false otherwise. On non-intraday charts always returns false.
- session.ispremarketvariablesession
Returns true if the current bar is a part of the pre-market, false otherwise. On non-intraday charts always returns false.
- session.regularvariablesession
Constant for regular session type (no extended hours data).
- settlement_as_close.inheritvariablesettlement_as_close
A constant to specify the value of the settlement_as_close parameter in ticker.new() and ticker.modify() functions.
- settlement_as_close.offvariablesettlement_as_close
A constant to specify the value of the settlement_as_close parameter in ticker.new() and ticker.modify() functions.
- settlement_as_close.onvariablesettlement_as_close
A constant to specify the value of the settlement_as_close parameter in ticker.new() and ticker.modify() functions.
- shape.arrowdownvariableshape
Shape style for plotshape() function.
- shape.arrowupvariableshape
Shape style for plotshape() function.
- shape.circlevariableshape
Shape style for plotshape() function.
- shape.crossvariableshape
Shape style for plotshape() function.
- shape.diamondvariableshape
Shape style for plotshape() function.
- shape.flagvariableshape
Shape style for plotshape() function.
- shape.labeldownvariableshape
Shape style for plotshape() function.
- shape.labelupvariableshape
Shape style for plotshape() function.
- shape.squarevariableshape
Shape style for plotshape() function.
- shape.triangledownvariableshape
Shape style for plotshape() function.
- shape.triangleupvariableshape
Shape style for plotshape() function.
- shape.xcrossvariableshape
Shape style for plotshape() function.
- simpletypebuilt-in
The simple keyword explicitly assigns the "simple" type qualifier to variables and function parameters. Variables and parameters that use the "simple" qualifier can reference values established at the beginning of a script's execution that do not change later.
export [method ]<functionName>([[simple ]<paramType>] <paramName>[ = <defaultValue>]) [method ]<functionName>([simple <paramType> ]<paramName>[ = <defaultValue>]) [var/varip ]simple <variableType> <variableName> = <variableValue></variableValue>
- size.autovariablesize
A constant to specify the size of the graphics drawn by plotchar(), plotshape(), label.new(), and box.new(). Adjusts the size of the graphics automatically.
- size.hugevariablesize
A constant to specify the size of the graphics drawn by plotchar(), plotshape(), label.new(), box.new(), and table.cell(). Sets the size to huge.
- size.largevariablesize
A constant to specify the size of the graphics drawn by plotchar(), plotshape(), label.new(), box.new(), and table.cell(). Sets the size to large.
- size.normalvariablesize
A constant to specify the size of the graphics drawn by plotchar(), plotshape(), label.new(), box.new(), and table.cell(). Sets the size to normal.
- size.smallvariablesize
A constant to specify the size of the graphics drawn by plotchar(), plotshape(), label.new(), box.new(), and table.cell(). Sets the size to small.
- size.tinyvariablesize
A constant to specify the size of the graphics drawn by plotchar(), plotshape(), label.new(), box.new(), and table.cell(). Sets the size to tiny.
- splits.denominatorvariablesplits
A named constant for the request.splits() function. Is used to request the denominator (the number below the line in a fraction) of a splits.
- splits.numeratorvariablesplits
A named constant for the request.splits() function. Is used to request the numerator (the number above the line in a fraction) of a splits.
- str.containsfunctionstr
Returns true if the source string contains the str substring, false otherwise.
str.contains(source, str) → const bool
- str.endswithfunctionstr
Returns true if the source string ends with the substring specified in str, false otherwise.
str.endswith(source, str) → const bool
- str.formatfunctionstr
Creates a formatted string using a specified formatting string (formatString) and one or more additional arguments (arg0, arg1, etc.). The formatting string defines the structure of the returned string, where all placeholders in curly brackets ({}) refer to the additional…
str.format(formatString, arg0, arg1, ...) → simple string
- str.format_timefunctionstr
Converts the time timestamp into a string formatted according to format and timezone.
str.format_time(time, format, timezone) → series string
- str.lengthfunctionstr
Returns an integer corresponding to the amount of chars in that string.
str.length(string) → const int
- str.lowerfunctionstr
Returns a new string with all letters converted to lowercase.
str.lower(source) → const string
- str.matchfunctionstr
Returns the new substring of the source string if it matches a regex regular expression, an empty string otherwise.
str.match(source, regex) → simple string
- str.posfunctionstr
Returns the position of the first occurrence of the str string in the source string, 'na' otherwise.
str.pos(source, str) → const int
- str.repeatfunctionstr
Constructs a new string containing the source string repeated repeat times with the separator injected between each repeated instance.
str.repeat(source, repeat, separator) → const string
- str.replacefunctionstr
Returns a new string with the Nth occurrence of the target string replaced by the replacement string, where N is specified in occurrence.
str.replace(source, target, replacement, occurrence) → const string
- str.replace_allfunctionstr
Replaces each occurrence of the target string in the source string with the replacement string.
str.replace_all(source, target, replacement) → simple string
- str.splitfunctionstr
Divides a string into an array of substrings and returns its array id.
str.split(string, separator) → array<string>
- str.startswithfunctionstr
Returns true if the source string starts with the substring specified in str, false otherwise.
str.startswith(source, str) → const bool
- str.substringfunctionstr
Returns a new string that is a substring of the source string. The substring begins with the character at the index specified by begin_pos and extends to 'end_pos - 1' of the source string.
str.substring(source, begin_pos, end_pos) → const string
- str.tonumberfunctionstr
Converts a value represented in string to its "float" equivalent.
str.tonumber(string) → const float
- str.tostringfunctionstr
value (const enum) Value or array ID whose elements are converted to a string.
str.tostring(value) → const string
- str.trimfunctionstr
Constructs a new string with all consecutive whitespaces and other control characters (e.g., “\n”, “\t”, etc.) removed from the left and right of the source.
str.trim(source) → const string
- str.upperfunctionstr
Returns a new string with all letters converted to uppercase.
str.upper(source) → const string
- strategyfunctionbuilt-in
This declaration statement designates the script as a strategy and sets a number of strategy-related properties.
strategy(title, shorttitle, overlay, format, precision, scale, pyramiding, calc_on_order_fills, calc_on_every_tick, max_bars_back, backtest_fill_limits_assumption, default_qty_type, default_qty_value, initial_capital, currency, slippage, commission_type, commission_value, process_orders_on_close, close_entries_rule, margin_long, margin_short, explicit_plot_zorder, max_lines_count, max_labels_count, max_boxes_count, calc_bars_count, risk_free_rate, use_bar_magnifier, fill_orders_on_standard_ohlc, max_polylines_count, dynamic_requests, behind_chart, calc_on_every_history_tick) → void
- strategy.account_currencyvariablestrategy
Returns the currency used to calculate results, which can be set in the strategy's properties.
- strategy.avg_losing_tradevariablestrategy
Returns the average amount of money lost per losing trade. Calculated as the sum of losses divided by the number of losing trades.
- strategy.avg_losing_trade_percentvariablestrategy
Returns the average percentage loss per losing trade. Calculated as the sum of loss percentages divided by the number of losing trades.
- strategy.avg_tradevariablestrategy
Returns the average amount of money gained or lost per trade. Calculated as the sum of all profits and losses divided by the number of closed trades.
- strategy.avg_trade_percentvariablestrategy
Returns the average percentage gain or loss per trade. Calculated as the sum of all profit and loss percentages divided by the number of closed trades.
- strategy.avg_winning_tradevariablestrategy
Returns the average amount of money gained per winning trade. Calculated as the sum of profits divided by the number of winning trades.
- strategy.avg_winning_trade_percentvariablestrategy
Returns the average percentage gain per winning trade. Calculated as the sum of profit percentages divided by the number of winning trades.
- strategy.cancelfunctionstrategy
Cancels a pending or unfilled order with a specific identifier. If multiple unfilled orders share the same ID, calling this command with that ID as the id argument cancels all of them.
strategy.cancel(id) → void
- strategy.cancel_allfunctionstrategy
Cancels all pending or unfilled orders, regardless of their identifiers.
strategy.cancel_all() → void
- strategy.cashvariablestrategy
This is one of the arguments that can be supplied to the default_qty_type parameter in the strategy() declaration statement. It is only relevant when no value is used for the ‘qty’ parameter in strategy.entry() or strategy.order() function calls.
- strategy.closefunctionstrategy
Creates an order to exit from the part of a position opened by entry orders with a specific identifier. If multiple entries in the position share the same ID, the orders from this command apply to all those entries, starting from the first open trade, when its calls use that ID…
strategy.close(id, comment, qty, qty_percent, alert_message, immediately, disable_alert) → void
- strategy.close_allfunctionstrategy
Creates an order to close an open position completely, regardless of the identifiers of the entry orders that opened or added to it.
strategy.close_all(comment, alert_message, immediately, disable_alert) → void
- strategy.closedtradesvariablestrategy
Number of trades, which were closed for the whole trading range.
- strategy.closedtrades.commissionfunctionstrategy
Returns the sum of entry and exit fees paid in the closed trade, expressed in strategy.account_currency.
strategy.closedtrades.commission(trade_num) → series float
- strategy.closedtrades.entry_bar_indexfunctionstrategy
Returns the bar_index of the closed trade's entry.
strategy.closedtrades.entry_bar_index(trade_num) → series int
- strategy.closedtrades.entry_commentfunctionstrategy
Returns the comment message of the closed trade's entry, or na if there is no entry with this trade_num.
strategy.closedtrades.entry_comment(trade_num) → series string
- strategy.closedtrades.entry_idfunctionstrategy
Returns the id of the closed trade's entry.
strategy.closedtrades.entry_id(trade_num) → series string
- strategy.closedtrades.entry_pricefunctionstrategy
Returns the price of the closed trade's entry.
strategy.closedtrades.entry_price(trade_num) → series float
- strategy.closedtrades.entry_timefunctionstrategy
Returns the UNIX time of the closed trade's entry, expressed in milliseconds..
strategy.closedtrades.entry_time(trade_num) → series int
- strategy.closedtrades.exit_bar_indexfunctionstrategy
Returns the bar_index of the closed trade's exit.
strategy.closedtrades.exit_bar_index(trade_num) → series int
- strategy.closedtrades.exit_commentfunctionstrategy
Returns the comment message of the closed trade's exit, or na if there is no entry with this trade_num.
strategy.closedtrades.exit_comment(trade_num) → series string
- strategy.closedtrades.exit_idfunctionstrategy
Returns the id of the closed trade's exit.
strategy.closedtrades.exit_id(trade_num) → series string
- strategy.closedtrades.exit_pricefunctionstrategy
Returns the price of the closed trade's exit.
strategy.closedtrades.exit_price(trade_num) → series float
- strategy.closedtrades.exit_timefunctionstrategy
Returns the UNIX time of the closed trade's exit, expressed in milliseconds.
strategy.closedtrades.exit_time(trade_num) → series int
- strategy.closedtrades.first_indexvariablestrategy
The index, or trade number, of the first (oldest) trade listed in the List of Trades. This number is usually zero. If more trades than the allowed limit have been closed, the oldest trades are removed, and this number is the index of the oldest remaining trade.
- strategy.closedtrades.max_drawdownfunctionstrategy
Returns the maximum drawdown of the closed trade, i.e., the maximum possible loss during the trade, expressed in strategy.account_currency.
strategy.closedtrades.max_drawdown(trade_num) → series float
- strategy.closedtrades.max_drawdown_percentfunctionstrategy
Returns the maximum drawdown of the closed trade, i.e., the maximum possible loss during the trade, expressed as a percentage and calculated by formula: Lowest Value During Trade / (Entry Price x Quantity) * 100.
strategy.closedtrades.max_drawdown_percent(trade_num) → series float
- strategy.closedtrades.max_runupfunctionstrategy
Returns the maximum run up of the closed trade, i.e., the maximum possible profit during the trade, expressed in strategy.account_currency.
strategy.closedtrades.max_runup(trade_num) → series float
- strategy.closedtrades.max_runup_percentfunctionstrategy
Returns the maximum run-up of the closed trade, i.e., the maximum possible profit during the trade, expressed as a percentage and calculated by formula: Highest Value During Trade / (Entry Price x Quantity) * 100.
strategy.closedtrades.max_runup_percent(trade_num) → series float
- strategy.closedtrades.profitfunctionstrategy
Returns the profit/loss of the closed trade in the strategy's account currency, reduced by the trade's commissions. A positive returned value represents a profit, and a negative value represents a loss.
strategy.closedtrades.profit(trade_num) → series float
- strategy.closedtrades.profit_percentfunctionstrategy
Returns the profit/loss value of the closed trade, expressed as a percentage. Losses are expressed as negative values.
strategy.closedtrades.profit_percent(trade_num) → series float
- strategy.closedtrades.sizefunctionstrategy
Returns the direction and the number of contracts traded in the closed trade. If the value is > 0, the market position was long. If the value is < 0, the market position was short.
strategy.closedtrades.size(trade_num) → series float
- strategy.commission.cash_per_contractvariablestrategy
Commission type for an order. Money displayed in the account currency per contract.
- strategy.commission.cash_per_ordervariablestrategy
Commission type for an order. Money displayed in the account currency per order.
- strategy.commission.percentvariablestrategy
Commission type for an order. A percentage of the cash volume of order.
- strategy.convert_to_accountfunctionstrategy
Converts the value from the currency that the symbol on the chart is traded in (syminfo.currency) to the currency used by the strategy (strategy.account_currency).
strategy.convert_to_account(value) → series float
- strategy.convert_to_symbolfunctionstrategy
Converts the value from the currency used by the strategy (strategy.account_currency) to the currency that the symbol on the chart is traded in (syminfo.currency).
strategy.convert_to_symbol(value) → series float
- strategy.default_entry_qtyfunctionstrategy
Calculates the default quantity, in units, of an entry order from strategy.entry() or strategy.order() if it were to fill at the specified fill_price value.
strategy.default_entry_qty(fill_price) → series float
- strategy.direction.allvariablestrategy
It allows strategy to open both long and short positions.
- strategy.direction.longvariablestrategy
It allows strategy to open only long positions.
- strategy.direction.shortvariablestrategy
It allows strategy to open only short positions.
- strategy.entryfunctionstrategy
Creates a new order to open or add to a position. If an unfilled order with the same id exists, a call to this command modifies that order.
strategy.entry(id, direction, qty, limit, stop, oca_name, oca_type, comment, alert_message, disable_alert) → void
- strategy.equityvariablestrategy
Current equity (strategy.initial_capital + strategy.netprofit + strategy.openprofit).
- strategy.eventradesvariablestrategy
Number of breakeven trades for the whole trading range.
- strategy.exitfunctionstrategy
Creates price-based orders to exit from an open position. If unfilled exit orders with the same id exist, calls to this command modify those orders. This command can generate more than one type of exit order, depending on the specified parameters.
strategy.exit(id, from_entry, qty, qty_percent, profit, limit, loss, stop, trail_price, trail_points, trail_offset, oca_name, comment, comment_profit, comment_loss, comment_trailing, alert_message, alert_profit, alert_loss, alert_trailing, disable_alert) → void
- strategy.fixedvariablestrategy
This is one of the arguments that can be supplied to the default_qty_type parameter in the strategy() declaration statement. It is only relevant when no value is used for the ‘qty’ parameter in strategy.entry() or strategy.order() function calls.
- strategy.grosslossvariablestrategy
Total currency value of all completed losing trades.
- strategy.grossloss_percentvariablestrategy
The total value of all completed losing trades, expressed as a percentage of the initial capital.
- strategy.grossprofitvariablestrategy
Total currency value of all completed winning trades.
- strategy.grossprofit_percentvariablestrategy
The total currency value of all completed winning trades, expressed as a percentage of the initial capital.
- strategy.initial_capitalvariablestrategy
The amount of initial capital set in the strategy properties.
- strategy.longvariablestrategy
A named constant for use with the direction parameter of the strategy.entry() and strategy.order() commands. It specifies that the command creates a buy order.
- strategy.losstradesvariablestrategy
Number of unprofitable trades for the whole trading range.
- strategy.margin_liquidation_pricevariablestrategy
When margin is used in a strategy, returns the price point where a simulated margin call will occur and liquidate enough of the position to meet the margin requirements.
- strategy.max_contracts_held_allvariablestrategy
Maximum number of contracts/shares/lots/units in one trade for the whole trading range.
- strategy.max_contracts_held_longvariablestrategy
Maximum number of contracts/shares/lots/units in one long trade for the whole trading range.
- strategy.max_contracts_held_shortvariablestrategy
Maximum number of contracts/shares/lots/units in one short trade for the whole trading range.
- strategy.max_drawdownvariablestrategy
Maximum equity drawdown value for the whole trading range.
- strategy.max_drawdown_percentvariablestrategy
The maximum equity drawdown value for the whole trading range, expressed as a percentage and calculated by formula: Lowest Value During Trade / (Entry Price x Quantity) * 100.
- strategy.max_runupvariablestrategy
Maximum equity run-up value for the whole trading range.
- strategy.max_runup_percentvariablestrategy
The maximum equity run-up value for the whole trading range, expressed as a percentage and calculated by formula: Highest Value During Trade / (Entry Price x Quantity) * 100.
- strategy.netprofitvariablestrategy
Total currency value of all completed trades.
- strategy.netprofit_percentvariablestrategy
The total value of all completed trades, expressed as a percentage of the initial capital.
- strategy.oca.cancelvariablestrategy
A named constant for use with the oca_type parameter of the strategy.entry() and strategy.order() commands. It specifies that the strategy cancels the unfilled order when another order with the same oca_name and oca_type executes.
- strategy.oca.nonevariablestrategy
A named constant for use with the oca_type parameter of the strategy.entry() and strategy.order() commands. It specifies that the order executes independently of all other orders, including those with the same oca_name.
- strategy.oca.reducevariablestrategy
A named constant for use with the oca_type parameter of the strategy.entry() and strategy.order() commands. It specifies that when another order with the same oca_name and oca_type executes, the strategy reduces the unfilled order by that order's size.
- strategy.openprofitvariablestrategy
Current unrealized profit or loss for all open positions.
- strategy.openprofit_percentvariablestrategy
The current unrealized profit or loss for all open positions, expressed as a percentage and calculated by formula: openPL / realizedEquity * 100.
- strategy.opentradesvariablestrategy
Number of market position entries, which were not closed and remain opened. If there is no open market position, 0 is returned.
- strategy.opentrades.capital_heldvariablestrategy
Returns the capital amount currently held by open trades.
- strategy.opentrades.commissionfunctionstrategy
Returns the sum of entry and exit fees paid in the open trade, expressed in strategy.account_currency.
strategy.opentrades.commission(trade_num) → series float
- strategy.opentrades.entry_bar_indexfunctionstrategy
Returns the bar_index of the open trade's entry.
strategy.opentrades.entry_bar_index(trade_num) → series int
- strategy.opentrades.entry_commentfunctionstrategy
Returns the comment message of the open trade's entry, or na if there is no entry with this trade_num.
strategy.opentrades.entry_comment(trade_num) → series string
- strategy.opentrades.entry_idfunctionstrategy
Returns the id of the open trade's entry.
strategy.opentrades.entry_id(trade_num) → series string
- strategy.opentrades.entry_pricefunctionstrategy
Returns the price of the open trade's entry.
strategy.opentrades.entry_price(trade_num) → series float
- strategy.opentrades.entry_timefunctionstrategy
Returns the UNIX time of the open trade's entry, expressed in milliseconds.
strategy.opentrades.entry_time(trade_num) → series int
- strategy.opentrades.max_drawdownfunctionstrategy
Returns the maximum drawdown of the open trade, i.e., the maximum possible loss during the trade, expressed in strategy.account_currency.
strategy.opentrades.max_drawdown(trade_num) → series float
- strategy.opentrades.max_drawdown_percentfunctionstrategy
Returns the maximum drawdown of the open trade, i.e., the maximum possible loss during the trade, expressed as a percentage and calculated by formula: Lowest Value During Trade / (Entry Price x Quantity) * 100.
strategy.opentrades.max_drawdown_percent(trade_num) → series float
- strategy.opentrades.max_runupfunctionstrategy
Returns the maximum run up of the open trade, i.e., the maximum possible profit during the trade, expressed in strategy.account_currency.
strategy.opentrades.max_runup(trade_num) → series float
- strategy.opentrades.max_runup_percentfunctionstrategy
Returns the maximum run-up of the open trade, i.e., the maximum possible profit during the trade, expressed as a percentage and calculated by formula: Highest Value During Trade / (Entry Price x Quantity) * 100.
strategy.opentrades.max_runup_percent(trade_num) → series float
- strategy.opentrades.profitfunctionstrategy
Returns the profit/loss of the open trade, expressed in strategy.account_currency. Losses are expressed as negative values.
strategy.opentrades.profit(trade_num) → series float
- strategy.opentrades.profit_percentfunctionstrategy
Returns the profit/loss of the open trade, expressed as a percentage. Losses are expressed as negative values.
strategy.opentrades.profit_percent(trade_num) → series float
- strategy.opentrades.sizefunctionstrategy
Returns the direction and the number of contracts traded in the open trade. If the value is > 0, the market position was long. If the value is < 0, the market position was short.
strategy.opentrades.size(trade_num) → series float
- strategy.orderfunctionstrategy
Creates a new order to open, add to, or exit from a position. If an unfilled order with the same id exists, a call to this command modifies that order.
strategy.order(id, direction, qty, limit, stop, oca_name, oca_type, comment, alert_message, disable_alert) → void
- strategy.percent_of_equityvariablestrategy
This is one of the arguments that can be supplied to the default_qty_type parameter in the strategy() declaration statement. It is only relevant when no value is used for the ‘qty’ parameter in strategy.entry() or strategy.order() function calls.
- strategy.position_avg_pricevariablestrategy
Average entry price of current market position. If the market position is flat, 'NaN' is returned.
- strategy.position_entry_namevariablestrategy
Name of the order that initially opened current market position.
- strategy.position_sizevariablestrategy
Direction and size of the current market position. If the value is > 0, the market position is long. If the value is < 0, the market position is short. The absolute value is the number of contracts/shares/lots/units in trade (position size).
- strategy.risk.allow_entry_infunctionstrategy
This function can be used to specify in which market direction the strategy.entry() function is allowed to open positions.
strategy.risk.allow_entry_in(value) → void
- strategy.risk.max_cons_loss_daysfunctionstrategy
The purpose of this rule is to cancel all pending orders, close all open positions and stop placing orders after a specified number of consecutive days with losses. The rule affects the whole strategy.
strategy.risk.max_cons_loss_days(count, alert_message) → void
- strategy.risk.max_drawdownfunctionstrategy
The purpose of this rule is to determine maximum drawdown. The rule affects the whole strategy. Once the maximum drawdown value is reached, all pending orders are cancelled, all open positions are closed and no new orders can be placed.
strategy.risk.max_drawdown(value, type, alert_message) → void
- strategy.risk.max_intraday_filled_ordersfunctionstrategy
The purpose of this rule is to determine maximum number of filled orders per 1 day (per 1 bar, if chart resolution is higher than 1 day). The rule affects the whole strategy.
strategy.risk.max_intraday_filled_orders(count, alert_message) → void
- strategy.risk.max_intraday_lossfunctionstrategy
The maximum loss value allowed during a day. It is specified either in money (base currency), or in percentage of maximum intraday equity (0 -100).
strategy.risk.max_intraday_loss(value, type, alert_message) → void
- strategy.risk.max_position_sizefunctionstrategy
The purpose of this rule is to determine maximum size of a market position. The rule affects the following function: strategy.entry(). The 'entry' quantity can be reduced (if needed) to such number of contracts/shares/lots/units, so the total position size doesn't exceed the…
strategy.risk.max_position_size(contracts) → void
- strategy.shortvariablestrategy
A named constant for use with the direction parameter of the strategy.entry() and strategy.order() commands. It specifies that the command creates a sell order.
- strategy.wintradesvariablestrategy
Number of profitable trades for the whole trading range.
- stringtypebuilt-in
Keyword used to explicitly declare the "string" type of a variable or a parameter.
- stringfunctionbuilt-in
Casts na to string
string(x) → const string
- switchkeywordbuilt-in
The switch operator transfers control to one of the several statements, depending on the values of a condition and expressions.
[variable_declaration = ] switch expression value1 => local_block value2 => local_block … => default_local_block [variable_declaration = ] switch condition1 => local_block condition2 => local_block … => default_local_block
- syminfo.basecurrencyvariablesyminfo
Returns a string containing the code representing the symbol's base currency (i.e., the traded currency or coin) if the instrument is a Forex or Crypto pair or a derivative based on such a pair. Otherwise, it returns an empty string.
- syminfo.countryvariablesyminfo
Returns the two-letter code of the country where the symbol is traded, in the ISO 3166-1 alpha-2 format, or na if the exchange is not directly tied to a specific country.
- syminfo.currencyvariablesyminfo
Returns a string containing the code representing the currency of the symbol's prices. For example, this variable returns "USD" for "NASDAQ:AAPL" and "JPY" for "EURJPY".
- syminfo.current_contractvariablesyminfo
The ticker identifier of the underlying contract, if the current symbol is a continuous futures contract; na otherwise.
- syminfo.descriptionvariablesyminfo
Description for the current symbol.
- syminfo.employeesvariablesyminfo
The number of employees the company has.
- syminfo.expiration_datevariablesyminfo
A UNIX timestamp representing the start of the last day of the current futures contract. This variable is only compatible with non-continuous futures symbols. On other symbols, it returns na.
- syminfo.industryvariablesyminfo
Returns the industry of the symbol, or na if the symbol has no industry. Example: "Internet Software/Services", "Packaged software", "Integrated Oil", "Motor Vehicles", etc. These are the same values one can see in the chart's "Symbol info" window.
- syminfo.isinvariablesyminfo
Holds a string representing a symbol's associated International Securities Identification Number (ISIN), or an empty string if there is no ISIN information available for the symbol. An ISIN is a 12-character alphanumeric code that uniquely identifies a security globally.
- syminfo.main_tickeridvariablesyminfo
A ticker identifier representing the current chart's symbol. The value contains an exchange prefix and a symbol name, separated by a colon (e.g., "NASDAQ:AAPL").
- syminfo.mincontractvariablesyminfo
The smallest amount of the current symbol that can be traded. This limit is set by the exchange. For cryptocurrencies, it is often less than 1 token. For most other types of asset, it is often 1.
- syminfo.minmovevariablesyminfo
Returns a whole number used to calculate the smallest increment between a symbol's price movements (syminfo.mintick). It is the numerator in the syminfo.mintick formula: syminfo.minmove / syminfo.pricescale = syminfo.mintick.
- syminfo.mintickvariablesyminfo
Min tick value for the current symbol.
- syminfo.pointvaluevariablesyminfo
The chart price of a security multiplied by the point value equals the actual price of the traded security.
- syminfo.prefixvariablesyminfo
Prefix of current symbol name (i.e. for 'CME_EOD:TICKER' prefix is 'CME_EOD').
- syminfo.prefixfunctionsyminfo
Returns exchange prefix of the symbol, e.g. "NASDAQ".
syminfo.prefix(symbol) → simple string
- syminfo.pricescalevariablesyminfo
Returns a whole number used to calculate the smallest increment between a symbol's price movements (syminfo.mintick). It is the denominator in the syminfo.mintick formula: syminfo.minmove / syminfo.pricescale = syminfo.mintick.
- syminfo.recommendations_buyvariablesyminfo
The number of analysts who gave the current symbol a "Buy" rating.
- syminfo.recommendations_buy_strongvariablesyminfo
The number of analysts who gave the current symbol a "Strong Buy" rating.
- syminfo.recommendations_datevariablesyminfo
The starting date of the last set of recommendations for the current symbol.
- syminfo.recommendations_holdvariablesyminfo
The number of analysts who gave the current symbol a "Hold" rating.
- syminfo.recommendations_sellvariablesyminfo
The number of analysts who gave the current symbol a "Sell" rating.
- syminfo.recommendations_sell_strongvariablesyminfo
The number of analysts who gave the current symbol a "Strong Sell" rating.
- syminfo.recommendations_totalvariablesyminfo
The total number of recommendations for the current symbol.
- syminfo.rootvariablesyminfo
Root for derivatives like futures contract. For other symbols returns the same value as syminfo.ticker.
- syminfo.sectorvariablesyminfo
Returns the sector of the symbol, or na if the symbol has no sector. Example: "Electronic Technology", "Technology services", "Energy Minerals", "Consumer Durables", etc. These are the same values one can see in the chart's "Symbol info" window.
- syminfo.sessionvariablesyminfo
Session type of the chart main series. Possible values are session.regular, session.extended.
- syminfo.shareholdersvariablesyminfo
The number of shareholders the company has.
- syminfo.shares_outstanding_floatvariablesyminfo
The total number of shares outstanding a company has available, excluding any of its restricted shares.
- syminfo.shares_outstanding_totalvariablesyminfo
The total number of shares outstanding a company has available, including restricted shares held by insiders, major shareholders, and employees.
- syminfo.target_price_averagevariablesyminfo
The average of the last yearly price targets for the symbol predicted by analysts.
- syminfo.target_price_datevariablesyminfo
The starting date of the last price target prediction for the current symbol.
- syminfo.target_price_estimatesvariablesyminfo
The latest total number of price target predictions for the current symbol.
- syminfo.target_price_highvariablesyminfo
The last highest yearly price target for the symbol predicted by analysts.
- syminfo.target_price_lowvariablesyminfo
The last lowest yearly price target for the symbol predicted by analysts.
- syminfo.target_price_medianvariablesyminfo
The median of the last yearly price targets for the symbol predicted by analysts.
- syminfo.tickervariablesyminfo
Symbol name without exchange prefix, e.g. 'MSFT'.
- syminfo.tickerfunctionsyminfo
Returns symbol name without exchange prefix, e.g. "AAPL".
syminfo.ticker(symbol) → simple string
- syminfo.tickeridvariablesyminfo
A ticker identifier representing the chart's symbol or a requested symbol, depending on how the script uses it. The variable's value represents a requested dataset's ticker ID when used in the expression argument of a request.*() function call.
- syminfo.timezonevariablesyminfo
Timezone of the exchange of the chart main series. Possible values see in timestamp().
- syminfo.typevariablesyminfo
The type of market the symbol belongs to. The values are "stock", "fund", "dr", "right", "bond", "warrant", "structured", "index", "forex", "futures", "spread", "economic", "fundamental", "crypto", "spot", "swap", "option", "commodity".
- syminfo.volumetypevariablesyminfo
Volume type of the current symbol. Possible values are: "base" for base currency, "quote" for quote currency, "tick" for the number of transactions, and "n/a" when there is no volume or its type is not specified.
- ta.accdistvariableta
Accumulation/distribution index.
- ta.almafunctionta
Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average.
ta.alma(series, length, offset, sigma, floor) → series float
- ta.atrfunctionta
Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close[1]), abs(low - close[1])).
ta.atr(length) → series float
- ta.barssincefunctionta
Counts the number of bars since the last time the condition was true.
ta.barssince(condition) → series int
- ta.bbfunctionta
Bollinger Bands. A Bollinger Band is a technical analysis tool defined by a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the security's price, but can be adjusted to user preferences.
ta.bb(series, length, mult) → [series float, series float, series float]
- ta.bbwfunctionta
Bollinger Bands Width. The Bollinger Band Width is the difference between the upper and the lower Bollinger Bands divided by the middle band.
ta.bbw(series, length, mult) → series float
- ta.ccifunctionta
The CCI (commodity channel index) is calculated as the difference between the typical price of a commodity and its simple moving average, divided by the mean absolute deviation of the typical price.
ta.cci(source, length) → series float
- ta.changefunctionta
Compares the current source value to its value length bars ago and returns the difference.
ta.change(source, length) → series int
- ta.cmofunctionta
Chande Momentum Oscillator. Calculates the difference between the sum of recent gains and the sum of recent losses and then divides the result by the sum of all price movement over the same period.
ta.cmo(series, length) → series float
- ta.cogfunctionta
The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.
ta.cog(source, length) → series float
- ta.correlationfunctionta
Correlation coefficient. Describes the degree to which two series tend to deviate from their ta.sma() values.
ta.correlation(source1, source2, length) → series float
- ta.crossfunctionta
source1 (series int/float) First data series.
ta.cross(source1, source2) → series bool
- ta.crossoverfunctionta
The source1-series is defined as having crossed over source2-series if, on the current bar, the value of source1 is greater than the value of source2, and on the previous bar, the value of source1 was less than or equal to the value of source2.
ta.crossover(source1, source2) → series bool
- ta.crossunderfunctionta
The source1-series is defined as having crossed under source2-series if, on the current bar, the value of source1 is less than the value of source2, and on the previous bar, the value of source1 was greater than or equal to the value of source2.
ta.crossunder(source1, source2) → series bool
- ta.cumfunctionta
Cumulative (total) sum of source. In other words it's a sum of all elements of source.
ta.cum(source) → series float
- ta.devfunctionta
Measure of difference between the series and it's ta.sma()
ta.dev(source, length) → series float
- ta.dmifunctionta
The dmi function returns the directional movement index.
ta.dmi(diLength, adxSmoothing) → [series float, series float, series float]
- ta.emafunctionta
The ema function returns the exponentially weighted moving average. In ema weighting factors decrease exponentially. It calculates by using a formula: EMA = alpha * source + (1 - alpha) * EMA[1], where alpha = 2 / (length + 1).
ta.ema(source, length) → series float
- ta.fallingfunctionta
Test if the source series is now falling for length bars long.
ta.falling(source, length) → series bool
- ta.highestfunctionta
Highest value for a given number of bars back.
ta.highest(source, length) → series float
- ta.highestbarsfunctionta
Highest value offset for a given number of bars back.
ta.highestbars(source, length) → series int
- ta.hmafunctionta
The hma function returns the Hull Moving Average.
ta.hma(source, length) → series float
- ta.iiivariableta
Intraday Intensity Index.
- ta.kcfunctionta
Keltner Channels. Keltner channel is a technical analysis indicator showing a central moving average line plus channel lines at a distance above and below.
ta.kc(series, length, mult, useTrueRange) → [series float, series float, series float]
- ta.kcwfunctionta
Keltner Channels Width. The Keltner Channels Width is the difference between the upper and the lower Keltner Channels divided by the middle channel.
ta.kcw(series, length, mult, useTrueRange) → series float
- ta.linregfunctionta
Linear regression curve. A line that best fits the prices specified over a user-defined time period. It is calculated using the least squares method.
ta.linreg(source, length, offset) → series float
- ta.lowestfunctionta
Lowest value for a given number of bars back.
ta.lowest(source, length) → series float
- ta.lowestbarsfunctionta
Lowest value offset for a given number of bars back.
ta.lowestbars(source, length) → series int
- ta.macdfunctionta
MACD (moving average convergence/divergence). It is supposed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock's price.
ta.macd(source, fastlen, slowlen, siglen) → [series float, series float, series float]
- ta.maxfunctionta
Returns the all-time high value of source from the beginning of the chart up to the current bar.
ta.max(source) → series float
- ta.medianfunctionta
Returns the median of the series.
ta.median(source, length) → series int
- ta.mfifunctionta
Money Flow Index. The Money Flow Index (MFI) is a technical oscillator that uses price and volume for identifying overbought or oversold conditions in an asset.
ta.mfi(series, length) → series float
- ta.minfunctionta
Returns the all-time low value of source from the beginning of the chart up to the current bar.
ta.min(source) → series float
- ta.modefunctionta
Returns the mode of the series. If there are several values with the same frequency, it returns the smallest value.
ta.mode(source, length) → series int
- ta.momfunctionta
Momentum of source price and source price length bars ago. This is simply a difference: source - source[length].
ta.mom(source, length) → series float
- ta.nvivariableta
Negative Volume Index.
- ta.obvvariableta
On Balance Volume.
- ta.percentile_linear_interpolationfunctionta
Calculates percentile using method of linear interpolation between the two nearest ranks.
ta.percentile_linear_interpolation(source, length, percentage) → series float
- ta.percentile_nearest_rankfunctionta
Calculates percentile using method of Nearest Rank.
ta.percentile_nearest_rank(source, length, percentage) → series float
- ta.percentrankfunctionta
Percent rank is the percents of how many previous values was less than or equal to the current value of given series.
ta.percentrank(source, length) → series float
- ta.pivot_point_levelsfunctionta
Calculates the pivot point levels using the specified type and anchor.
ta.pivot_point_levels(type, anchor, developing) → array<float>
- ta.pivothighfunctionta
This function returns price of the pivot high point. It returns 'NaN', if there was no pivot high point.
ta.pivothigh(leftbars, rightbars) → series float
- ta.pivotlowfunctionta
This function returns price of the pivot low point. It returns 'NaN', if there was no pivot low point.
ta.pivotlow(leftbars, rightbars) → series float
- ta.pvivariableta
Positive Volume Index.
- ta.pvtvariableta
Price-Volume Trend.
- ta.rangefunctionta
Returns the difference between the min and max values in a series.
ta.range(source, length) → series int
- ta.rcifunctionta
Calculates the Rank Correlation Index (RCI), which measures the directional consistency of price movements. It evaluates the monotonic relationship between a source series and the bar index over length bars using Spearman's rank correlation coefficient.
ta.rci(source, length) → series float
- ta.risingfunctionta
Test if the source series is now rising for length bars long.
ta.rising(source, length) → series bool
- ta.rmafunctionta
Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.
ta.rma(source, length) → series float
- ta.rocfunctionta
Calculates the percentage of change (rate of change) between the current value of source and its value length bars ago.
ta.roc(source, length) → series float
- ta.rsifunctionta
Relative strength index. It is calculated using the ta.rma() of upward and downward changes of source over the last length bars.
ta.rsi(source, length) → series float
- ta.sarfunctionta
Parabolic SAR (parabolic stop and reverse) is a method devised by J. Welles Wilder, Jr., to find potential reversals in the market price direction of traded goods.
ta.sar(start, inc, max) → series float
- ta.smafunctionta
The sma function returns the moving average, that is the sum of last y values of x, divided by y.
ta.sma(source, length) → series float
- ta.stdevfunctionta
source (series int/float) Series of values to process.
ta.stdev(source, length, biased) → series float
- ta.stochfunctionta
Stochastic. It is calculated by a formula: 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length)).
ta.stoch(source, high, low, length) → series float
- ta.supertrendfunctionta
The Supertrend Indicator. The Supertrend is a trend following indicator.
ta.supertrend(factor, atrPeriod) → [series float, series float]
- ta.swmafunctionta
Symmetrically weighted moving average with fixed length: 4. Weights: [1/6, 2/6, 2/6, 1/6].
ta.swma(source) → series float
- ta.trvariableta
True range, equivalent to ta.tr(handle_na = false). It is calculated as math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1])).
- ta.trfunctionta
Calculates the current bar's true range. Unlike a bar's actual range (high - low), true range accounts for potential gaps by taking the maximum of the current bar's actual range and the absolute distances from the previous bar's close to the current bar's high and low.
ta.tr(handle_na) → series float
- ta.tsifunctionta
True strength index. It uses moving averages of the underlying momentum of a financial instrument.
ta.tsi(source, short_length, long_length) → series float
- ta.valuewhenfunctionta
Returns the value of the source series on the bar where the condition was true on the nth most recent occurrence.
ta.valuewhen(condition, source, occurrence) → series color
- ta.variancefunctionta
Variance is the expectation of the squared deviation of a series from its mean (ta.sma()), and it informally measures how far a set of numbers are spread out from their mean.
ta.variance(source, length, biased) → series float
- ta.vwapvariableta
Volume Weighted Average Price. It uses hlc3 as its source series.
- ta.vwapfunctionta
Volume weighted average price.
ta.vwap(source, anchor) → series float
- ta.vwmafunctionta
The vwma function returns volume-weighted moving average of source for length bars back. It is the same as: sma(source * volume, length) / sma(volume, length).
ta.vwma(source, length) → series float
- ta.wadvariableta
Williams Accumulation/Distribution.
- ta.wmafunctionta
The wma function returns weighted moving average of source for length bars back. In wma weighting factors decrease in arithmetical progression.
ta.wma(source, length) → series float
- ta.wprfunctionta
Williams %R. The oscillator shows the current closing price in relation to the high and low of the past 'length' bars.
ta.wpr(length) → series float
- ta.wvadvariableta
Williams Variable Accumulation/Distribution.
- tabletypebuilt-in
Keyword used to explicitly declare the "table" type of a variable or a parameter. Table objects (or IDs) can be created with the table.new() function.
- tablefunctionbuilt-in
Casts na to table
table(x) → series table
- table.allvariabletable
Returns an array filled with all the current tables drawn by the script.
- table.cellfunctiontable
The function defines a cell in the table and sets its attributes.
table.cell(table_id, column, row, text, width, height, text_color, text_halign, text_valign, text_size, bgcolor, tooltip, text_font_family, text_formatting) → void
- table.cell_set_bgcolorfunctiontable
The function sets the background color of the cell.
table.cell_set_bgcolor(table_id, column, row, bgcolor) → void
- table.cell_set_heightfunctiontable
The function sets the height of cell.
table.cell_set_height(table_id, column, row, height) → void
- table.cell_set_textfunctiontable
The function sets the text in the specified cell.
table.cell_set_text(table_id, column, row, text) → void
- table.cell_set_text_colorfunctiontable
The function sets the color of the text inside the cell.
table.cell_set_text_color(table_id, column, row, text_color) → void
- table.cell_set_text_font_familyfunctiontable
The function sets the font family of the text inside the cell.
table.cell_set_text_font_family(table_id, column, row, text_font_family) → void
- table.cell_set_text_formattingfunctiontable
Sets the formatting attributes the drawing applies to displayed text.
table.cell_set_text_formatting(table_id, column, row, text_formatting) → void
- table.cell_set_text_halignfunctiontable
The function sets the horizontal alignment of the cell's text.
table.cell_set_text_halign(table_id, column, row, text_halign) → void
- table.cell_set_text_sizefunctiontable
The function sets the size of the cell's text.
table.cell_set_text_size(table_id, column, row, text_size) → void
- table.cell_set_text_valignfunctiontable
The function sets the vertical alignment of a cell's text.
table.cell_set_text_valign(table_id, column, row, text_valign) → void
- table.cell_set_tooltipfunctiontable
The function sets the tooltip in the specified cell.
table.cell_set_tooltip(table_id, column, row, tooltip) → void
- table.cell_set_widthfunctiontable
The function sets the width of the cell.
table.cell_set_width(table_id, column, row, width) → void
- table.clearfunctiontable
The function removes a cell or a sequence of cells from the table. The cells are removed in a rectangle shape where the start_column and start_row specify the top-left corner, and end_column and end_row specify the bottom-right corner.
table.clear(table_id, start_column, start_row, end_column, end_row) → void
- table.deletefunctiontable
The function deletes a table.
table.delete(table_id) → void
- table.merge_cellsfunctiontable
The function merges a sequence of cells in the table into one cell. The cells are merged in a rectangle shape where the start_column and start_row specify the top-left corner, and end_column and end_row specify the bottom-right corner.
table.merge_cells(table_id, start_column, start_row, end_column, end_row) → void
- table.newfunctiontable
The function creates a new table.
table.new(position, columns, rows, bgcolor, frame_color, frame_width, border_color, border_width, force_overlay) → series table
- table.set_bgcolorfunctiontable
The function sets the background color of a table.
table.set_bgcolor(table_id, bgcolor) → void
- table.set_border_colorfunctiontable
The function sets the color of the borders (excluding the outer frame) of the table's cells.
table.set_border_color(table_id, border_color) → void
- table.set_border_widthfunctiontable
The function sets the width of the borders (excluding the outer frame) of the table's cells.
table.set_border_width(table_id, border_width) → void
- table.set_frame_colorfunctiontable
The function sets the color of the outer frame of a table.
table.set_frame_color(table_id, frame_color) → void
- table.set_frame_widthfunctiontable
The function set the width of the outer frame of a table.
table.set_frame_width(table_id, frame_width) → void
- table.set_positionfunctiontable
The function sets the position of a table.
table.set_position(table_id, position) → void
- text.align_bottomvariabletext
Vertical text alignment for box.new(), box.set_text_valign(), table.cell() and table.cell_set_text_valign() functions.
- text.align_centervariabletext
Text alignment for box.new(), box.set_text_halign(), box.set_text_valign(), label.new() and label.set_textalign() functions.
- text.align_leftvariabletext
Horizontal text alignment for box.new(), box.set_text_halign(), label.new() and label.set_textalign() functions.
- text.align_rightvariabletext
Horizontal text alignment for box.new(), box.set_text_halign(), label.new() and label.set_textalign() functions.
- text.align_topvariabletext
Vertical text alignment for box.new(), box.set_text_valign(), table.cell() and table.cell_set_text_valign() functions.
- text.format_boldvariabletext
A named constant for use with the text_formatting parameter of the label.new(), box.new(), table.cell(), and *set_text_formatting() functions. Makes the text bold.
- text.format_italicvariabletext
A named constant for use with the text_formatting parameter of the label.new(), box.new(), table.cell(), and *set_text_formatting() functions. Italicizes the text.
- text.format_nonevariabletext
A named constant for use with the text_formatting parameter of the label.new(), box.new(), table.cell(), and *set_text_formatting() functions. Signifies no special text formatting.
- text.wrap_autovariabletext
Automatic wrapping mode for box.new() and box.set_text_wrap() functions.
- text.wrap_nonevariabletext
Disabled wrapping mode for box.new() and box.set_text_wrap() functions.
- ticker.heikinashifunctionticker
Creates a ticker identifier for requesting Heikin Ashi bar values.
ticker.heikinashi(symbol) → simple string
- ticker.inheritfunctionticker
Constructs a ticker ID for the specified symbol with additional parameters inherited from the ticker ID passed into the function call, allowing the script to request a symbol's data using the same modifiers that the from_tickerid has, including extended session, dividend…
ticker.inherit(from_tickerid, symbol) → simple string
- ticker.kagifunctionticker
Creates a ticker identifier for requesting Kagi values.
ticker.kagi(symbol, reversal) → simple string
- ticker.linebreakfunctionticker
Creates a ticker identifier for requesting Line Break values.
ticker.linebreak(symbol, number_of_lines) → simple string
- ticker.modifyfunctionticker
Creates a ticker identifier for requesting additional data for the script.
ticker.modify(tickerid, session, adjustment, backadjustment, settlement_as_close) → simple string
- ticker.newfunctionticker
Creates a ticker identifier for requesting additional data for the script.
ticker.new(prefix, ticker, session, adjustment, backadjustment, settlement_as_close) → simple string
- ticker.pointfigurefunctionticker
Creates a ticker identifier for requesting Point & Figure values.
ticker.pointfigure(symbol, source, style, param, reversal) → simple string
- ticker.renkofunctionticker
Creates a ticker identifier for requesting Renko values.
ticker.renko(symbol, style, param, request_wicks, source) → simple string
- ticker.standardfunctionticker
Creates a ticker to request data from a standard chart that is unaffected by modifiers like extended session, dividend adjustment, currency conversion, and the calculations of non-standard chart types: Heikin Ashi, Renko, etc.
ticker.standard(symbol) → simple string
- timevariablebuilt-in
Current bar time in UNIX format. It is the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970.
- timefunctionbuilt-in
Returns the opening UNIX timestamp for the specified timeframe and session, or na if the time point is outside the session.
time(timeframe, session, bars_back, timeframe_bars_back) → series int
- time_closevariablebuilt-in
The time of the current bar's close in UNIX format. It represents the number of milliseconds elapsed since 00:00:00 UTC, 1 January 1970. On tick charts and price-based charts such as Renko, line break, Kagi, point & figure, and range, this variable's series holds an na timestamp…
- time_closefunctionbuilt-in
Returns the closing UNIX timestamp for the specified timeframe and session, or na if the time point is outside the session. On tick charts and price-based charts such as Renko, line break, Kagi, point & figure, and range, the function returns na on the latest realtime bar…
time_close(timeframe, session, bars_back, timeframe_bars_back) → series int
- time_tradingdayvariablebuilt-in
The timestamp that represents 00:00 UTC of the trading day the current bar belongs to, in UNIX format (the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970).
- timeframe.changefunctiontimeframe
Detects changes in the specified timeframe.
timeframe.change(timeframe) → series bool
- timeframe.from_secondsfunctiontimeframe
Converts a number of seconds into a valid timeframe string.
timeframe.from_seconds(seconds) → simple string
- timeframe.in_secondsfunctiontimeframe
Converts a timeframe string into seconds.
timeframe.in_seconds(timeframe) → simple int
- timeframe.isdailyvariabletimeframe
Returns true if current resolution is a daily resolution, false otherwise.
- timeframe.isdwmvariabletimeframe
Returns true if current resolution is a daily or weekly or monthly resolution, false otherwise.
- timeframe.isintradayvariabletimeframe
Returns true if current resolution is an intraday (minutes or seconds) resolution, false otherwise.
- timeframe.isminutesvariabletimeframe
Returns true if current resolution is a minutes resolution, false otherwise.
- timeframe.ismonthlyvariabletimeframe
Returns true if current resolution is a monthly resolution, false otherwise.
- timeframe.issecondsvariabletimeframe
Returns true if current resolution is a seconds resolution, false otherwise.
- timeframe.isticksvariabletimeframe
Returns true if current resolution is a ticks resolution, false otherwise.
- timeframe.isweeklyvariabletimeframe
Returns true if current resolution is a weekly resolution, false otherwise.
- timeframe.main_periodvariabletimeframe
A string representation of the script's main timeframe. If the script is an indicator() that specifies a timeframe value in its declaration statement, this variable holds that value. Otherwise, its value represents the chart's timeframe.
- timeframe.multipliervariabletimeframe
Multiplier of resolution, e.g. '60' - 60, 'D' - 1, '5D' - 5, '12M' - 12.
- timeframe.periodvariabletimeframe
A string representation of the script's main timeframe or a requested timeframe, depending on how the script uses it. The variable's value represents the timeframe of a requested dataset when used in the expression argument of a request.*() function call.
- timenowvariablebuilt-in
Current time in UNIX format. It is the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970.
- timestampfunctionbuilt-in
Function timestamp returns UNIX time of specified date and time.
timestamp(dateString) → const int
- truevariablebuilt-in
Literal representing one of the values a bool variable can hold, or an expression can evaluate to when it uses comparison or logical operators.
- typekeywordbuilt-in
This keyword allows the declaration of user-defined types (UDT) from which scripts can instantiate objects. UDTs are composite types that contain an arbitrary number of fields of any built-in or user-defined type, including the defined UDT itself. The syntax to define a UDT is:
[export ]type <UDT_identifier> [varip ]<field_type> <field_name> [= <value>] …
- varkeywordbuilt-in
var is the keyword used for assigning and one-time initializing of the variable.
var variable_name = expression
- varipkeywordbuilt-in
varip (var intrabar persist) is the keyword used for the assignment and one-time initialization of a variable or a field of a user-defined type.
varip [<variable_type> ]<variable_name> = <expression> [export ]type <UDT_identifier> varip <field_type> <field_name> [= <value>]
- volumevariablebuilt-in
Current bar volume.
- volume_rowtypebuilt-in
A keyword that explicitly declares the type of a variable or parameter as volume_row. All footprint.*() functions that retrieve row data from a footprint object return an ID of the volume_row type.
- volume_row.buy_volumefunctionvolume_row
Calculates the total "buy" volume for the volume footprint row represented by a volume_row object.
volume_row.buy_volume(id) → series float
- volume_row.deltafunctionvolume_row
Calculates the volume delta for the volume footprint row represented by a volume_row object. The value represents the difference between the row's "buy" volume and "sell" volume.
volume_row.delta(id) → series float
- volume_row.down_pricefunctionvolume_row
Retrieves the lower price level of the volume footprint row represented by a volume_row object.
volume_row.down_price(id) → series float
- volume_row.has_buy_imbalancefunctionvolume_row
Checks whether the volume footprint row represented by a volume_row object has a "buy" imbalance, based on the imbalance_percent argument of the request.footprint() call that the object depends on.
volume_row.has_buy_imbalance(id) → series bool
- volume_row.has_sell_imbalancefunctionvolume_row
Checks whether the volume footprint row represented by a volume_row object has a sell imbalance, based on the imbalance_percent argument of the request.footprint() call that the object depends on.
volume_row.has_sell_imbalance(id) → series bool
- volume_row.sell_volumefunctionvolume_row
Calculates the total "sell" volume for the volume footprint row represented by a volume_row object.
volume_row.sell_volume(id) → series float
- volume_row.total_volumefunctionvolume_row
Calculates the sum of the "buy" and "sell" volume for the volume footprint row represented by a volume_row object.
volume_row.total_volume(id) → series float
- volume_row.up_pricefunctionvolume_row
Retrieves the upper price level of the volume footprint row represented by a volume_row object.
volume_row.up_price(id) → series float
- weekofyearvariablebuilt-in
The week number of the year, in the exchange time zone, calculated from the bar's opening UNIX timestamp.
- weekofyearfunctionbuilt-in
Calculates the week number of the year, in a specified time zone, from a UNIX timestamp.
weekofyear(time, timezone) → series int
- whilekeywordbuilt-in
Creates a condition-controlled loop whose local code block executes repeatedly while the value of a conditional expression remains true. The loop's iterations end after the condition's value becomes false.
[variables = | :=] while condition statements | continue | break return_expression
- xloc.bar_indexvariablexloc
A constant that specifies how functions that create and modify Pine drawings interpret x-coordinates. If xloc = xloc.bar_index, the drawing object treats each x-coordinate as a bar_index value.
- xloc.bar_timevariablexloc
A constant that specifies how functions that create and modify Pine drawings interpret x-coordinates. If xloc = xloc.bar_time, the drawing object treats each x-coordinate as a UNIX timestamp, expressed in milliseconds.
- yearvariablebuilt-in
Current bar year in exchange timezone.
- yearfunctionbuilt-in
time (series int) UNIX time in milliseconds.
year(time, timezone) → series int
- yloc.abovebarvariableyloc
A named constant that specifies the algorithm of interpretation of y-value in function label.new().
- yloc.belowbarvariableyloc
A named constant that specifies the algorithm of interpretation of y-value in function label.new().
- yloc.pricevariableyloc
A named constant that specifies the algorithm of interpretation of y-value in function label.new().
| Feature | V6 | V5 | V4 | V3 |
|---|---|---|---|---|
| Enhanced Type System | ✓ | — | — | — |
| Improved Performance | ✓ | — | — | — |
| New Built-in Functions | ✓ | — | — | — |
| Better Error Messages | ✓ | — | — | — |
| Advanced Debugging Tools | ✓ | — | — | — |
| Objects and Methods | — | ✓ | — | — |
| Libraries Support | — | ✓ | — | — |
| Enhanced Arrays | — | ✓ | — | — |
| Improved Maps | — | ✓ | — | — |
| Type System Improvements | — | ✓ | — | — |
| Core Pine Script Features | — | — | ✓ | — |
| Basic Type System | — | — | ✓ | — |
| Essential Built-ins | — | — | ✓ | — |
| Standard Library | — | — | ✓ | — |
| Basic Pine Script | — | — | — | ✓ |
| Simple Indicators | — | — | — | ✓ |
| Core Functions | — | — | — | ✓ |
Offline Downloads
TradingView's Pine Script manual, mirrored into a file you can read with no connection: every page, every figure, searchable. Fetched 29 October 2026, free, no account needed.
Community Resources
Handpicked resources from the Pine Script community to help you learn, develop, and master trading automation.

TradingView Official Website
The official platform for charting, trading, and Pine Script automation.

PineCoders Website
An excellent resource managed by the Official Pine Script Team, with FAQs and code snippets.

Pine Script Blog (TradingView)
Official blog for updates on the newest Pine Script advancements and features.

BackTest Rookies
A solid website offering tutorials and tips and tricks on Pine Script and TradingView.

Kodify
An independent website with a blog and tutorials on Pine Script, particularly good for beginners.

GitHub Repos Tagged with Pine Script
Explore open-source scripts and projects related to Pine Script on GitHub.

Keyboard Shortcuts For Pine Editor
Become a Pine Maestro with quick hands and shortcuts for the Pine Editor.

Awesome Pine Script (GitHub)
A curated GitHub repository with a comprehensive collection of Pine Script resources.