Console📕 Console Library
🔷 Introduction
This script is an adaptation of the classic JavaScript console script. It provides a simple way to display data in a console-like table format for debugging purposes.
While there are many nice console/logger scripts out there, my personal goal was to achieve inline functionality and visual object (label, lines) logging .
🔷 How to Use
◼ 1. Import the Console library into your script:
import cryptolinx/Console/1
- or -
Instead of the library namespace, you can define a custom namespace as alias.
import cryptolinx/Console/1 as c
◼ 2. Create and init a new `` object.
The `init()` method is used to initialize the console object with default settings. It can be used to customize it.
// When using the `var` keyword in a declaration, the logs will act as ever-forwarding.
// Without `var`, the `console` variable will be redeclared every time `bar` is called.
// var console = Console.terminal.new(log_position=position.bottom_left, prefix = '> ', show_no = true)
- or -
If you has set up an alias before.
var console = c.terminal.new().init()
◼ 3. Logging
// inline ✨
array testArray = array.new(3, .0).log(console)
// basic
console.log(testArray)
// inline ✨
var testLabel = label.new(bar_index, close, 'Label Text').log(console)
// basic
console.log(testLabel)
// It is also possible to use `().` for literals ✨.
int a = 100
testCalc = (5 * 100).log(console) + a.log(console) // SUM: 600
console.
.empty()
.log('SUM' + WS + testCalc.tostring())
◼ 4. Visibility
Finally, we need to call the `show()` method to display the logged messages in the console.
console.show(true) // True by default. Simply turn it on or off
Formatting
DiddlyUtilityLibrary "DiddlyUtility"
TODO: add library description here
getStringTimeMinus1Minute(london_ssth, london_sstm)
Parameters:
london_ssth
london_sstm
getLadderStepIncrement(_price)
Parameters:
_price
getLadderIndexForPrice(_price, _ladderRange)
Parameters:
_price
_ladderRange
getLadderStartPriceRange(_price, _ladderRange)
Parameters:
_price
_ladderRange
get_volume_string(_volume)
Parameters:
_volume
floorDown(number, decimals)
Parameters:
number
decimals
countDigitsBeforeDecimal(n)
Parameters:
n
countDigitsAfterDecimal(n)
Parameters:
n
getChartTimePeriodAsSeconds(_chartPeriod)
Parameters:
_chartPeriod
debug(_txt)
Parameters:
_txt
SessionAndTimeFct_publicLibrary "SessionAndTimeFct_public"
is_in_session(sessionTime, sessionTimeZone)
: Check if actual bar is in specific session with specific time zone
Parameters:
sessionTime
sessionTimeZone
is_session_start(sessionTime, sessionTimeZone)
: Check if actual bar the first bar of a specific session
Parameters:
sessionTime
sessionTimeZone
is_new_day(timeZone)
: Check if a new day started
Parameters:
timeZone
is_new_week(timeZone)
: Check if a new week started
Parameters:
timeZone
is_new_month(timeZone)
: Check if a new month started
Parameters:
timeZone
is_element_to_show_with_tf_up(base, value)
: Check if an element is to show compared to a specific timeframe >
Parameters:
base
value
is_element_to_show_with_tf_down(base, value)
: Check if an element is to show compared to a specific timeframe <
Parameters:
base
value
TableBuilderLibrary "TableBuilder"
A helper library to make it simpler to create tables in pinescript
This is a simple table building library that I created because I personally feel that the built-in table building method is too verbose. It features chaining methods and variable arguments.
There are many features that are lacking because the implementation is early, and there may be antipatterns because I am not familiar with the runtime behavior like pinescript. If you have any comments on code improvements or features you want, please comment :D
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 `
Markdown: The Pine Editor's Hidden Gem💬 Markdown, a markup language
Markdown is a portable, lightweight markup language that can be used for everything whether you're building a website, documentation, or even presentations.
Platforms like Discord, Reddit, and GitHub support Markdown and is the widely go-to option for text formatting due to its simplicity. Pine Script is a language that also utilizes Markdown, specifically in the Pine Editor where it can really be used to some extent.
Since the release of libraries, user-defined types, and methods, Pine Script is entering an age where developers will be highly dependent on libraries due to the capabilities Pine has inherited recently. It would be no surprise if a few people got together and took their time to thoroughly develop an entire project/library centered around improving Pine Script's built-in functions and providing developers with easier ways of achieving things than they thought they could.
As you're all aware, hovering over functions (and more) in the editor pops up a prompt that specifies the parameters, types, and what the function returns. Pine Script uses Markdown for that, so I figured we could go ahead and push that feature to its limits and see what we can do.
Today we'll go over how we can utilize Markdown in Pine Script, and how you can make your library's built-in functions stand out more than they did previously.
For more information, visit www.markdownguide.org
📕 General Notes
Markdown syntax only works on functions and methods.
Using arrays as parameters as of 2/21/2023 breaks the Markdown system.
The prompt window holds a max of 166 characters on one line before overflowing.
There is no limit on how long the prompt window can be.
🔽 Getting Started 🔽
▶️ Headings
If you have experience in HTML, Markdown, or even Microsoft Word then you already have a grasp of how headings work and look.
To simplify it, headings make the given text either massive or tiny depending on how many number symbols are provided.
When defining headings, you must have a space between the number (#) symbol, and the text. This is typical syntax throughout the language.
Pine Script uses bold text by applying (**) for their titles on their built-ins (e.g. @returns) but you could also use heading level 4 (####) and have it look the same.
▶️ Paragraphs & Line Breaks
You may want to provide extensive details and examples relating to one function, in this case, you could create line breaks. Creating line breaks skips to the next line so you can keep things organized as a result.
To achieve a valid line break and create a new paragraph, you must end the line with two or more spaces.
If you want to have an empty line in between, apply a backslash (\).
Backslashes (\) are generally not recommended for every line break. In this case, I only recommend using them for empty lines.
▶️ Text Formatting
Markdown provides text formatting such as bold, italics, and strikethrough.
For bolding text, you can apply open and close (**) or (__).
For italicizing text, you can apply open and close (*) or (_).
For bolding and italicizing text, you can apply open and close (***) or (___).
For s̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶, you need to apply open and close (~~).
This was mentioned in the Headers section, but Pine Script's main titles (e.g. @returns or @syntax) use bold (**) by default.
▶️ Blockquotes
Blockquotes in Pine Script can be visualized as a built-in indentation system.
They are declared using greater than (>) and everything will be auto-aligned and indented until closed.
By convention you generally want to include the greater than (>) on every line that's included in the block quote. Even when not needed.
If you would like to indent even more (nested blockquotes), you can apply multiple greater than symbols (>). For example, (>>)
Blockquotes can be closed by ending the next line with only one greater than (>) symbol, or by using a horizontal rule.
▶️ Horizontal Rules
Horizontal rules in Pine Script are what you see at the very top of the prompt in built-ins.
When hovering, you can see the top of the prompt provides a line, and we can actually reproduce these lines.
These are extremely useful for separating information into their own parts and are accessed by applying 3 underscores (___), or 3 asterisks (***).
Horizontal rules were mentioned above, when we were discussing block quotes. These can also be used to close blockquotes as well.
Horizontal rules require a minimum of 3 underscores (___) or 3 asterisks (***).
▶️ Lists
Lists give us a way to structure data in a somewhat neat way. There are multiple ways to start a list, such as
1. First Item (number followed by a period)
- First Item (dash)
+ First Item (plus sign)
* First Item (asterisk)
Using number-based lists provide an ordered list, whereas using (-), (+), or (*) will provide an unordered list (bullet points).
If you want to begin an unordered list with a number that ends with a period, you must use an escape sequence (\) after the number.
Standard indentation (tab-width) list detection isn't supported, so to nest lists you have to use blockquotes (>) which may not look as appealing.
▶️ Code Blocks
Using code blocks allows you to write actual Pine Script code inside the prompt.
It's a game changer that can potentially help people understand how to execute functions quickly.
To use code blocks, apply three 3 open and close backquotes (```). Built-in's use (```pine) but there's no difference when we apply it.
Considering that tab-width indentation isn't detected properly, we can make use of the blockquotes mentioned above.
▶️ Denotation
Denoting can also be seen as highlighting a background layer behind text. They're basically code blocks, but without the "block".
Similar to how code blocks work, we apply one backquote open and close (`).
Make sure to only use this on important keywords. There really isn't a conventional way of applying this.
It's up to you to decide what people should have their eyes tracked onto when they hover over your functions.
If needed, look at how Pine Script's built-in variables and functions utilize this.
▶️ Tables
Tables are possible in Markdown, although they may look a bit different in the Pine Editor.
They are made by separating text with vertical bars (|).
The headers are detected when there is a minimum of one hyphen (-) below them.
You can align text by using a colon as I do in the photo. Hyphens must be connected to the colon in order to display correctly.
Tables aren't ideal to use in the editor but are there if anyone wants to give it a go.
▶️ Links & Images
Markdown supports images and hyperlinks, which means we can also do that here in the Pine Editor. Cool right?
If you want to create a hyperlink, surround the displayed text in open and close brackets .
If you want to load a photo into your prompt, it's the same syntax as the hyperlink, except it uses a (!)
See syntax list below.
Here are realistic usage examples. (Snippets from code below)
These follow the same syntax as the built-ins.
I'm not using horizontal rules here, but it's entirely up to you.
▶️ Syntax List
Headings
Level 1: #
Level 2: ##
Level 3: ###
Level 4: ####
Level 5: #####
Level 6: ######
Line Breaks
Text (two spaces)
Text\ (backslash)
Text Formatting
Bold (**)
Italic (**)
Strikethrough (~~)
Blockquotes
Indent (>)
Double Indent (>>)
Triple Indent (>>>) and so on.
Horizontal Rules
(___) or (***)
Lists
Ordered List (1.)
Unordered List (-) or (+) or (*)
Code Blocks
(```) or (```pine)
Denotation
(`)
Tables
(|) and (-) and (:)
Hyperlinks
(URL)
Images
! (URL)
Hope this helps. 👍
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
AntaresLibrary "Antares"
this library contains some utility functions that I use in my open source scripts including moving average helpers, candlstick helpers, money management, formatters, convertors, webhook integration, analysis, filters and drawing helpers
ma(type, length, source)
Wraps all ma functions
Parameters:
type : Either SMA or EMA or RMA or WMA or VWMA
length : Number of bars (length).
source : Series of values to process.
Returns: Moving average of `source` for `length` bars back by the of MA.
bb(ma, length, mult, source)
Overwrites `ta.bb` duo to limitations of simple int.float mult. Bollinger Bands. A Bollinger Band is a technical analysis tool defined by a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the security's price, but can be adjusted to user preferences.
Parameters:
ma : Either SMA or EMA or RMA or WMA or VWMA
length : Number of bars (length).
mult : Standard deviation factor.
source : Series of values to process.
Returns: Bollinger Bands.
atr(length, h, l, c)
Overwrites `ta.atr` duo to limitations of simple int length. Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close ), abs(low - close )).
Parameters:
length : Number of bars (length).
h : High price high price.
l : low price.
c : Close price close price.
Returns: Average true range.
rsi(length, source)
Overwrites `ta.rsi` duo to limitations of simple int length. Relative strength index. It is calculated using the `ta.rma()` of upward and downward changes of `source` over the last `length` bars.
Parameters:
length : Number of bars (length).
source : Series of values to process.
Returns: Relative strength index.
lowest(length, source, start)
Lowest value for a given number of bars back.
Parameters:
length : Number of bars (length).
source : Series of values to process.
start : Series number of bars that should be skipped before process.
Returns: Lowest value in the series.
highest(length, source, start)
Highest value for a given number of bars back.
Parameters:
length : Number of bars (length).
source : Series of values to process.
start : Series number of bars that should be skipped before process.
Returns: Highest value in the series.
atr_multiplier(rsi, atr_max_multiplier)
Dynamic atr multiplier calculated by RSI.
Parameters:
rsi : Relative strength index.
atr_max_multiplier : The maximum multiplier of atr
Returns: Dynamic multiplier of ATR
offset(atr, atr_multiplier)
Safe dynamic offset you need to use in your stoploss, stop buy/sell, etc.
Parameters:
atr : Average true range.
atr_multiplier : ATR multiplier got from `atr_multiplier(rsi, atr_max_multiplier)`
Returns: Dynamic offset
rsi_emotional(rsi, bottom, top)
Tells you if RSI is in emotional zone.
Parameters:
rsi : Relative Strength Index
bottom : The zone that below it market reacts emotionally
top : The zone that above it market reacts emotionally
Returns: false if RSI was between `bottom` and `top` otherwise true
rsi_signal(rsi, bottom, top)
Tells you if RSI is in good point to check your other strategy conditions.
Parameters:
rsi : Relative Strength Index
bottom : The zone that below it market reacts emotionally
top : The zone that above it market reacts emotionally
Returns: 1 if RSI crossed out 30, 50 or 70. -1 if RSI crossed under 70, 50, 30. otherwise is 0
DiscordLibraryLibrary "DiscordLibrary"
BoldString(str)
Bold String in Discord Function
Parameters:
str
ItalicizeString(str)
Italicize String in Discord Function
Parameters:
str
StrikeThroughString(str)
Strikethrough a String in Discord Function
Parameters:
str
UnderlineString(str)
Underline a String in Discord Function
Parameters:
str
SpoilerString(str)
When you send the text, it will be shown as a black block, and only by clicking on it will you be able to see what is written below, in a way, unveiling the text or giving spoilers
Parameters:
str
HighlightString(str)
Highlight String Function
Parameters:
str
BoxedString(str)
Put String in a Box Function
Parameters:
str
NonEmbeddedURLString(str)
Format URL String so that it is not an embedded Image but just the Link
Parameters:
str
InvisibleString(str)
Send Inivisible Text
Parameters:
str
FormatTimePeriodForDiscord(_timeperiod)
Parameters:
_timeperiod
GetDiscordEmbedJSON(_message, _avatarURL, _botName, _role, _color, _embed_title, _embed_subtitle, _title, _url, _icon_url, _icon2_url, _footer, _description)
Generate discord embed JSON
Parameters:
_message
_avatarURL
_botName
_role
_color
_embed_title
_embed_subtitle
_title
_url
_icon_url
_icon2_url
_footer
_description
GetDiscordTextJSON(_description)
Formats Content Only JSON Message
Parameters:
_description
Truncate(_number, _decimalPlaces)
Custom function to truncate (cut) excess decimal places
Parameters:
_number
_decimalPlaces
FormatDiscordMessage(_textmessage, _ticker, _timeframe)
format Content message
Parameters:
_textmessage
_ticker
_timeframe
FormatCoin(_coinText)
Format Ticker Symbol
Parameters:
_coinText
theme_engineLibrary "theme_engine"
Theme Builder and Structure for live generative themes
init(_name)
New theme object.
Parameters:
_name : (string) opptional name
Returns: a VAR theme (holds it's vals when updated if not overwritten)
globals(theme, _h1, _h2, _h3, _h4, _s, _val, _contrast)
Create light/dark theme globals
Parameters:
theme : (theme) Theme to add theses to
_h1 : (float) Hue #1 for Template
_h2 : (float) Hue #2 for Template
_h3 : (float) Hue #3 for Template
_h4 : (float) Hue #4 for Template
_s : (float) Saturation of theme
_val : (float) Luminosity (light/dark)
_contrast : (float) Contrast to apply
Returns: Theme wwith adjusted colors
setConfig(theme, setting)
Apply a Settings object to a theme
Parameters:
theme : Theme object to apply settings to.
setting : settings to apply
Returns: theme
Types :
settings
Settings for a theme
Fields:
h1 : (float) Hue #1 for Template
h2 : (float) Hue #2 for Template
h3 : (float) Hue #3 for Template
h4 : (float) Hue #4 for Template
sat : (float) Saturation of theme
lum : (float) Luminosity (light/dark)
vib : (float) Vibrance (Contrast)
r : (float) Hue of Red
o : (float) Hue of Orange
y : (float) Hue of Yellow
g : (float) Hue of Green
a : (float) Hue of Aqua
b : (float) Hue of Blue
i : (float) Hue of Indigo
v : (float) Hue of Violet
satvals : (settings) Array for use if desired to customize Saturation per color
lumvals : (settings) Array for use if desired to customize Luminancce per color
mods
Modifiers Item for Use if desired
Fields:
val : (float)
size : (float)
depth : (float)
hue : (float)
sat : (float)
alpha : (float)
mix : (float)
emit : (float)
ch : (float)
step : (int)
dist : (int)
holds : (mods)
isin : (mods)
track : (color)
varient
Light/Dark/Custom Theme Varients
Fields:
bg : (color) Bacckground Color
fg : (color) Foreground Color
accent : (color) Accccent Color
secondary : (color) Secondary Color
txt : (color) Text Color
theme
Theme Object
Fields:
name : (string) Theme name
dark : (varient) Theme dark Varient
light : (varient) Theme light Varient
red : (color) Color for red
orange : (color) Color for orange
yellow : (color) Color for yellow
green : (color) Color for green
aqua : (color) Color for aqua
blue : (color) Color for blue
purple : (color) Color for purple
pink : (color) Color for pink
tweaks : (mods) Modifiers UDT to use for adjusters
themedict
Fields:
names : (string ) Names of themes
themes : (theme ) Theme Items
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
TableBuilderTableBuilder is a library designed to make it easier to create tables in PineScript.
It allows you to more flexibly define the structure of a table before actually building it.
Features:
Style inheritance: styles are inherited from Table, to Column, to Row, and then Cell.
Columns are useful for propagating/reusing style but they are not required.
Add rows with different numbers of cells. The resultant number of columns in the table will be determined by the max number of cells vs the number of defined columns.
Auto text color: Instead of having to set the font color for every cell, the color is automatically determined by the luminosity of the background color.
See the 'Demo' section of the code for an example.
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
Dynamic Array Table (versatile display methods)Library "datTable"
Dynamic Array Table.... Configurable Shape/Size Table from Arrays
Allows for any data in any size combination of arrays to join together
with:
all possible orientations!
filling all cells contiguously and/or flipping at boundaries
vertical or horizontal rotation
x/y axis direction swapping
all types array inputs for data.
please notify of any bugs. thanks
init(_posit)
Get Table (otional gapping cells)
Parameters:
_posit : String or Int (1-9 3x3 grid L to R)
Returns: Table
coords()
Req'd coords Seperate for VARIP table, non-varip coords
add
Add arrays to display table. coords reset each calc
uses displaytable object, string titles, and color optional array, and second line optional data 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`
libcompressLibrary "libcompress"
numbers compressor for large output data compression
compress_fp24()
converts float to base64 (4 chars) | 24 bits: 1 sign + 5 exponent + 18 mantissa
Returns: 4-character base64_1/5/18 representation of x
compress_ufp18()
converts unsigned float to base64 (3 chars) | 18 bits: 5 exponent + 13 mantissa
Returns: 3-character base64_0/5/13 representation of x
compress_int()
converts int to base64
text_utilsLibrary "text_utils"
a set of functions to handle placeholder in texts
add_placeholder(list, key, value)
add a placehodler key and value to a local list
Parameters:
list : - reference to a local string array containing all placeholders, add string list = array.new_string(0) to your code
key : - a string representing the placeholder in a text, e.g. '{ticker}'
value : - a string representing the value of the placeholder e.g. 'EURUSD'
Returns: void
add_placeholder(list, key, value, format)
add a placehodler key and value to a local list
Parameters:
list : - reference to a local string array containing all placeholders, add string list = array.new_string(0) to your code
key : - a string representing the placeholder in a text, e.g. '{ticker}'
value : - an integer value representing the value of the placeholder e.g. 10
format : - optional format string to be used when converting integer value to string, see str.format() for details, must contain '{0}'
Returns: void
add_placeholder(list, key, value, format)
add a placehodler key and value to a local list
Parameters:
list : - reference to a local string array containing all placeholders, add string list = array.new_string(0) to your code
key : - a string representing the placeholder in a text, e.g. '{ticker}'
value : - a float value representing the value of the placeholder e.g. 1.5
format : - optional format string to be used when converting float value to string, see str.format() for details, must contain '{0}'
Returns: void
replace_all_placeholder(list, text_to_covert)
replace all placeholder keys with their value in a given text
Parameters:
list : - reference to a local string array containing all placeholders
text_to_covert : - a text with placeholder keys before their are replaced by their values
Returns: text with all replaced placeholder keys
fast_utilsLibrary "fast_utils"
This library contains my favourite functions. Will be updated frequently
count_int_digits()
Count int digits in number
Returns: : number of int digits in number
count_float_digits()
Count float digits in number
Returns: : number of float digits in number
stringify()
Convert values in array or matrix into string values
Returns: : array or matrix of string values
arrcompare()
Compare values in arrays
Returns: : bool value
arrdedup()
Remove duplicate values in array
Returns: : array without duplicates
ResInMins()
Converts current resolution in minutes
Returns: : return float number of minuted
MultOfRes(res, mult)
Convert current float TF in minutes to target string TF in "timeframe.period" format.
Parameters:
res : : current resolution in minutes
mult : : Multiple of current TF to be calculated.
Returns: : timeframe format string
Encoder DecoderLibrary "EncoderDecoder"
Simple example how to encode some values into float number and then decode it back to original values
f_calctype()
Encode parameter
Returns: encoded value
f_calctype()
Decode parameter
Returns: decoded value
f_srctype()
Encode parameter
Returns: encoded value
f_srctype()
Decode parameter
Returns: decoded value
f_encode(calc_type, src_type, tf, length)
Encodes 4 paramters into float number
Parameters:
calc_type : 1st paramter to encode (its values defined in f_calctype functions) max number of values that can be encoded = 100
src_type : 2nd paramter to encode (its values defined in f_src_type functions) max number of values that can be encoded = 100
tf : 3rd paramter to encode (may be int number with format.price precision length!)
length : 4th paramter to encode (may be any int number)
Returns: float number
f_decode()
Decodes 4 paramters into tuple
Returns: tuple
intoLibrary "into"
convert literals by type,
Same-types left in for bulk reasons.
TODO: Expand Types
b(string)
Convert string to bool.
Parameters:
string : val A string value.
Returns: Bool.
b(bool)
Pass Bool/bool
Parameters:
bool :
Returns: Bool.
b(float)
Convert Float (True if exists and not 0)
Parameters:
float : val A float value.
Returns: Bool.
b(int)
Convert integer (True if exists and not 0)
Parameters:
int : val An integer value.
Returns: Bool.
f(bool)
Convert bool to float.
Parameters:
bool : val A boolean value.
Returns: Float.
f(string, int)
Convert with decimal
Parameters:
string : val A string value.
int : decimals Decimal places. def = 6
Returns: Float.
f(float, int)
Convert float bypass with decimals
Parameters:
float : val A float value.
int : decimals Decimal places. def = 6
Returns: Float.
f(int)
Convert integer to float.
Parameters:
int : val An integer value.
Returns: Float.
i(bool)
Convert bool to int.
Parameters:
bool : val A boolean value.
Returns: Int.
i(string)
Convert string number to int.
Parameters:
string : val A string value.
Returns: Int.
i(float)
Convert float to int.
Parameters:
float : val A float value.
Returns: Int.
i(int)
Convert int to int.
Parameters:
int : val An int value.
Returns: Int.
s(bool)
Convert bool value to string.
Parameters:
bool : val A boolean value.
Returns: String.
s(str)
bypass string
Parameters:
str : val A string value.
Returns: String.
s(float)
Convert float value to string.
Parameters:
float : val A float value.
Returns: String.
s(int)
Convert int value to string.
Parameters:
int : val An integer value.
Returns: String.
s(val)
Array Convert Each Item
Parameters:
val : Array Input (Str,Bool,Int,Float)
Returns: String.
s(val)
Array Convert Each Item
Parameters:
val : Array Input (Str,Bool,Int,Float)
Returns: String.
s(val)
Array Convert Each Item
Parameters:
val : Array Input (Str,Bool,Int,Float)
Returns: String.
s(val)
Array Convert Each Item
Parameters:
val : Array Input (Str,Bool,Int,Float)
Returns: String.
fontLibrary "font"
Unicode Characters Replacement function for strings.
uni(_str, _number)
Unicode Font Substitutee
Parameters:
_str : Input Strinbg
_number : Font by Int input
uni(_str, _number)
Unicode Font Substitutee
Parameters:
_str : Input Strinbg
_number : Font by Name input
String to NumberA library that exposes a method to translate strings to numbers. Adapted from MichelT 's String to Number indicator.