ToStringMx█ OVERVIEW
Contains methods for conversion of matrices to string.
Supports matrices of int/float/bool/string/color/line/label/box/.
- toStringMx(matrix) - converts matrix to a string matrix converting each of its elements to string
- toS(matrix) - converts matrix to a string matrix (using toStringMx()) and outputs as string using str.tostring(matrix)
Conversion of each item to string is made using toS() function from moebius1977/ToS/1 library.
█ GENERAL DESCRIPTION OF FUNCTIONS
All toStringMx(matrix) and toS(matrix) methods have same parameters. The only difference will be in format parameter as explained below.
Parameters:
this (matrix) Matrix to be converted to a string matrix.
format (string) Format string.
nz (string) Placeholder for na items.
format parameter depends on the type:
For matrix format parameter works in the same way as `str.format()` (i.e. you can use same format strings as with `str.format()` with `{0}` as a placeholder for the value) with some shorthand "format" options available:
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "... ... " in any place is substituted with "{0, time, HH.mm.ss}"
For matrix :
format (string) : (string) (Optional) Use `x1` as placeholder for `x1` and so on. E.g. default format is `"(x1, y1) - (x2, y2)"`.
For matrix :
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` and `txt` for label's text. E.g. default format is `(x1, y1): "txt"` if ptint_text is true and `(x1, y1)` if false.
For matrix :
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` etc. E.g. default format is "(x1, y1) - (x2, y2)".
For matrix :
format (string) : (string) (Optional) Options are "HEX" (e.g. "#FFFFFF33") or "RGB" (e.g. "rgb(122,122,122,23)"). Default is "HEX".
█ FULL LIST OF FUNCTIONS AND PARAMETERS
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) Like in str.format()
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) Like in str.format() with some shorthand options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "... ... " in any place is substituted with "{0, time, HH.mm.ss}"
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) Like in str.format() with some shorthand options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "... ... " in any place is substituted with "{0, time, HH.mm.ss}"
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) Like in str.format()
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) "HEX" (default) or "RGB"
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toStringMx(mx, format, nz)
Returns a string matrix made of original matrix items converted to string with toS().
Namespace types: matrix
Parameters:
mx (matrix)
format (string) : (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.
method toS(this, format, nz)
Converts each element of the matrix to string outputs using str.tostring(matrix)
Namespace types: matrix
Parameters:
this (matrix) : (matrix) Matrix to be converted to string
format (string) : (string) Format string as in str.format()
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
method toS(this, format, nz)
Converts each element of the matrix to string outputs using str.tostring(matrix)
Namespace types: matrix
Parameters:
this (matrix) : (matrix) Matrix to be converted to string
format (string) : (string) Like in str.format() with some shorthand options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "... ... " in any place is substituted with "{0, time, HH.mm.ss}"
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
method toS(this, format, nz)
Converts each element of the matrix to string outputs using str.tostring(matrix)
Namespace types: matrix
Parameters:
this (matrix) : (matrix) Matrix to be converted to string
format (string) : (string) Format string as in str.format()
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
method toS(this, format, nz)
Converts each element of the matrix to string outputs using str.tostring(matrix)
Namespace types: matrix
Parameters:
this (matrix) : (matrix) Matrix to be converted to string
format (string) : (string) "HEX" (default) or "RGB"
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
method toS(this, format, nz)
Converts each element of the matrix to string outputs using str.tostring(matrix)
Namespace types: matrix
Parameters:
this (matrix) : (matrix) Matrix to be converted to string
format (string) : (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
method toS(this, format, nz)
Converts each element of the matrix to string outputs using str.tostring(matrix)
Namespace types: matrix
Parameters:
this (matrix) : (matrix) Matrix to be converted to string
format (string) : (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
method toS(this, format, nz)
Converts each element of the matrix to string outputs using str.tostring(matrix)
Namespace types: matrix
Parameters:
this (matrix) : (matrix) Matrix to be converted to string
format (string) : (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
nz (string) : (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
Indicators and strategies
ToStringAr█ OVERVIEW
Contains to string conversion methods arrays of int/float/bool/string/line/label/box types
- toS() - method works like array.join() with more flexibility and
- toStringAr() - converts array to string on a per item basis and returns the resulting string array
Conversion of each item to string is made using toS() function from moebius1977/ToS/1 library.
█ GENERAL DESCRIPTION OF LIBRARY FUNCTIONS
All toS(array) methods have same parameters. The only difference will be in format parameter as explained below.
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Like array.join() but with string length limit. Joins elements into readable string (length capped at 4000, truncating the end or beg)
Parameters:
this (array) : array to be converted to string
index_from (int) : index_from (int) (Optional) Start from this id (starting from 0, in insertion order). If omitted - start from the first item.
index_to (int) : index_to (int) (Optional) End with this pair (inclusive, in insertion order). If omitted - to last item.
separator (string) : separator (string) (Optional) String to be inserted between pairs. Default: `", "`
showIDs (bool) : showIDs (bool) (Optional) If true item's id is added in the form `id: value`.
format (string) : format (string) (Optional) Format string fo toS(). If omitted default format is used depending in the type.
truncate_left (bool) : truncate_left (bool) (Optional) Truncate from left or right. Default: false.
size_limit (int) : size_limit (int) (Optional) Max output string length. Default: 4000.
nz (string) : nz (string) (Optional) A string used to represent na (na values are substituted with this string).
format parameter depends on the type:
For toS(bool/int/float ...) format parameter works in the same way as `str.format()` (i.e. you can use same format strings as with `str.format()` with `{0}` as a placeholder for the value) with some shorthand "format" options available:
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "... ... " in any place is substituted with "{0, date, dd.MM.YY}" (e.g. " " results in "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}")
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
--- time ---
- "... ... " in any place is substituted with "{0, time, HH.mm.ss}" (e.g. " " results in "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}")
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
For toS(line ...):
format (string) : (string) (Optional) Use `x1` as placeholder for `x1` and so on. E.g. default format is `"(x1, y1) - (x2, y2)"`.
For toS(label ...) :
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` and `txt` for label's text. E.g. default format is `(x1, y1): "txt"` if ptint_text is true and `(x1, y1)` if false.
For toS(box ... ) :
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` etc. E.g. default format is "(x1, y1) - (x2, y2)".
For toS(color] ... ) :
format (string) : (string) (Optional) Options are "HEX" (e.g. "#FFFFFF33") or "RGB" (e.g. "rgb(122,122,122,23)"). Default is "HEX".
All toStringAr() methods just convert each item to string using toS with same format options as described above.
Parameters:
arr (array) : Array to be converted to a string array.
format (string) : Format string.
nz (string) : Placeholder for na items.
█ FULL OF FUNCTIONS AND PARAMETERS
Library "ToStringAr"
Contains toString/toS conversion methods for int/float/bool/string/line/label/box and arrays and matrices thereof. Also contains a string wraping function.
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz)
Namespace types: array
Parameters:
this (array)
index_from (int)
index_to (int)
separator (string)
showIDs (bool)
format (string)
truncate_left (bool)
size_limit (int)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
method toStringAr(arr, format, nz)
Namespace types: array
Parameters:
arr (array)
format (string)
nz (string)
display_valueOVERVIEW
This script is a tinny library for creating and displaying formatted values in TradingView scripts. It provides a structured way to present key information like titles, percentages, currency values, decimals, and integers with clear formatting. This allows you to coordinate your strings in advance and hold one item to use for calling your string to a label, box, table.. Made for day to day use of most typical use cases, more advanced techniques should be used for complicated scenarios.
Building Blocks
User Defined Types (UDTs)
The script defines a UDT called `DisplayValue` to encapsulate the components of a display value:
* title : The title or label of the value.
* format_string : The string used to format the value (e.g., "{0} - 1,number,percent}").
* value : The actual value to be displayed.
* format : An enum value specifying the desired format (percent, currency, etc.).
Enums
The `DisplayFormat` enum provides predefined constants for various formatting options, making the code more readable and less prone to errors.
Functions
* create() : This function creates a new `DisplayValue` instance. It takes the title, value, and desired format as arguments and generates the appropriate format string.
* to_string() : This function converts a `DisplayValue` instance into a formatted string ready for display on the chart.
How to Use
1. Import the library:
import kaigouthro/display_value/1as dv
2. Create a DisplayValue instance:
myValue = dv.create("My Percentage", 0.5, dv.DisplayFormat.percent)
3. Convert it to a string:
formattedString = dv.to_string(myValue)
4. Display the formatted string:
label.new(bar_index, high, formattedString)
Example
//@version=5
import kaigouthro/display_value/1 as dv
myValue = dv.create("Profit", 0.15, dv.DisplayFormat.percent)
formattedString = dv.to_string(myValue)
label.new(bar_index, high, formattedString)
This will display a label on the chart with the text "Profit - 15%".
### Notes
* The library handles the formatting details, making it easier to display values consistently in your scripts.
* The use of enums and UDTs improves code organization and readability.
--------
Library "display_value"
create(display_name, display_value, display_format)
Gets the appropriate format string based on the display format.
Parameters:
display_name (string) : (string) The name of the display value. Default is na.
display_value (float)
display_format (series DisplayFormat)
Returns: (DisplayValue) A new DisplayValue instance with the formatted value.
to_string(item)
Converts the display value to a string with the specified format.
Parameters:
item (DisplayValue) : (DisplayValue) The display value to convert to a string.
Returns: (string) The string representation of the display value.
DisplayValue
Structure representing a display value.
Fields:
title (series string) : (string) The title of the display value.
format_string (series string) : (string) The format string to use for display.
value (series float) : (float) The value to display.
format (series DisplayFormat) : (DisplayFormat) The format to use.
analytics_tablesLibrary "analytics_tables"
📝 Description
This library provides the implementation of several performance-related statistics and metrics, presented in the form of tables.
The metrics shown in the afforementioned tables where developed during the past years of my in-depth analalysis of various strategies in an atempt to reason about the performance of each strategy.
The visualization and some statistics where inspired by the existing implementations of the "Seasonality" script, and the performance matrix implementations of @QuantNomad and @ZenAndTheArtOfTrading scripts.
While this library is meant to be used by my strategy framework "Template Trailing Strategy (Backtester)" script, I wrapped it in a library hoping this can be usefull for other community strategy scripts that will be released in the future.
🤔 How to Guide
To use the functionality this library provides in your script you have to import it first!
Copy the import statement of the latest release by pressing the copy button below and then paste it into your script. Give a short name to this library so you can refer to it later on. The import statement should look like this:
import jason5480/analytics_tables/1 as ant
There are three types of tables provided by this library in the initial release. The stats table the metrics table and the seasonality table.
Each one shows different kinds of performance statistics.
The table UDT shall be initialized once using the `init()` method.
They can be updated using the `update()` method where the updated data UDT object shall be passed.
The data UDT can also initialized and get updated on demend depending on the use case
A code example for the StatsTable is the following:
var ant.StatsData statsData = ant.StatsData.new()
statsData.update(SideStats.new(), SideStats.new(), 0)
if (barstate.islastconfirmedhistory or (barstate.isrealtime and barstate.isconfirmed))
var statsTable = ant.StatsTable.new().init(ant.getTablePos('TOP', 'RIGHT'))
statsTable.update(statsData)
A code example for the MetricsTable is the following:
var ant.StatsData statsData = ant.StatsData.new()
statsData.update(ant.SideStats.new(), ant.SideStats.new(), 0)
if (barstate.islastconfirmedhistory or (barstate.isrealtime and barstate.isconfirmed))
var metricsTable = ant.MetricsTable.new().init(ant.getTablePos('BOTTOM', 'RIGHT'))
metricsTable.update(statsData, 10)
A code example for the SeasonalityTable is the following:
var ant.SeasonalData seasonalData = ant.SeasonalData.new().init(Seasonality.monthOfYear)
seasonalData.update()
if (barstate.islastconfirmedhistory or (barstate.isrealtime and barstate.isconfirmed))
var seasonalTable = ant.SeasonalTable.new().init(seasonalData, ant.getTablePos('BOTTOM', 'LEFT'))
seasonalTable.update(seasonalData)
🏋️♂️ Please refer to the "EXAMPLE" regions of the script for more advanced and up to date code examples!
Special thanks to @Mrcrbw for the proposal to develop this library and @DCNeu for the constructive feedback 🏆.
getTablePos(ypos, xpos)
Get table position compatible string
Parameters:
ypos (simple string) : The position on y axise
xpos (simple string) : The position on x axise
Returns: The position to be passed to the table
method init(this, pos, height, width, positiveTxtColor, negativeTxtColor, neutralTxtColor, positiveBgColor, negativeBgColor, neutralBgColor)
Initialize the stats table object with the given colors in the given position
Namespace types: StatsTable
Parameters:
this (StatsTable) : The stats table object
pos (simple string) : The table position string
height (simple float) : The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells
width (simple float) : The width of the table as a percentage of the charts height. By default, 0 auto-adjusts the width based on the text inside the cells
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
neutralTxtColor (simple color) : The text color when neutral
positiveBgColor (simple color) : The background color with transparency when positive
negativeBgColor (simple color) : The background color with transparency when negative
neutralBgColor (simple color) : The background color with transparency when neutral
method init(this, pos, height, width, neutralBgColor)
Initialize the metrics table object with the given colors in the given position
Namespace types: MetricsTable
Parameters:
this (MetricsTable) : The metrics table object
pos (simple string) : The table position string
height (simple float) : The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells
width (simple float) : The width of the table as a percentage of the charts width. By default, 0 auto-adjusts the width based on the text inside the cells
neutralBgColor (simple color) : The background color with transparency when neutral
method init(this, seas)
Initialize the seasonal data
Namespace types: SeasonalData
Parameters:
this (SeasonalData) : The seasonal data object
seas (simple Seasonality) : The seasonality of the matrix data
method init(this, data, pos, maxNumOfYears, height, width, extended, neutralTxtColor, neutralBgColor)
Initialize the seasonal table object with the given colors in the given position
Namespace types: SeasonalTable
Parameters:
this (SeasonalTable) : The seasonal table object
data (SeasonalData) : The seasonality data of the table
pos (simple string) : The table position string
maxNumOfYears (simple int) : The maximum number of years that fit into the table
height (simple float) : The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells
width (simple float) : The width of the table as a percentage of the charts width. By default, 0 auto-adjusts the width based on the text inside the cells
extended (simple bool) : The seasonal table with extended columns for performance
neutralTxtColor (simple color) : The text color when neutral
neutralBgColor (simple color) : The background color with transparency when neutral
method update(this, wins, losses, numOfInconclusiveExits)
Update the strategy info data of the strategy
Namespace types: StatsData
Parameters:
this (StatsData) : The strategy statistics object
wins (SideStats)
losses (SideStats)
numOfInconclusiveExits (int) : The number of inconclusive trades
method update(this, stats, positiveTxtColor, negativeTxtColor, negativeBgColor, neutralBgColor)
Update the stats table object with the given data
Namespace types: StatsTable
Parameters:
this (StatsTable) : The stats table object
stats (StatsData) : The stats data to update the table
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
negativeBgColor (simple color) : The background color with transparency when negative
neutralBgColor (simple color) : The background color with transparency when neutral
method update(this, stats, buyAndHoldPerc, positiveTxtColor, negativeTxtColor, positiveBgColor, negativeBgColor)
Update the metrics table object with the given data
Namespace types: MetricsTable
Parameters:
this (MetricsTable) : The metrics table object
stats (StatsData) : The stats data to update the table
buyAndHoldPerc (float) : The buy and hold percetage
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
positiveBgColor (simple color) : The background color with transparency when positive
negativeBgColor (simple color) : The background color with transparency when negative
method update(this)
Update the seasonal data based on the season and eon timeframe
Namespace types: SeasonalData
Parameters:
this (SeasonalData) : The seasonal data object
method update(this, data, positiveTxtColor, negativeTxtColor, neutralTxtColor, positiveBgColor, negativeBgColor, neutralBgColor, timeBgColor)
Update the seasonal table object with the given data
Namespace types: SeasonalTable
Parameters:
this (SeasonalTable) : The seasonal table object
data (SeasonalData) : The seasonal cell data to update the table
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
neutralTxtColor (simple color) : The text color when neutral
positiveBgColor (simple color) : The background color with transparency when positive
negativeBgColor (simple color) : The background color with transparency when negative
neutralBgColor (simple color) : The background color with transparency when neutral
timeBgColor (simple color) : The background color of the time gradient
SideStats
Object that represents the strategy statistics data of one side win or lose
Fields:
numOf (series int)
sumFreeProfit (series float)
freeProfitStDev (series float)
sumProfit (series float)
profitStDev (series float)
sumGain (series float)
gainStDev (series float)
avgQuantityPerc (series float)
avgCapitalRiskPerc (series float)
avgTPExecutedCount (series float)
avgRiskRewardRatio (series float)
maxStreak (series int)
StatsTable
Object that represents the stats table
Fields:
table (series table) : The actual table
rows (series int) : The number of rows of the table
columns (series int) : The number of columns of the table
StatsData
Object that represents the statistics data of the strategy
Fields:
wins (SideStats)
losses (SideStats)
numOfInconclusiveExits (series int)
avgFreeProfitStr (series string)
freeProfitStDevStr (series string)
lossFreeProfitStDevStr (series string)
avgProfitStr (series string)
profitStDevStr (series string)
lossProfitStDevStr (series string)
avgQuantityStr (series string)
MetricsTable
Object that represents the metrics table
Fields:
table (series table) : The actual table
rows (series int) : The number of rows of the table
columns (series int) : The number of columns of the table
SeasonalData
Object that represents the seasonal table dynamic data
Fields:
seasonality (series Seasonality)
eonToMatrixRow (map)
numOfEons (series int)
mostRecentMatrixRow (series int)
balances (matrix)
returnPercs (matrix)
maxDDs (matrix)
eonReturnPercs (array)
eonCAGRs (array)
eonMaxDDs (array)
SeasonalTable
Object that represents the seasonal table
Fields:
table (series table) : The actual table
headRows (series int) : The number of head rows of the table
headColumns (series int) : The number of head columns of the table
eonRows (series int) : The number of eon rows of the table
seasonColumns (series int) : The number of season columns of the table
statsRows (series int)
statsColumns (series int) : The number of stats columns of the table
rows (series int) : The number of rows of the table
columns (series int) : The number of columns of the table
extended (series bool) : Whether the table has additional performance statistics
ToS█ OVERVIEW
Contains methods for conversion to string of simple types int/float/bool/string/line/label/box .
- toS() - For bool/int/float works much the same as str.tostring() with some shorthand formatting options for int/float. For line/label/box displays their text and coordinates automatically formatting x coordinate as time or bar index.
- toShortString() - Converts a number to a short form using "k", "m", "bn" and "T" nominators. (e.g. `12,350` --> `12.4k`).
Supports some shorthand formatting options for int/float and time.
█ HOW TO USE
All toS() methods have the same parameters:
Parameters:
val (int) : A float to be converted to string
format (string) : Format string, which depends on the value type
nz (string) : (string) A string used to represent na (na values are substituted with this string).
For toS(bool/int/float) format parameter works in the same way as `str.format()` (i.e. you can use same format strings as with `str.format()` with `{0}` as a placeholder for the value)
Some shorthand "format" options available:
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "... ... " in any place is substituted with "{0, date, dd.MM.YY}"
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
--- time ---
- "... ... " in any place is substituted with "{0, time, HH.mm.ss}"
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
For toS(line) :
format (string) : (string) (Optional) Use `x1` as placeholder for `x1` and so on. E.g. default format is `"(x1, y1) - (x2, y2)"`.
For toS(label) :
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` and `txt` for label's text. E.g. default format is `(x1, y1): "txt"` if ptint_text is true and `(x1, y1)` if false.
For toS(box) :
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` etc. E.g. default format is "(x1, y1) - (x2, y2)".
For toS(color) :
format (string) : (string) (Optional) Options are "HEX" (e.g. "#FFFFFF33") or "RGB" (e.g. "rgb(122,122,122,23)"). Default is "HEX".
█ LIST OF FUNCTIONS AND PARAMETERS
method toS(val, format, nz)
Formats the `int/float` in the same way as `str.format()` (i.e. you can use same format strings as with
`str.format()` with `{0}` arg) with some shorthand "format" options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "......" in angular brackets in any place is substituted with "{0, date, dd.MM.YY}"
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
--- time ---
- "......" in angular brackets in any place is substituted with "{0, time, HH.mm.ss}"
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
```
Namespace types: series int, simple int, input int, const int
Parameters:
val (int) : A float to be converted to string
format (string) : Format string (e.g. "0.000" or "date : time" or "HH:mm")
nz (string) : (string) A string used to represent na (na values are substituted with this string).
method toS(val, format, nz)
Formats the `int/float` in the same way as `str.format()` (i.e. you can use same format strings as with
`str.format()` with `{0}` arg) with some shorthand "format" options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "......" in angular brackets in any place is substituted with "{0, date, dd.MM.YY}"
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
--- time ---
- "......" in angular brackets in any place is substituted with "{0, time, HH.mm.ss}"
- "time" => "{0, time, HH:mm:ss}"
- "HH:mm" => "{0, time, HH:mm}"
- "mm:ss" => "{0, time, mm:ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
- "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}"
- "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}"
- "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}"
```
Namespace types: series float, simple float, input float, const float
Parameters:
val (float) : A float to be converted to string
format (string) : Format string (e.g. "0.000" or "date : time" or "HH:mm")
nz (string) : (string) A string used to represent na (na values are substituted with this string).
method toS(val, format, nz)
Formats `bool val` in the same way as `str.format()` (i.e. you can use same format strings as with
`str.format()` with `{0}` placeholder for the `val` argument).
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
val (bool) : (bool) Value to be formatted
format (string)
nz (string) : (string) A string used to represent na (na values are substituted with this string).
method toS(val, format, nz)
Formats `string val` in the same way as `str.format()` (i.e. you can use same format strings as with
`str.format()` with `{0}` placeholder for the `val` argument).
Namespace types: series color, simple color, input color, const color
Parameters:
val (color)
format (string) : (string) "HEX" or "RGB"
nz (string) : (string) A string used to represent na (na values are substituted with this string).
method toS(val, format, nz)
Formats `string val` in the same way as `str.format()` (i.e. you can use same format strings as with
`str.format()` with `{0}` placeholder for the `val` argument).
Namespace types: series string, simple string, input string, const string
Parameters:
val (string)
format (string)
nz (string) : (string) A string used to represent na (na values are substituted with this string).
method toS(ln, format, nz)
Returns line's coordinates as a string (by default in "(x1, y1) - (x2, y2)" format, use `x1`, `y1`, `x2`,`y2` as placeholders in `format` string)). Automatically detects
whether the coordinates are in `xloc.bar_index` or `xloc.bar_time` and displays
accordingly (in _dd.MM.yy HH:mm:ss_ format)
Namespace types: series line
Parameters:
ln (line)
format (string) : (string) (Optional) Use `x1` as placeholder for `x1` and so on. E.g. default format is `"(x1, y1) - (x2, y2)"`.
nz (string) : (string) (Optional) If `val` is `na` and `nz` is not `na` the value of `nz` param is returned instead.
method toS(lbl, format, nz, print_text)
Returns label's coordinates and text as a string (by default in "(x, y): text = ...)" format; use `x1`, `y1`, `txt` as placeholders in `format` string))).
Automatically detects whether the coordinates are in `xloc.bar_index` or `xloc.bar_time` and displays.
accordingly (in _dd.MM.yy HH:mm:ss_ format)
Namespace types: series label
Parameters:
lbl (label)
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` and `txt` for label's text. E.g. default format is `(x1, y1): "txt"`.
nz (string) : (string) A string used to represent na (na values are substituted with this string).
print_text (bool)
method toS(bx, format, nz)
Returns box's coordinates as a string (by default in "(x1, y1) - (x2, y2)" format)
Namespace types: series box
Parameters:
bx (box)
format (string) : (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` etc. E.g. default format is "(x1, y1) - (x2, y2)".
nz (string) : (string) A string used to represent na (na values are substituted with this string).
method toShortString(this, decimals)
Converts number to a short form using "k", "m", "bn" and "T" nominators. (e.g. `12,350` --> `12.4k`).
@this (series float) Number to be converted to short format.
@decimals (series int) Optional argument. Decimal places to which number will be rounded. When no argument
is supplied, rounding is to the nearest integer.
Namespace types: series float, simple float, input float, const float
Parameters:
this (float)
decimals (int)
Killzones And Macros LibraryKillzones & Macros Library for Trading Sessions
This Pine Script library is designed to help traders identify and act during high-volatility trading windows, commonly referred to as "Killzones." These are specific times during the day when institutional traders are most active, resulting in increased liquidity and price movement. The library provides boolean fields that return true when the current time falls within one of the killzones or macroeconomic event windows, allowing for enhanced trade timing and precision.
Killzones Include:
London Open, New York Open, Midnight Open, London Lunch, New York PM, and more.
Capture high-volume periods like Power Hour, Equities Open, and Asian Range.
Macros:
Identify key moments like London 02:33, New York 08:50, and other significant times aligned with market movements or events.
This library is perfect for integrating into your custom strategies, backtesting, or setting alerts for optimal trade execution during major trading sessions and events.
mlivsLibrary "mlivs"
TODO: add library description here
adx(high, low, adxlen, dilen)
TODO: add function description here
Parameters:
high (float)
low (float)
adxlen (simple int)
dilen (simple int)
Returns: TODO: add what function returns
adxMA()
impulseMACD(lengthMA, lengthSignal)
Parameters:
lengthMA (simple int)
lengthSignal (int)
movingAveragesUtilitiesLibrary "movingAveragesUtilities"
get_movingAverages_data(source, length_fast, length_medium, length_slow)
Parameters:
source (float)
length_fast (simple int)
length_medium (simple int)
length_slow (simple int)
gridUtilitiesLibrary "gridUtilities"
TODO: add library description here
get_fibonacciGrid_data(length, trend_direction, plot_grid, plot_labels, bars_to_right, include_levels)
: Gets and plots a fibonacci grid.
Parameters:
length (int) : (int): The direction flag that indicates where the trend is going.
trend_direction (string) : (string): Direction of the trend (Long, Short or Neutral)
plot_grid (bool) : (bool): Plots the fibonacci grid.
plot_labels (bool) : (bool): Plots the datatable.
bars_to_right (int) : (bool): Plots the datatable.
include_levels (bool) : (bool): Plots the datatable.
Returns: : Returns a map with the grid levels, as string with the direction of the grid and a map with the values for the dataTable.
BinaryInsertionSortLibrary "BinaryInsertionSort"
Library containing functions which can help create sorted array based on binary insertion sort.
This sorting will be quicker than array.sort function if the sorting needs to be done on every bar and the size of the array is comparatively big.
method binary_search_basic(sortedArray, item, order)
binary_search_basic - finds the closest index of the value
Namespace types: array
Parameters:
sortedArray (array) : array which is assumed to be sorted in the requested order
item (float) : float item which needs to be searched in the sorted array
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns: int index at which the item can be inserted into sorted array
method binary_search_basic(sortedArray, item, order)
binary_search_basic - finds the closest index of the value
Namespace types: array
Parameters:
sortedArray (array) : array which is assumed to be sorted in the requested order
item (int) : int item which needs to be searched in the sorted array
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns: int index at which the item can be inserted into sorted array
method binary_insertion_sort(sortedArray, item, order)
binary insertion sort - inserts item into sorted array while maintaining sort order
Namespace types: array
Parameters:
sortedArray (array) : array which is assumed to be sorted in the requested order
item (float) : float item which needs to be inserted into sorted array
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns: int index at which the item is inserted into sorted array
method binary_insertion_sort(sortedArray, item, order)
binary insertion sort - inserts item into sorted array while maintaining sort order
Namespace types: array
Parameters:
sortedArray (array) : array which is assumed to be sorted in the requested order
item (int) : int item which needs to be inserted into sorted array
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns: int index at which the item is inserted into sorted array
update_sort_indices(sortIndices, newItemIndex)
adds the sort index of new item added to sorted array and also updates existing sort indices.
Parameters:
sortIndices (array) : array containing sort indices of an array.
newItemIndex (int) : sort index of new item added to sorted array
Returns: void
get_array_of_series(item, order)
Converts series into array and sorted array.
Parameters:
item (float) : float series
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns:
get_array_of_series(item, order)
Converts series into array and sorted array.
Parameters:
item (int) : int series
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns:
get_sorted_arrays(item, order)
Converts series into array and sorted array. Also calculates the sort order of the value array
Parameters:
item (float) : float|int series
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns:
get_sorted_arrays(item, order)
Converts series into array and sorted array. Also calculates the sort order of the value array
Parameters:
item (int) : int series
order (int) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns:
volumeUtilitiesLibrary "volumeUtilities"
generate_and_plot_volumeProfile(length, valueArea_perc, plot_vp, show_vp_labels, include_vp_levels)
: Generate and plot volume profile
Parameters:
length (int) : (int): Length of the volume profile indicator
valueArea_perc (float) : (float): Percentage of the volume that will be in the value area
plot_vp (bool) : (bool): Flag to plot or not the indicator
show_vp_labels (bool) : (bool): Flag to plot the labels of the levels
include_vp_levels (bool) : (bool): Flag to include the values inside the labels of the levels
Returns: : Returns POC level, upper value area level, lower value area level and alerts if close is above or below the value area.
regressionUtilitiesLibrary "regressionUtilities"
get_linear_regression(bar_index_array, prices_array, stdDev_mult)
: Generates the linear regression channel for an array of values.
Parameters:
bar_index_array (array) : (array): Array with bar indexes
prices_array (array) : (array): Array with prices
stdDev_mult (float) : (float): Standard deviation multiple for the channels
Returns: : Returns x1, x2, y1_mid, y2_mid, y1_up, y2_up, y1_dn, y2_dn, m, b, R2, stdDev
get_optimal_linearRegression_channel(max_length, min_length, source, stdDev_mult)
: Gets the best fitting linear regression using optimum length
Parameters:
max_length (int) : (int): Maximum bar length
min_length (int) : (int): Minimum bar length
source (float) : (float): Source for the regression
stdDev_mult (float) : (float): Array with prices
Returns: : Returns three line objects
get_cuadratic_Regression(x_array, y_array, bars_to_project)
: Gets the best fitting linear regression using optimum length
Parameters:
x_array (array) : (array): Maximum bar length
y_array (array) : (array): Minimum bar length
bars_to_project (int) : (int): Array with prices
Returns: : Returns three line objects
dataTableUtilitiesLibrary "dataTableUtilities"
generate_dataTable(dataTable_map, title, tableYpos, tableXpos)
: Generates and shows a data table.
Parameters:
dataTable_map (map)
title (string) : (string): Title of the table
tableYpos (string) : (string): Vertical position of the table
tableXpos (string) : (string): Horizontal position of the table
Returns: : None
formattingUtilitiesLibrary "formattingUtilities"
toPercentageString(x, decimals)
: Converts a decimal number into a string formatted as percentage.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as percentage.
toFactorString(x, decimals)
: Converts a decimal number into a string formatted as Factor.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a Factor.
toCurrencyString(x, decimals)
: Converts a decimal number into a string formatted as currency.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as currency.
toNumberString(x, decimals)
: Converts a decimal number into a string formatted as decimal.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a decimal.
colorByAboveBelow(x, reference, above, below, equal)
: Returns a different color if the reference is above, below or equal to x.
Parameters:
x (float) : (simple float): The number that will be tested, above, below or equal.
reference (float) : (simple float): The reference for for determining if x is above, below or equal.
above (color)
below (color)
equal (color)
Returns: : The color returned if above, below or equal.
utilitiesLibrary "utilities"
toPercentageString(x, decimals)
: Converts a decimal number into a string formatted as percentage.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as percentage.
toFactorString(x, decimals)
: Converts a decimal number into a string formatted as Factor.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a Factor.
toCurrencyString(x, decimals)
: Converts a decimal number into a string formatted as currency.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as currency.
toNumberString(x, decimals)
: Converts a decimal number into a string formatted as decimal.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a decimal.
bollingerBandsLibrary "bollingerBands"
Bollinger bands related functions
get_multiple_bollinger_bands(stdv1, stdv2, stdv3, stdv4, stdv5, stdv6, stdv7, length, source)
Parameters:
stdv1 (int)
stdv2 (int)
stdv3 (int)
stdv4 (int)
stdv5 (int)
stdv6 (int)
stdv7 (int)
length (simple int)
source (float)
get_bb_volatility(bb_highest, bb_lowest, ma_length, lookback)
Parameters:
bb_highest (float)
bb_lowest (float)
ma_length (simple int)
lookback (int)
pseudorenko█ CALCULATE PSEUDO-RENKO VALUE
Calculates and returns the Pseudo-Renko Stabilized value (or close price) based on a given input value, along with the direction of the current Renko brick. This function adapts the traditional Renko brick size dynamically based on the volatility of the input value using a combination of SMA and EMA calculations. The calculated price represents the closing price of the most recent Pseudo-Renko brick, while the direction indicates the trend ( 1 for uptrend, -1 for downtrend).
Parameters:
* `val` :
* Type: ` float `
* Description: The input value upon which the Pseudo-Renko calculations are performed. You can use any price series or custom value as input.
* `sensitivity` :
* Type: ` float `
* Default Value: ` 1.0 `
* Description: Controls the sensitivity of the brick size to the volatility of the `val`. Higher values lead to larger bricks, resulting in a smoother Renko chart. Lower values produce smaller bricks, leading to a more reactive chart.
* Possible Values: Any positive float.
* `length` :
* Type: ` int `
* Default Value: ` 7 `
* Description: The length used for calculating the EMA and SMA in the dynamic brick size calculation. It influences how quickly the brick size adapts to changing volatility of the `val`.
* Possible Values: Any positive integer.
Return Values:
* `lastRenkoClose` :
* Type: ` float `
* Description: The closing price of the last completed Pseudo-Renko brick based on the `val`.
* `renkoDirection` :
* Type: ` int `
* Description: The direction of the current Pseudo-Renko brick based on the `val`:
* ` 1 `: Uptrend
* ` -1 `: Downtrend
* ` 0 `: No change (initially, or no brick change since the previous bar)
Example Usage:
//@version=5
indicator("Pseudo-Renko Stabilized (Val)", overlay=true)
// Get user inputs
sensitivityInput = input.float(0.1, "Sensitivity",0.01,step=0.01)
lengthInput = input.int(5, "Length",2)
// Example usage with the 'close' price as the input value
= pseudo_renko(math.avg(close,open), sensitivityInput, lengthInput)
// Plot the Renko close price
plot(renkoClose, "Renko Close", renkoDirection>0?color.aqua:color.orange,2)
// You can also use other values as input, such as:
// = pseudo_renko(high, sensitivityInput, lengthInput)
// = pseudo_renko(low, sensitivityInput, lengthInput)
This example demonstrates how to use the `pseudo_renko` function within an indicator. It takes user inputs for `sensitivity` and `length`, then calculates the Pseudo-Renko values using the average of the `close` and `open` prices as the `val`. The resulting `renkoClose` price is plotted on the chart, with a color change based on the `renkoDirection`. It also illustrates how you can use other values, like `high` and `low`, as input to the function.
Note: The Pseudo-Renko algorithm is based on adapting the Renko brick size dynamically based on the input `val`. This provides more flexibility compared to the normal, but is experimental. The `sensitivity` and `length` parameters, along with the choice of the `val`, offer further customization to tune the algorithm's behavior to your preference and trading style.
JordanSwindenLibraryLibrary "JordanSwindenLibrary"
TODO: add library description here
getDecimals()
Calculates how many decimals are on the quote price of the current market
Returns: The current decimal places on the market quote price
getPipSize(multiplier)
Calculates the pip size of the current market
Parameters:
multiplier (int) : The mintick point multiplier (1 by default, 10 for FX/Crypto/CFD but can be used to override when certain markets require)
Returns: The pip size for the current market
truncate(number, decimalPlaces)
Truncates (cuts) excess decimal places
Parameters:
number (float) : The number to truncate
decimalPlaces (simple float) : (default=2) The number of decimal places to truncate to
Returns: The given number truncated to the given decimalPlaces
toWhole(number)
Converts pips into whole numbers
Parameters:
number (float) : The pip number to convert into a whole number
Returns: The converted number
toPips(number)
Converts whole numbers back into pips
Parameters:
number (float) : The whole number to convert into pips
Returns: The converted number
getPctChange(value1, value2, lookback)
Gets the percentage change between 2 float values over a given lookback period
Parameters:
value1 (float) : The first value to reference
value2 (float) : The second value to reference
lookback (int) : The lookback period to analyze
Returns: The percent change over the two values and lookback period
random(minRange, maxRange)
Wichmann–Hill Pseudo-Random Number Generator
Parameters:
minRange (float) : The smallest possible number (default: 0)
maxRange (float) : The largest possible number (default: 1)
Returns: A random number between minRange and maxRange
bullFib(priceLow, priceHigh, fibRatio)
Calculates a bullish fibonacci value
Parameters:
priceLow (float) : The lowest price point
priceHigh (float) : The highest price point
fibRatio (float) : The fibonacci % ratio to calculate
Returns: The fibonacci value of the given ratio between the two price points
bearFib(priceLow, priceHigh, fibRatio)
Calculates a bearish fibonacci value
Parameters:
priceLow (float) : The lowest price point
priceHigh (float) : The highest price point
fibRatio (float) : The fibonacci % ratio to calculate
Returns: The fibonacci value of the given ratio between the two price points
getMA(length, maType)
Gets a Moving Average based on type (! MUST BE CALLED ON EVERY TICK TO BE ACCURATE, don't place in scopes)
Parameters:
length (simple int) : The MA period
maType (string) : The type of MA
Returns: A moving average with the given parameters
barsAboveMA(lookback, ma)
Counts how many candles are above the MA
Parameters:
lookback (int) : The lookback period to look back over
ma (float) : The moving average to check
Returns: The bar count of how many recent bars are above the MA
barsBelowMA(lookback, ma)
Counts how many candles are below the MA
Parameters:
lookback (int) : The lookback period to look back over
ma (float) : The moving average to reference
Returns: The bar count of how many recent bars are below the EMA
barsCrossedMA(lookback, ma)
Counts how many times the EMA was crossed recently (based on closing prices)
Parameters:
lookback (int) : The lookback period to look back over
ma (float) : The moving average to reference
Returns: The bar count of how many times price recently crossed the EMA (based on closing prices)
getPullbackBarCount(lookback, direction)
Counts how many green & red bars have printed recently (ie. pullback count)
Parameters:
lookback (int) : The lookback period to look back over
direction (int) : The color of the bar to count (1 = Green, -1 = Red)
Returns: The bar count of how many candles have retraced over the given lookback & direction
getBodySize()
Gets the current candle's body size (in POINTS, divide by 10 to get pips)
Returns: The current candle's body size in POINTS
getTopWickSize()
Gets the current candle's top wick size (in POINTS, divide by 10 to get pips)
Returns: The current candle's top wick size in POINTS
getBottomWickSize()
Gets the current candle's bottom wick size (in POINTS, divide by 10 to get pips)
Returns: The current candle's bottom wick size in POINTS
getBodyPercent()
Gets the current candle's body size as a percentage of its entire size including its wicks
Returns: The current candle's body size percentage
isHammer(fib, colorMatch)
Checks if the current bar is a hammer candle based on the given parameters
Parameters:
fib (float) : (default=0.382) The fib to base candle body on
colorMatch (bool) : (default=false) Does the candle need to be green? (true/false)
Returns: A boolean - true if the current bar matches the requirements of a hammer candle
isStar(fib, colorMatch)
Checks if the current bar is a shooting star candle based on the given parameters
Parameters:
fib (float) : (default=0.382) The fib to base candle body on
colorMatch (bool) : (default=false) Does the candle need to be red? (true/false)
Returns: A boolean - true if the current bar matches the requirements of a shooting star candle
isDoji(wickSize, bodySize)
Checks if the current bar is a doji candle based on the given parameters
Parameters:
wickSize (float) : (default=2) The maximum top wick size compared to the bottom (and vice versa)
bodySize (float) : (default=0.05) The maximum body size as a percentage compared to the entire candle size
Returns: A boolean - true if the current bar matches the requirements of a doji candle
isBullishEC(allowance, rejectionWickSize, engulfWick)
Checks if the current bar is a bullish engulfing candle
Parameters:
allowance (float) : (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
rejectionWickSize (float) : (default=disabled) The maximum rejection wick size compared to the body as a percentage
engulfWick (bool) : (default=false) Does the engulfing candle require the wick to be engulfed as well?
Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle
isBearishEC(allowance, rejectionWickSize, engulfWick)
Checks if the current bar is a bearish engulfing candle
Parameters:
allowance (float) : (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
rejectionWickSize (float) : (default=disabled) The maximum rejection wick size compared to the body as a percentage
engulfWick (bool) : (default=false) Does the engulfing candle require the wick to be engulfed as well?
Returns: A boolean - true if the current bar matches the requirements of a bearish engulfing candle
isInsideBar()
Detects inside bars
Returns: Returns true if the current bar is an inside bar
isOutsideBar()
Detects outside bars
Returns: Returns true if the current bar is an outside bar
barInSession(sess, useFilter)
Determines if the current price bar falls inside the specified session
Parameters:
sess (simple string) : The session to check
useFilter (bool) : (default=true) Whether or not to actually use this filter
Returns: A boolean - true if the current bar falls within the given time session
barOutSession(sess, useFilter)
Determines if the current price bar falls outside the specified session
Parameters:
sess (simple string) : The session to check
useFilter (bool) : (default=true) Whether or not to actually use this filter
Returns: A boolean - true if the current bar falls outside the given time session
dateFilter(startTime, endTime)
Determines if this bar's time falls within date filter range
Parameters:
startTime (int) : The UNIX date timestamp to begin searching from
endTime (int) : the UNIX date timestamp to stop searching from
Returns: A boolean - true if the current bar falls within the given dates
dayFilter(monday, tuesday, wednesday, thursday, friday, saturday, sunday)
Checks if the current bar's day is in the list of given days to analyze
Parameters:
monday (bool) : Should the script analyze this day? (true/false)
tuesday (bool) : Should the script analyze this day? (true/false)
wednesday (bool) : Should the script analyze this day? (true/false)
thursday (bool) : Should the script analyze this day? (true/false)
friday (bool) : Should the script analyze this day? (true/false)
saturday (bool) : Should the script analyze this day? (true/false)
sunday (bool) : Should the script analyze this day? (true/false)
Returns: A boolean - true if the current bar's day is one of the given days
atrFilter(atrValue, maxSize)
Parameters:
atrValue (float)
maxSize (float)
tradeCount()
Calculate total trade count
Returns: Total closed trade count
isLong()
Check if we're currently in a long trade
Returns: True if our position size is positive
isShort()
Check if we're currently in a short trade
Returns: True if our position size is negative
isFlat()
Check if we're currentlyflat
Returns: True if our position size is zero
wonTrade()
Check if this bar falls after a winning trade
Returns: True if we just won a trade
lostTrade()
Check if this bar falls after a losing trade
Returns: True if we just lost a trade
maxDrawdownRealized()
Gets the max drawdown based on closed trades (ie. realized P&L). The strategy tester displays max drawdown as open P&L (unrealized).
Returns: The max drawdown based on closed trades (ie. realized P&L). The strategy tester displays max drawdown as open P&L (unrealized).
totalPipReturn()
Gets the total amount of pips won/lost (as a whole number)
Returns: Total amount of pips won/lost (as a whole number)
longWinCount()
Count how many winning long trades we've had
Returns: Long win count
shortWinCount()
Count how many winning short trades we've had
Returns: Short win count
longLossCount()
Count how many losing long trades we've had
Returns: Long loss count
shortLossCount()
Count how many losing short trades we've had
Returns: Short loss count
breakEvenCount(allowanceTicks)
Count how many break-even trades we've had
Parameters:
allowanceTicks (float) : Optional - how many ticks to allow between entry & exit price (default 0)
Returns: Break-even count
longCount()
Count how many long trades we've taken
Returns: Long trade count
shortCount()
Count how many short trades we've taken
Returns: Short trade count
longWinPercent()
Calculate win rate of long trades
Returns: Long win rate (0-100)
shortWinPercent()
Calculate win rate of short trades
Returns: Short win rate (0-100)
breakEvenPercent(allowanceTicks)
Calculate break even rate of all trades
Parameters:
allowanceTicks (float) : Optional - how many ticks to allow between entry & exit price (default 0)
Returns: Break-even win rate (0-100)
averageRR()
Calculate average risk:reward
Returns: Average winning trade divided by average losing trade
unitsToLots(units)
(Forex) Convert the given unit count to lots (multiples of 100,000)
Parameters:
units (float) : The units to convert into lots
Returns: Units converted to nearest lot size (as float)
getFxPositionSize(balance, risk, stopLossPips, fxRate, lots)
(Forex) Calculate fixed-fractional position size based on given parameters
Parameters:
balance (float) : The account balance
risk (float) : The % risk (whole number)
stopLossPips (float) : Pip distance to base risk on
fxRate (float) : The conversion currency rate (more info below in library documentation)
lots (bool) : Whether or not to return the position size in lots rather than units (true by default)
Returns: Units/lots to enter into "qty=" parameter of strategy entry function
EXAMPLE USAGE:
string conversionCurrencyPair = (strategy.account_currency == syminfo.currency ? syminfo.tickerid : strategy.account_currency + syminfo.currency)
float fx_rate = request.security(conversionCurrencyPair, timeframe.period, close )
if (longCondition)
strategy.entry("Long", strategy.long, qty=zen.getFxPositionSize(strategy.equity, 1, stopLossPipsWholeNumber, fx_rate, true))
skipTradeMonteCarlo(chance, debug)
Checks to see if trade should be skipped to emulate rudimentary Monte Carlo simulation
Parameters:
chance (float) : The chance to skip a trade (0-1 or 0-100, function will normalize to 0-1)
debug (bool) : Whether or not to display a label informing of the trade skip
Returns: True if the trade is skipped, false if it's not skipped (idea being to include this function in entry condition validation checks)
fillCell(tableID, column, row, title, value, bgcolor, txtcolor, tooltip)
This updates the given table's cell with the given values
Parameters:
tableID (table) : The table ID to update
column (int) : The column to update
row (int) : The row to update
title (string) : The title of this cell
value (string) : The value of this cell
bgcolor (color) : The background color of this cell
txtcolor (color) : The text color of this cell
tooltip (string)
Returns: Nothing.
[ALGOA+] Markov Chains Library by @metacamaleoLibrary "MarkovChains"
Markov Chains library by @metacamaleo. Created in 09/08/2024.
This library provides tools to calculate and visualize Markov Chain-based transition matrices and probabilities. This library supports two primary algorithms: a rolling window Markov Chain and a conditional Markov Chain (which operates based on specified conditions). The key concepts used include Markov Chain states, transition matrices, and future state probabilities based on past market conditions or indicators.
Key functions:
- `mc_rw()`: Builds a transition matrix using a rolling window Markov Chain, calculating probabilities based on a fixed length of historical data.
- `mc_cond()`: Builds a conditional Markov Chain transition matrix, calculating probabilities based on the current market condition or indicator state.
Basically, you will just need to use the above functions on your script to default outputs and displays.
Exported UDTs include:
- s_map: An UDT variable used to store a map with dummy states, i.e., if possible states are bullish, bearish, and neutral, and current is bullish, it will be stored
in a map with following keys and values: "bullish", 1; "bearish", 0; and "neutral", 0. You will only use it to customize your own script, otherwise, it´s only for internal use.
- mc_states: This UDT variable stores user inputs, calculations and MC outputs. As the above, you don´t need to use it, but you may get features to customize your own script.
For example, you may use mc.tm to get the transition matrix, or the prob map to customize the display. As you see, functions are all based on mc_states UDT. The s_map UDT is used within mc_states´s s array.
Optional exported functions include:
- `mc_table()`: Displays the transition matrix in a table format on the chart for easy visualization of the probabilities.
- `display_list()`: Displays a map (or array) of string and float/int values in a table format, used for showing transition counts or probabilities.
- `mc_prob()`: Calculates and displays probabilities for a given number of future bars based on the current state in the Markov Chain.
- `mc_all_states_prob()`: Calculates probabilities for all states for future bars, considering all possible transitions.
The above functions may be used to customize your outputs. Use the returned variable mc_states from mc_rw() and mc_cond() to display each of its matrix, maps or arrays using mc_table() (for matrices) and display_list() (for maps and arrays) if you desire to debug or track the calculation process.
See the examples in the end of this script.
Have good trading days!
Best regards,
@metacamaleo
-----------------------------
KEY FUNCTIONS
mc_rw(state, length, states, pred_length, show_table, show_prob, table_position, prob_position, font_size)
Builds the transition matrix for a rolling window Markov Chain.
Parameters:
state (string) : The current state of the market or system.
length (int) : The rolling window size.
states (array) : Array of strings representing the possible states in the Markov Chain.
pred_length (int) : The number of bars to predict into the future.
show_table (bool) : Boolean to show or hide the transition matrix table.
show_prob (bool) : Boolean to show or hide the probability table.
table_position (string) : Position of the transition matrix table on the chart.
prob_position (string) : Position of the probability list on the chart.
font_size (string) : Size of the table font.
Returns: The transition matrix and probabilities for future states.
mc_cond(state, condition, states, pred_length, show_table, show_prob, table_position, prob_position, font_size)
Builds the transition matrix for conditional Markov Chains.
Parameters:
state (string) : The current state of the market or system.
condition (string) : A string representing the condition.
states (array) : Array of strings representing the possible states in the Markov Chain.
pred_length (int) : The number of bars to predict into the future.
show_table (bool) : Boolean to show or hide the transition matrix table.
show_prob (bool) : Boolean to show or hide the probability table.
table_position (string) : Position of the transition matrix table on the chart.
prob_position (string) : Position of the probability list on the chart.
font_size (string) : Size of the table font.
Returns: The transition matrix and probabilities for future states based on the HMM.
Candlestick_patternsLibrary "CandlestickepatternsClase3"
TODO: add library description here
bullish_engulfing()
bearish_engulfing()
LinTrendLibLibrary "LinTrendLib"
TODO: add library description here
ema_trend(twz, ema_length, cross_ratio, multiplier)
Given Bullish / Bearish / side-way market jugement
Parameters:
twz (int)
ema_length (simple int)
cross_ratio (float)
multiplier (float)
Returns: 1 --> bullish trend, -1 --> bearish trend, 0 --> sideway market
Color Library // AlgoFyreAlgoFyre's Color Library is a Pine Script v5 library offering fire-themed palettes with light and dark modes. It helps traders easily integrate consistent, visually appealing color schemes into TradingView indicators. Used in AlgoFyre's Scripts and Indicators.
Color Overview
The AlgoFyreColorLibrary includes a comprehensive set of colors inspired by fire, ranging from light reds and oranges to dark browns and deep reds. The library is divided into two main themes:
Light Theme:
Includes lighter shades of red, orange, and brown, suitable for use on light backgrounds.
Dark Theme:
Includes darker shades of red, orange, and brown, suitable for use on dark backgrounds.
How to Use
To use the AlgoFyreColorLibrary in your Pine Script indicators and strategies, follow these steps:
Import the Library:
Import the AlgoFyreColorLibrary at the beginning of your script.
Call the getColor Function:
Use the getColor function to retrieve the desired color with the specified transparency.
Example
//@version=5
import "AF-L-0001" as af
// Example usage of getColor function
color primaryColor = af.getColor("af_primary1", 50)
color signalColor = af.getColor("af_green", 80)
// Plotting example
plot(close, color=primaryColor, linewidth=2, title="Primary Color Line")
plot(close, color=signalColor, linewidth=2, title="Signal Color Line")
The library AF-L-0001 is imported with the alias af.
The getColor function is used to get colors with specified transparency.
The colors are then used to plot lines on the chart.
StyleLibraryLibrary "StyleLibrary"
A small library of Pine Script functions that return built-in style variables.
method sizeStyle(size)
Takes a `string` that returns the corresponding built-in size style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
size (string) : A `string` representing a built-in size style: `"Tiny"`, `"Small"`, `"Normal"`, `"Large"`,
`"Huge"`, `"Auto"`.
Returns: The respective built-in size style variable.
method sizeStyle(size)
Takes a `sizeStyle` that returns the corresponding built-in size style variable.
Namespace types: series sizeStyle
Parameters:
size (series sizeStyle) : A `sizeStyle` representing a built-in size style variable.
Returns: The respective built-in size style variable.
method lineStyle(style)
Takes a `string` that returns the corresponding built-in line style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
style (string) : A `string` representing a built-in line style: `"Dashed"`, `"Dotted"`, `"Solid"`.
Returns: The respective built-in line style variable.
method lineStyle(style)
Takes a `lineStyle` that returns the corresponding built-in line style variable.
Namespace types: series lineStyle
Parameters:
style (series lineStyle) : A `lineStyle` representing a built-in line style variable.
Returns: The respective built-in line style variable.
method labelStyle(style)
Takes a `string` that returns the corresponding built-in label style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
style (string) : A `string` representing a built-in label style:
`"Arrow Down"`, `"Arrow Up"`, `"Circle"`, `"Cross"`, `"Diamond"`, `"Flag"`,
`"Label Center"`, `"Label Down"`, `"Label Left"`, `"Label Lower Left"`,
`"Label Lower Right"`, `"Label Right"`, `"Label Up"`, `"Label Upper Left"`,
`"Label Upper Right"`, `"None"`, `"Square"`, `"Text Outline"`, `"Triangle Down"`,
`"Triangle Up"`, `"XCross"`.
Returns: The respective built-in label style variable.
method labelStyle(style)
Takes a `labelStyle` that returns the corresponding built-in label style variable.
Namespace types: series labelStyle
Parameters:
style (series labelStyle) : A `labelStyle` representing a built-in label style variable.
Returns: The respective built-in label style variable.
method fontStyle(font)
Takes a `string` that returns the corresponding built-in font style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
font (string) : A `string` representing a built-in font style: `"Default"`, `"Monospace"`.
Returns: The respective built-in font style variable.
method positionStyle(position)
Takes a `string` that returns the corresponding built-in position style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
position (string) : A `string` representing a built-in position style:
`"Bottom Center", `"Bottom Left", `"Bottom Right", `"Middle Center", `"Middle Left",
`"Middle Right", `"Top Center", `"Top Left", `"Top Right".
Returns: The respective built-in position style variable.
method displayStyle(display)
Takes a `simple string` that returns the corresponding built-in display style variable.
Namespace types: simple string, input string, const string
Parameters:
display (simple string) : A `simple string` representing a built-in display style: `"All"`, `"Data Window"`,
`"None"`, `"Pane"`, `"Price Scale"`, `"Status Line"`.
Returns: The respective built-in display style variable.