TimeFormattingLibraryLibrary "TimeFormattingLibrary"
Time formatting functions: formating functions to make timestrings more human readable friendly (for both fixed time and time-elapsed).
Also functions for last and first instance in month of day of week input.
Also a function for identifying bank holiday Mondays.
timeFormatFxn(showDayOfWeek, showDayOfMonth, showMonth, showYear, showHrMin, _time, _timezone)
converts time into readable format
Parameters:
showDayOfWeek (bool) : if you want to show day of week (i.e. Mon, Tues etc)
showDayOfMonth (bool) : if you want to show day number of month with superscript ordinals (i.e. 1ˢᵗ, 2ⁿᵈ, etc)
showMonth (bool) : if you want to show the month (i.e. Jan, Feb, etc)
showYear (bool) : if you want to show the year (i.e. 2023)
showHrMin (bool) : if you want to show time in 24hr clock format
_time (int) : is the unix time (i.e. time or time_close)
_timezone (string) : the user timezone input as string (e.g. "America/New_York", "UTC-5", "GMT+0530")
Returns: time date string
timeElapsedFxn(timespan)
converts timespan into readable format
Parameters:
timespan (int) : is the length of time in milliseconds to be converted into a human readable string
Returns: timespan string (whether it be a for showing 'time-elapsed' or for showing a 'countdown timer')
isFirstXdayofmonth(_dayofweek)
gives bool result for when first occurence in month of the day-of-week input
Parameters:
_dayofweek (int) : (can be integer 1-7 or can be dayofweek variable; i.e. dayofweek.wednesday)
isLastXdayofmonth(_dayofweek)
gives bool result for when last occurence in month of the day-of-week input
Parameters:
_dayofweek (int) : (can be integer 1-7 or can be dayofweek variable; i.e. dayofweek.wednesday)
wasBankHolidayMonday()
gives bool result for if yesterday was a bank holiday monday. Only for use with with request.security() function, see example code below
Strings
ETFFinderLibLibrary "ETFFinderLib"
TODO: add library description here
etf_search_ticker(ticker)
searches the entire ETF library by ticker and identifies which ETFs hold a specific tickers.
Parameters:
ticker (string)
Returns: returns 2 arrays, holding_array (string array) and compo_array(float array)
etf_search_sectors(sector)
searches the entire ETF library by sector and pulls by desired sector
Parameters:
sector (string)
Returns: returns 2 arrays, sector_array (string array) and composition array (float array)
Stringify - Timeframe Enumeration --> StringLibrary "Stringify"
Cast variable types and enumerations to human-readable Strings
timeframe(string)
Cast a timeframe enumeration to readable string.
Parameters:
string : `T` is a timeframe enumeration ('3D', '120', '15', '5s' ...)
Returns: A string representation of the timeframe or 'NA' if `x` is `na`
ETFHoldingsLibLibrary "ETFHoldingsLib"
spy_get()
: pulls SPY ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
qqq_get()
: pulls QQQ ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
arkk_get()
: pulls ARKK ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xle_get()
: pulls XLE ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
brk_get()
: pulls BRK ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
ita_get()
: pulls ITA ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
iwm_get()
: pulls IWM ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xlf_get()
: pulls XLF ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xlv_get()
: pulls XLV ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vnq_get()
: pulls VNQ ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xbi_get()
: pulls XBI ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
blcr_get()
: pulls BLCR ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vgt_get()
: pulls VGT ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vwo_get()
: pulls VWO ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vig_get()
: pulls VIG ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vug_get()
: pulls VUG ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vtv_get()
: pulls VTV ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vea_get()
: pulls VEA ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
RiskToolsLibrary "RiskTools"
Provides functions for calculating risk metrics
pctDrop(start, result)
Calculates what is the percentage drop from a reference price
Parameters:
start (float) : Starting price before the drop occurred
result (float) : Resulting price to which the percentage drop occurred
Returns: Percentage drop from "start" to "result"
priceBeforeDrop(pctDrop, result)
Calculates a starting price given a resulting price and a percentage drop to that price
Parameters:
pctDrop (float) : Percentage drop
result (float) : Resulting price to which the percentage drop occurred
Returns: The starting price from which a percentage drop "pctDrop" gave a "result"
dropzone(price, masource, malength, window, zonesize)
Calculates drop zone as an integer representing some multiple of the "zoning size"
Parameters:
price (float) : The current price from which you want to calculate the drop zone
masource (float) : The source series used in the SMA calculation from which the floor price is determined
malength (simple int) : The length used in the SMA calculation from which the floor price is determined
window (simple int) : The lookback period from which to calculate the floor price
zonesize (simple int)
Returns: The zone identifier as a multiple of the zone size. A value of zero or less is translated to the first zone.
Spot Symbols for CryptoLibrary "CryptoSpotSymbols"
This Library has one purpose only. It generate Symbols for the Crypto Spot Market, like all the currencies pairs of most Crypto Exchanges available to TradingView.
Have a look at .find() , which is an all in one function.
Binance(basecurrency)
Generate 27 Symbols for the Spot Market of Binance.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BinanceUS(basecurrency)
Generate seven Symbols for the Spot Market of BinanceUS.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bitfinex(basecurrency)
Generate 12 Symbols for the Spot Market of Bitfinex.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitFlyer(basecurrency)
Generate three Symbols for the Spot Market of bitFlyer.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bitget(basecurrency)
Generate seven Symbols for the Spot Market of Bitget.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bithumb(basecurrency)
Generate two Symbols for the Spot Market of Bithumb.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitkub(basecurrency)
Generate one Symbol for the Spot Market of bitkub.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: THB
BitMEX(basecurrency)
Generate two Symbols for the Spot Market of BitMEX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitpanda_pro(basecurrency)
Generate six Symbols for the Spot Market of bitpanda pro.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitrue(basecurrency)
Generate nine Symbols for the Spot Market of bitrue.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bitstamp(basecurrency)
Generate eight Symbols for the Spot Market of Bitstamp.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BITTREX(basecurrency)
Generate six Symbols for the Spot Market of BITTREX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BTSE(basecurrency)
Generate 15 Symbols for the Spot Market of BTSE.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BYBIT(basecurrency)
Generate five Symbols for the Spot Market of BYBIT.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
CapitalCom(basecurrency)
Generate five Symbols for the Spot Market of capital.com.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
coinbase(basecurrency)
Generate seven Symbols for the Spot Market of coinbase.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
CoinEx(basecurrency)
Generate three Symbols for the Spot Market of CoinEx.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
CurrencyCom(basecurrency)
Generate 30 Symbols for the Spot Market of currency.com.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Delta(basecurrency)
Generate one Symbol for the Spot Market of Delta.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USDT
Deribit(basecurrency)
Generate two Symbols for the Spot Market of Deribit.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
easyMarkets(basecurrency)
Generate one Symbol for the Spot Market of easyMarkets.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
Eightcap(basecurrency)
Generate one Symbol for the Spot Market of Eightcap.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
ExMo(basecurrency)
Generate ten Symbols for the Spot Market of ExMo.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
FOREXcom(basecurrency)
Generate four Symbols for the Spot Market of FOREX.com.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
FXCM(basecurrency)
Generate three Symbols for the Spot Market of FXCM.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
GateIO(basecurrency)
Generate five Symbols for the Spot Market of Gate.io.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Gemini(basecurrency)
Generate ten Symbols for the Spot Market of Gemini.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Kraken(basecurrency)
Generate 14 Symbols for the Spot Market of Kraken.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
KuCoin(basecurrency)
Generate 13 Symbols for the Spot Market of KuCoin.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
MEXC(basecurrency)
Generate six Symbols for the Spot Market of MEXC.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
OANDA(basecurrency)
Generate one Symbol for the Spot Market of OANDA.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
OKX(basecurrency)
Generate six Symbols for the Spot Market of OKX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Pepperstone(basecurrency)
Generate one Symbol for the Spot Market of Pepperstone.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
phemex(basecurrency)
Generate four Symbols for the Spot Market of phemex.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
POLONIEX(basecurrency)
Generate nine Symbols for the Spot Market of POLONIEX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Pyth(basecurrency)
Generate three Symbols for the Spot Market of Pyth.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Skilling(basecurrency)
Generate four Symbols for the Spot Market of Skilling.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
TimeX(basecurrency)
Generate six Symbols for the Spot Market of TimeX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
TradeStation(basecurrency)
Generate four Symbols for the Spot Market of TradeStation.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
UpBit(basecurrency)
Generate four Symbols for the Spot Market of UpBit.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
whitebit(basecurrency)
Generate 13 Symbols for the Spot Market of whitebit.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
WOOX(basecurrency)
Generate two Symbols for the Spot Market of WOO.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
find(exchange, basecurrency)
Generate up to 30 Symbols for the Spot Market, depending on the market picked.
Parameters:
exchange (simple string) : The name of an Exchange. Case insensitivity. Optional. Default value is `syminfo.prefix`. If something else is put in here it will return `na` values.
basecurrency (simple string) : The Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`
Returns: 30x string as tuple
TooltipLibrary "Tooltip"
This library helps creating and managing nice looking data (key/value) tooltips that you can use for
labels. The tooltips data key/value will align automatically. It is optional to convert the data to a values only string too.
method addSpacesToKey(this)
Calculates the amount of spaces needed after the key to make it the key least 4 characters wide.
Namespace types: Data
Parameters:
this (Data) : (Data) The Data.
method addTabs(this, longestKeyLength)
Calculates the amount of tabs to be used.
Namespace types: Data
Parameters:
this (Data) : (Data) The Data.
longestKeyLength (int)
method longestKeyLength(this)
Returns the length of the longest key string in the array.
Namespace types: Data
Parameters:
this (Data ) : (Tooltip) The object to work with.
@return (int) The length of the key.
method toString(tooltips, withKey)
Helper function for the tooltip.
Namespace types: Data
Parameters:
tooltips (Data )
withKey (bool) : (bool) Wether to create a string with keys in it.
@return (string) The string
new()
Creates a new array to store tooltip data in
@return (Data) The data array.
Data
Key/Value pair for tooltips
Fields:
key (series string)
value (series string)
Mizar_LibraryThe "Mizar_Library" is a powerful tool designed for Pine Script™ programmer’s, providing a collection of general functions that facilitate the usage of Mizar’s DCA (Dollar-Cost-Averaging) bot system.
To begin using the Mizar Library, you first need to import it into your indicator script. Insert the following line below your indicator initiation line: import Mizar_Trading/Mizar_Library/1 as mizar (mizar is the chosen alias).
In the import statement, Mizar_Trading.Mizar_Library_v1 refers to the specific version of the Mizar Library you wish to use. Feel free to modify mizar to your preferred alias name.
Once the library is imported, you can leverage its functions by prefixing them with mizar. . This will prompt auto-completion suggestions displaying all the available user-defined functions provided by the Mizar Library.
Now, let's delve into some of the key functions available in the Mizar Library:
DCA_bot_msg(_cmd)
The DCA_bot_msg function accepts an user-defined type (UDT) _cmd as a parameter and returns a string with the complete JSON command for a Mizar DCA bot.
Parameters:
_cmd (bot_params) : ::: User-defined type (UDT) that holds all the necessary information for the bot command.
Returns: A string with the complete JSON command for a Mizar DCA bot.
rounding_to_ticks(value, ticks, rounding_type)
The rounding_to_ticks function rounds a calculated price to the nearest actual price based on the specified tick size.
Parameters:
value (float) : ::: The calculated price as float type, to be rounded to the nearest real price.
ticks (float) : ::: The smallest possible price obtained through a request in your script.
rounding_type (int) : ::: The rounding type for the price: 0 = closest real price, 1 = closest real price above, 2 = closest real price below.
Returns: A float value representing the rounded price to the next tick.
bot_params
Bot_params is an user-defined type (UDT) that represents the parameters required for a Mizar DCA bot.
Fields:
bot_id (series string) : The ID number of your Mizar DCA bot.
api_key (series string) : Your private API key from your Mizar account (keep it confidential!).
action (series string) : The command to perform: "open" (standard) or "close" optional .
tp_perc (series string) : The take profit percentage in decimal form (1% = "0.01") optional .
base_asset (series string) : The cryptocurrency you want to buy (e.g., "BTC").
quote_asset (series string) : The coin or fiat currency used for payment (e.g., "USDT" is standard if not specified) optional .
direction (series string) : The direction of the position: "long" or "short" (only applicable for two-way hedge bots) optional .
To obtain the JSON command string for the alert_function call, you can use the DCA_bot_msg function provided by the library. Simply pass the cmd_msg UDT as an argument and assign the returned string value to a variable.
Here's an example to illustrate the process:
// Import of the Mizar Library to use the included functions
import/Mizar_Trading/Mizar_Library/1 as mizar
// Example to set a variable called “cmd_msg” and all of its parameters
cmd_msg = mizar.bot_params. new()
cmd_msg.action := "open"
cmd_msg.api_key := "top secret"
cmd_msg.bot_id := "9999"
cmd_msg.base_asset := "BTC"
cmd_msg.quote_asset := "USDT"
cmd_msg.direction := "long"
cmd_msg.tp_perc := "0.015"
// Calling the Mizar conversion function named “DCA_bot_msg()” with the cmd_msg as argument to receive the JSON command and save it in a string variable called “alert_msg”
alert_msg = mizar.DCA_bot_msg(cmd_msg)
Feel free to utilize (series) string variables instead of constant strings. By incorporating the Mizar Library into your Pine Script, you gain access to a powerful set of functions and can leverage them according to your specific requirements.
For additional help or support, you can join the Mizar Discord channel. There, you'll find a dedicated Pine Script channel where you can ask any questions related to Pine Script.
.print()
You don't need to initialize anything..
After you import the library you can use .print() as easy as that..!
Hope this helps
* use a unique ID for each .print() call
let me know if you run into any bugs
by trying to make it as user friendly as possible i had to do
some not ideal things so there's a chance it could present some bugs with
a lot of labels present on the chart
and if you use label.all to parse and manipulate the labels on the chart..
most likely it will cause an issue but not a lot of people use this so
I don't think that will be a problem.
thanks,
FFriZz | frizlabz
Library "print"
Single function to print any type to console
method str(inp)
`method` convert all types to string
```
(overload)
*.str(any inp) => string
```
Namespace types: series string, simple string, input string, const string
Parameters:
inp (string) : `any` - desc | Required
Returns: `string` formatted string
method str(inp)
Namespace types: series int, simple int, input int, const int
Parameters:
inp (int)
method str(inp)
Namespace types: series float, simple float, input float, const float
Parameters:
inp (float)
method str(inp)
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
inp (bool)
method str(inp)
Namespace types: series linefill
Parameters:
inp (linefill)
method str(inp)
Namespace types: series line
Parameters:
inp (line)
method str(inp)
Namespace types: series box
Parameters:
inp (box)
method str(inp)
Namespace types: series label
Parameters:
inp (label)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: linefill
Parameters:
inp (linefill )
method str(inp)
Namespace types: line
Parameters:
inp (line )
method str(inp)
Namespace types: box
Parameters:
inp (box )
method str(inp)
Namespace types: label
Parameters:
inp (label )
method str(inp)
Namespace types: string
Parameters:
inp (string )
method str(inp)
Namespace types: int
Parameters:
inp (int )
method str(inp)
Namespace types: float
Parameters:
inp (float )
method str(inp)
Namespace types: bool
Parameters:
inp (bool )
method arrayShorten(str)
arrayShorten
Namespace types: series string, simple string, input string, const string
Parameters:
str (string) : `string` - the string to shorten | Required
Returns: `string` - a shortened version of the input string if it is an array with more than 7 elements, otherwise the original string
method matrixShorten(str)
matrixShorten
Namespace types: series string, simple string, input string, const string
Parameters:
str (string) : `string` - the string to shorten | Required
Returns: `string` - the shortened matrix string if the input is a matrix, otherwise returns the input string as is
method print(x, ID)
print all types to theh same console with just this `method/function`
```
(overload)
*.print(any x, string ID, bool shorten=true?) => console
"param 'shorten' - only for arrays and matrixs" | true
```
Namespace types: series string, simple string, input string, const string
Parameters:
x (string) : - `any` input to convert
ID (string) : - `string` unique id for label on console `MUST BE UNIQUE`
Returns: adds the `ID` and the `inp` to the console on the chart
method print(x, ID)
Namespace types: series float, simple float, input float, const float
Parameters:
x (float)
ID (string)
method print(x, ID)
Namespace types: series int, simple int, input int, const int
Parameters:
x (int)
ID (string)
method print(x, ID)
Namespace types: series box
Parameters:
x (box)
ID (string)
method print(x, ID)
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
x (bool)
ID (string)
method print(x, ID)
Namespace types: series label
Parameters:
x (label)
ID (string)
method print(x, ID)
Namespace types: series line
Parameters:
x (line)
ID (string)
method print(x, ID)
Namespace types: series linefill
Parameters:
x (linefill)
ID (string)
method print(x, ID, shorten)
Namespace types: string
Parameters:
x (string )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: float
Parameters:
x (float )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: int
Parameters:
x (int )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: box
Parameters:
x (box )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: bool
Parameters:
x (bool )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: label
Parameters:
x (label )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: line
Parameters:
x (line )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: linefill
Parameters:
x (linefill )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
WebhookJsonMsgLibrary "WebhookJsonMsg"
This webhook json message library provides convenient functions for building JSON messages
Used to manage automatic transaction orders and positions
method buildWebhookJson(msg)
Builds the final JSON payload from a WebhookMessage type.
Namespace types: WebhookMessage
Parameters:
msg (WebhookMessage)
Returns: A JSON Payload.
Dict
Define some constant values
Fields:
OPEN_LONG (series string)
OPEN_SHORT (series string)
CLOSE_LONG (series string)
CLOSE_SHORT (series string)
LIMIT (series string)
MARKET (series string)
U_MARGIN (series string)
C_MARGIN (series string)
SPOT (series string)
WebhookMessage
Webhook message structure.
Fields:
strategyId (series string)
signalNo (series string)
symbol (series string)
symbolType (series string)
orderSide (series string)
price (series string)
orderType (series string)
takeProfitPrice (series string)
stopLossPrice (series string)
timestamp (series string)
accessKey (series string)
peterzorve-libraryLibrary "library"
is_bullish_engulfing()
is_bearish_engulfing()
is_hammer(fib_level)
Parameters:
fib_level (float)
is_shooting_star(fib_level)
Parameters:
fib_level (float)
is_hammer_and_star(fib_level)
Parameters:
fib_level (float)
is_star_and_hammer(fib_level)
Parameters:
fib_level (float)
is_dogi(dogi_body_ratio)
Parameters:
dogi_body_ratio (float)
is_bear_bear_bullish_engulf()
is_atr_stoploss_takeprofit(atr_multiplier, atr_length, reward_ratio)
Parameters:
atr_multiplier (float)
atr_length (simple int)
reward_ratio (float)
is_fixed_stoploss_takeprofit(stoploss_pips, reward_ratio)
Parameters:
stoploss_pips (float)
reward_ratio (float)
is_step_trailing_stoploss(stoploss_pips)
Parameters:
stoploss_pips (float)
is_atr_trailing_stoploss(atr_multiplier, break_even_pip)
Parameters:
atr_multiplier (float)
break_even_pip (int)
is_pull_back_strategy(length)
Parameters:
length (simple int)
is_trade_statistics(condition, entrypoint, stoploss, takeprofit)
Parameters:
condition (bool)
entrypoint (float)
stoploss (float)
takeprofit (float)
is_table_of_statistics(win_trades, lost_trades, even_trades, pips_won, pips_lost)
Parameters:
win_trades (int)
lost_trades (int)
even_trades (int)
pips_won (float)
pips_lost (float)
is_pine_info(lotsize, stoploss, takeprofit)
Parameters:
lotsize (float)
stoploss (float)
takeprofit (float)
is_support_and_resistance_strategy(look_back, look_forward)
Parameters:
look_back (int)
look_forward (int)
is_choral_strategy(smoothing_period, constant_d)
Parameters:
smoothing_period (int)
constant_d (float)
is_bollinger_band_strategy(length, dev_entry, dev_stoploss, dev_takeprofit)
Parameters:
length (int)
dev_entry (simple float)
dev_stoploss (simple float)
dev_takeprofit (simple float)
TextLibLibrary "TextLib"
TODO: Library with text / string functions
addText(before, value, separator)
Parameters:
before (string)
value (string)
separator (string)
addText(before, value1, value2, separator)
Parameters:
before (string)
value1 (string)
value2 (string)
separator (string)
MarkovAlgorithmLibrary "MarkovAlgorithm"
Markov algorithm is a string rewriting system that uses grammar-like rules to operate on strings of
symbols. Markov algorithms have been shown to be Turing-complete, which means that they are suitable as a
general model of computation and can represent any mathematical expression from its simple notation.
~ wikipedia
.
reference:
en.wikipedia.org
rosettacode.org
parse(rules, separator)
Parameters:
rules (string)
separator (string)
Returns: - `array _rules`: List of rules.
---
Usage:
- `parse("|0 -> 0|| 1 -> 0| 0 -> ")`
apply(expression, rules)
Aplies rules to a expression.
Parameters:
expression (string) : `string`: Text expression to be formated by the rules.
rules (rule ) : `string`: Rules to apply to expression on a string format to be parsed.
Returns: - `string _result`: Formated expression.
---
Usage:
- `apply("101", parse("|0 -> 0|| 1 -> 0| 0 -> "))`
apply(expression, rules)
Parameters:
expression (string)
rules (string)
Returns: - `string _result`: Formated expression.
---
Usage:
- `apply("101", parse("|0 -> 0|| 1 -> 0| 0 -> "))`
rule
String pair that represents `pattern -> replace`, each rule may be ordinary or terminating.
Fields:
pattern (series string) : Pattern to replace.
replacement (series string) : Replacement patterns.
termination (series bool) : Termination rule.
composite_ticker_cleanerLibrary "composite_ticker_cleaner"
Extract a clean symbol from a composite ticker. E.g., (BINANCE:BTCUSD+KRAKEN:BTCUSD)/2 as input will return BTCUSD or BINANCE:BTCUSD
composite_ticker_cleaner_extract_first(symbol, keepexchange)
Extract the first symbol out of the supplied string (usually ticker.standard(syminfo.tickerid) )
Parameters:
symbol : string input string to search in
keepexchange : bool (optional) Keep exchange in the returned ticker? By default, we only return the symbol without the exchange.
Returns: first occurrence of a symbol
composite_ticker_cleaner_extract_first(keepexchange)
Extract the first symbol out of the current tickerid (as provided by ticker.standard(syminfo.tickerid) )
Parameters:
keepexchange : bool (optional) Keep exchange in the returned ticker? By default, we only return the symbol without the exchange.
Returns: first occurrence of a symbol in the current tickerid
This is inspired by the work I did on this indicator:
I needed a similar functionality in another script, so instead of duplicating code, I thought generalizing the process in a library could be helpful for me and others, and will be easier to maintain and upgrade with new features if I need to.
string_utilsLibrary "string_utils"
Collection of string utilities that can be used to replace sub-strings in a string and string functions
that are not part of the standard library.
This a more simple replacement of my previous string_variables library since it uses types for better
performance due to data locality and methods that give a more intuitive API.
UnispacesLibrary "Unispaces"
Easier than looking up unicode spaces
spaces(sequence, string1, string2)
UNISPACES
Parameters:
sequence : (int) required | 123 = 3 spaces / 3 different sizes (one space per number can find spaces in hover over)
string1 : (str) optional | default = ""
string2 : (str) optional | default = ""
Returns: `string - concatenated string surrounding unispaces`
space(space, string1, string2)
UNISPACE
Parameters:
space : (int) optional | default = 0 | 0-15 (can find spaces in hover over)
string1 : (str) optional | default = ""
string2 : (str) optional | default = ""
Returns: `string - concatenated string surrounding a unispace `
Sub-Super Script and Roman numerals LibraryLibrary "Sub_Super_Script_and_RomanNumerals_Library"
Library to transform numbers into Roman numerals / Super-Sub script / check if value is alpha or number
isnumber(input)
check to see if value is a number
Parameters:
input : (string/float/int) value to check
Returns: (na) if value is NOT a number and input (string/float/int) if value is a number
isalpha(input)
check a string if it is alpha(doesnt contain numbers)
Parameters:
input
Returns: (string) if string input does NOT contain numbers, return (na) if input string contains numbers
super(num)
convert a string's numbers from normal print to super-script
Parameters:
num : (string/int/float) input value to transform
Returns: string of input with numbers converted to super-script
sub(num)
convert a string's numbers from normal print to sub-script
Parameters:
num : (string/int/float) input value to transform
Returns: string of input with numbers converted to sub-script
roman(num, trunc)
convert a string of numbers, float, or int
Parameters:
num : (string) input number to transform
trunc : (bool | false) true to truncate float value, false to show roman numerals with decimals (XX.VI)
Returns: string of roman numerals representing the input (num)
FrizLabz_Time_Utility_MethodsLibrary "FrizLabz_Time_Utility_Methods"
Some time to index and index to time helper methods made them for another library thought I would try to make
them as methods
UTC_helper(utc)
UTC helper function this adds the + to the positive utc times, add "UTC" to the string
and can be used in the timezone arg of for format_time()
Parameters:
utc : (int) | +/- utc offset
Returns: string | string to be added to the timezone paramater for utc timezone usage
bar_time(bar_amount)
from a time to index
Parameters:
bar_amount : (int) | default - 1)
Returns: int bar_time
time_to_index(_time)
from time to bar_index
Parameters:
_time : (int)
Returns: int time_to_index | bar_index that corresponds to time provided
time_to_bars_back(_time)
from a time quanity to bar quanity for use with .
Parameters:
_time : (int)
Returns: int bars_back | yeilds the amount of bars from current bar to reach _time provided
bars_back_to_time(bars_back)
from bars_back to time
Parameters:
bars_back
Returns: int | using same logic as this will return the
time of the bar = to the bar that corresponds to bars_back
index_time(index)
bar_index to UNIX time
Parameters:
index : (int)
Returns: int time | time in unix that corrresponds to the bar_index
to_utc(time_or_index, timezone, format)
method to use with a time or bar_index variable that will detect if it is an index or unix time
and convert it to a printable string
Parameters:
time_or_index : (int) required) | time in unix or bar_index
timezone : (int) required) | utc offset to be appled to output
format : (string) | default - "yyyy-MM-dd'T'HH:mm:ssZ") | the format for the time, provided string is
default one from str.format_time()
Returns: string | time formatted string
GET(line)
Gets the location paramaters of a Line
Parameters:
line : (line)
Returns: tuple
GET(box)
Gets the location paramaters of a Box
Parameters:
box : (box)
Returns: tuple
GET(label)
Gets the location paramaters and text of a Label
Parameters:
label : (label)
Returns: tuple
GET(linefill)
Gets line 1 and 2 from a Linefill
Parameters:
linefill : (linefill)
Returns: tuple
Format(line, timezone)
converts Unix time in time or index params to formatted time
and returns a tuple of the params as string with the time/index params formatted
Parameters:
line : (line) | required
timezone : (int) | default - na
Returns: tuple
Line(x1, y1, x2, y2, extend, color, style, width)
similar to line.new() with the exception
of not needing to include y2 for a flat line, y1 defaults to close,
and it doesnt require xloc.bar_time or xloc.bar_index, if no x1
Parameters:
x1 : (int) default - time
y1 : (float) default - close
x2 : (int) default - last_bar_time/last_bar_index | not required for line that ends on current bar
y2 : (float) default - y1 | not required for flat line
extend : (string) default - extend.none | extend.left, extend.right, extend.both
color : (color) default - chart.fg_color
style : (string) default - line.style_solid | line.style_dotted, line.style_dashed,
line.style_arrow_both, line.style_arrow_left, line.style_arrow_right
width
Returns: line
Box(left, top, right, bottom, extend, border_color, bgcolor, text_color, border_width, border_style, txt, text_halign, text_valign, text_size, text_wrap)
similar to box.new() but only requires top and bottom to create box,
auto detects if it is bar_index or time used in the (left) arg. xloc.bar_time and xloc.bar_index are not used
args are ordered by purpose | position -> colors -> styling -> text options
Parameters:
left : (int) default - time
top : (float) required
right : (int) default - last_bar_time/last_bar_index | will default to current bar index or time
depending on (left) arg
bottom : (float) required
extend : (string) default - extend.none | extend.left, extend.right, extend.both
border_color : (color) default - chart.fg_color
bgcolor : (color) default - color.new(chart.fg_color,75)
text_color : (color) default - chart.bg_color
border_width : (int) default - 1
border_style : (string) default - line.style_solid | line.style_dotted, line.style_dashed,
txt : (string) default - ''
text_halign : (string) default - text.align_center | text.align_left, text.align_right
text_valign : (string) default - text.align_center | text.align_top, text.align_bottom
text_size : (string) default - size.normal | size.tiny, size.small, size.large, size.huge
text_wrap : (string) default - text.wrap_auto | text.wrap_none
Returns: box
Label(x, y, txt, yloc, color, textcolor, style, size, textalign, text_font_family, tooltip)
similar to label.new() but only requires no args to create label,
auto detects if it is bar_index or time used in the (x) arg. xloc.bar_time and xloc.bar_index are not used
args are ordered by purpose | position -> colors -> styling -> text options
Parameters:
x : (int) default - time
y : (float) default - high or low | depending on bar direction
txt : (string) default - ''
yloc : (string) default - yloc.price | yloc.price, yloc.abovebar, yloc.belowbar
color : (color) default - chart.fg_color
textcolor : (color) default - chart.bg_color
style : (string) default - label.style_label_down | label.style_none
label.style_xcross,label.style_cross,label.style_triangleup,label.style_triangledown
label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown,
label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right,
label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left,
label.style_label_upper_right, label.style_label_center, label.style_square,
label.style_diamond
size : (string) default - size.normal | size.tiny, size.small, size.large, size.huge
textalign : (string) default - text.align_center | text.align_left, text.align_right
text_font_family : (string) default - font.family_default | font.family_monospace
tooltip : (string) default - na
Returns: label
Debugging_consoleRefer to notes for instruction
===================================================================
Motion▮ FEATURES
Now as library version :)
String-based transition-effects
Performance optimization. Reduced memory consumption up to >90% by kicking the output to the "stdout".
Use marquee- or loader-effect on any possible string location.
Example: UI Price-Ticker
----------------------------------------------------------------------------
Library "Motion"
_getStringMono(_len, _str, _sep)
Parameters:
_len
_str
_sep
marquee(this, _extern, _ws, _subLen, _subStart)
Parameters:
this
_extern
_ws
_subLen
_subStart
transition(this, _subLen, _subStart)
Parameters:
this
_subLen
_subStart
hold(this)
Parameters:
this
keyframe
keyframe A keyframe object.
Fields:
seq
intv
step
length
update_no
frame_no
ltr
hold
String Extra FunctionsLibrary "string_extras"
Additional String shortcuts, unshift and pop return the string ~without~ the first or last, so in use will still require to extract first or last character prior to overwriting a string with the output.
can be imported "as str" to work side by side with regular pine
last(_string)
last char of a string
Parameters:
_string
Returns: last char of a string
shift(_string)
string without first char
Parameters:
_string
Returns: string without first char
pop(_string)
string without last char
Parameters:
_string
Returns: string without last char
get(_string, _position)
get specific char of a string
Parameters:
_string
_position
Returns: string _string
push(_string, _char)
push to end of a string
Parameters:
_string
_char
Returns: string _string
unshift(_string, _char)
unshift char to prepend string
Parameters:
_string
_char
Returns: string _string
jsonLibrary "json"
JSON Easy Object Create/stringiffy
Functions to add/write JSON
new (name , kind) -> object
set (_item , _obj , _key ) -> key index for parent object's array
add (_obj , _key , _item ) -> key index for parent object's array
write (object , kind ) -> stringified object // (enter kind to cut off key )
============================================
obj
obj Object storage container/item
Fields:
key : (string ) item name
kind : (string ) item's type(for writing)
item : (string ) item (converted to string)
keys : (string ) keys of all sub-items and objects
items : (obj ) nested obj off individual subitems (for later...)
============================================
new(_name, _kind)
create multitype object
Parameters:
_name : (string) Name off object
_kind : (string) Preset Type (_OBJECT if a container item)
Returns: object container/item 2-in-1
============================================
add(_item, _obj, _key)
Set item to object obj item (same as set, prep for future Pine methods)
Parameters:
_item : ( int / float / bool / string )
_obj : (obj multi-type-item object)
_key : ( string )
set(_item, _obj, _key)
Set item to object obj item (same as add, prep for future Pine methods)
Parameters:
_item : ( int / float / bool / string )
_obj : (obj multi-type-item object)
_key : ( string )
addstore(_parent, _child)
Add a object as a subobject to storage (Future upgrade to write/edit)
Parameters:
_parent : to insert obj into
_child : to be inserted
setstore(_child, _parent)
Add a object as a subobject to storage (Future upgrade to write/edit)
Parameters:
_child : to be inserted
_parent : to insert obj into
add(_parent, _child)
Add a object as a string rendered item
Parameters:
_parent : to insert obj into
_child : to be inserted
set(_child, _parent)
Add a object as a string rendered item
Parameters:
_child : to be inserted
_parent : to insert obj into
============================================
write(_object, _key, _itemname)
Write object to string Object
Parameters:
_object : (obj)
_key : (array<(string/int)> )/(string)
_itemname : (string)
Returns: stringified flattened object.
clean_output(_str)
Clean JSON final output
Parameters:
_str : string json item
Returns: cleaned string
FrizBugLibrary "FrizBug"
Debug Tools | Pinescript Debugging Tool Kit
All in one Debugger - the benefit of wrapper functions to simply wrap variables or outputs and have the code still execute the same. Perfect for Debugging on Pine
str(inp)
Overloaded tostring like Function for all type+including Object Variables will also do arrays and matricies of all Types
Parameters:
inp : All types
Returns: string
print_label(str, x_offset, y, barstate, style, color, textcolor, text_align, size)
Label Helper Function - only needs the Str input to work
Parameters:
str :
x_offset : offset from last bar + or -
y : price of label
barstate : barstate built in variable
style : label style settin7
color : color setting
textcolor : textcolor
text_align : text align setting
size : text_sise
Returns: label
init()
initializes the database arrays
Returns: tuple | 2 matrix (1 matrix is varip(live) the other is reagular var (Bar))
update(log, live, live_console, log_console, live_lbl, log_lbl)
Put at the very end of your code / This updates all of the consoles
Parameters:
log : This matrix is the one used for Bar updates
live : This matrix is the one used for Real Time updates
live_console : on_offs for the consoles and lbls - call in the update function
log_console : on_offs for the consoles and lbls - call in the update function
live_lbl : on_offs for the consoles and lbls - call in the update function
log_lbl : on_offs for the consoles and lbls - call in the update function
Returns: void
log(log, inp, str_label, off, rows, index_cols, bars_back)
Function Will push to the Console offset to the right of Current bar, This is the main Console - it has 2 Feeds left and right (changeable)"
Parameters:
log : Matrix - Log or Live
inp : All types
str_label : (optional) This input will label it on the feed
off : Useful for when you don't want to remove the function"
rows : when printing or logging a matrix this will shorten the output will show last # of rows"
index_cols : When printing or logging a array or matrix this will shorten the array or the columns of a matrix by the #"
bars_back : Adjustment for Bars Back - Default is 1 (0 for barstate.islast)"
Returns: inp - all types (The log and print functions can be used as wrapper functions see usage below for examples)
Print(log, str_label, off, bars_back)
Function can be used to send information to a label style Console, Can be used as a wrapper function, Similar to str.format use with str()
Parameters:
log :
str_label : (optional) Can be used to label Data sent to the Console
off : Useful for when you don't want to remove the function
bars_back : Adjustment for Bars Back - Default is 1 (0 for barstate.islast)
Returns: string
print(inp, str_label, off, bars_back)
This Function can be used to send information to a label style Console, Can be used as a wrapper function, Overload print function
Parameters:
inp : All types
str_label : string (optional) Can be used to label Data sent to the Console
off : Useful for when you don't want to remove the function
bars_back : Adjustment for Bars Back - Default is 1 (0 for barstate.islast)
Returns: inp - all types (The log and print functions can be used as wrapper functions see usage below for examples)
Credits:
@kaigouthro - for the font library
@RicardoSantos - for the concept I used to make this
Thanks!
Use cases at the bottom
POALibrary "POA"
This library is a client script for making a webhook signal formatted string to POABOT server.
entry_message(password, percent, leverage, kis_number)
Create a entry message for POABOT
Parameters:
password : (string) The password of your bot.
percent : (float) The percent for entry based on your wallet balance.
leverage : (int) The leverage of entry. If not set, your levereage doesn't change.
kis_number : (int) The number of koreainvestment account.
Returns: (string) A json formatted string for webhook message.
close_message(password, percent, kis_number)
Create a close message for POABOT
Parameters:
password : (string) The password of your bot.
percent : (float) The percent for close based on your wallet balance.
kis_number : (int) The number of koreainvestment account.
Returns: (string) A json formatted string for webhook message.
exit_message(password, percent)
Create a exit message for POABOT
Parameters:
password : (string) The password of your bot.
percent : (float) The percent for exit based on your wallet balance.
Returns: (string) A json formatted string for webhook message.
in_trade(start_time, end_time)
Create a trade start line
Parameters:
start_time : (int) The start of time.
end_time : (int) The end of time.
Returns: (bool) Get bool for trade based on time range.