rowsLibrary "rows"
Error Tolerant Matrix Setter/Getter Operations. Easy ways to add/remove items into start and end of rows as well as arrays to grow and shrink matrix.
if mismatched sizes occur the typified NA value will be there to prevent catastrophic crashing.
columns and rows are split into 2 libraries due to limitations on number of exports as well as ease of style (columns.shift(), rows.pop() )
pop(_matrix)
do pop last row off of matrix
Parameters:
_matrix : Matrix To Edit
Returns: Array of Last row, removing it from matrix
shift(_matrix)
do shift the first row off of matrix
Parameters:
_matrix : Matrix To Edit
Returns: Array of First row, removing it from matrix
get(_matrix, _rowNum)
retrieve specific row of matrix
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
Returns: Array of selected row number, leaving in place
push(_matrix, _rowNum, _item)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_item : Item to Push on Row
Returns: shifted item from row start
push(_matrix, _array)
add single item onto end of matrix
Parameters:
_matrix : Matrix To Edit
_array : Array to Push on Matrix
Returns: Void
unshift(_matrix, _rowNum, _item)
slide single item into start of row remove last
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_item : Item to Unshift on Row
Returns: popped item from row end
unshift(_matrix, _array)
add single item into first row of matrix
Parameters:
_matrix : Matrix To Edit
_array : Array to unshift into Matrix
Returns: Void
set(_matrix, _rowNum, _array)
replace an array to an existing row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_array : Array to place in Matrix
Returns: row that was replaced
insert(_matrix, _rowNum, _array)
insert an array to a new row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
_array : Array to place in Matrix
Returns: void
slideDown(_matrix, _array)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_array : Array to push to Matrix
Returns: shifted first row
slideUp(_matrix, _array)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_array : Array to unshift to Matrix
Returns: popped last row
pullOut(_matrix, _rowNum)
add single item onto end of row
Parameters:
_matrix : Matrix To Edit
_rowNum : Row being Targeted
Returns: removed selected row
Indicateurs et stratégies
RS_TD_Library_2Library "RS_TD_Library_2"
TradingView Library for showing option prices on the chart
Here is a simple way to draw options to an underlying asset on the chart. At the top right there is a table with the summary of the corresponding premiums. A tooltip shows the corresponding buy/sell prices for each option.
showTable(sumShortPut, sumLongPut, sumShortCall, sumLongCall, sumTotal, smallLayout)
Shows the table of profit/loss of all options to the given underlying
Parameters:
sumShortPut : Sum of all short put options
sumLongPut : Sum of all long put options
sumShortCall : Sum of all short call options
sumLongCall : Sum of all long call options
sumTotal : Sum of all kind of options
smallLayout : Usage of a small table layout
debugging_labelOnEachBar(_text)
Shows a debugging label on each bar
Parameters:
_text : Text to show on the label
showLine(date1, date2, strike, color)
Prints a line at the strike of the option
Parameters:
date1 : Buying date of the option
date2 : Selling date of the option
strike : Strike of the option
color : Color of the line
showLabel(date, strike, color, tooltip)
Prints a label at the strike of the option
Parameters:
date : Buying/Selling date of the option
strike : Strike of the option
color : Color of the line
tooltip : ToolTip of the option with the detailed prices
fibo_levelsLibrary "Fibo_levels"
Calculate Fibo levels from any 2 levels. Your need know only 2 price of 2 levels for calculate any level of Fibo: function 'fibo_lvl',
or calculate array of price Fibo levels : function 'fibo_lvls'
fibo_lvl(fibo_lvl1, price1, fibo_lvl2, price2, calc_level)
Parameters:
fibo_lvl1 : First of any level of fibo from 0 to 1 (example 0.236)
price1 : Price for 1th any level (example 2356.1)
fibo_lvl2 : Second of any level of fibo from 0 to 1 (example 0.382)
price2 : Price for 2th any level (example 2497.4)
calc_level : Price for level to calculate (example 0.5)
Returns: return price for calc_level fibo
fibo_lvls(bars, time1, time2, fibo_lvl1, price1, fibo_lvl2, price1)
Parameters:
fibo_lvl1 : First of any level of fibo from 0 to 1 (example 0.236)
price1 : Price for 1th any level (example 2356.1)
fibo_lvl2 : Second of any level of fibo from 0 to 1 (example 0.382)
price1 : Price for 2th any level (example 2497.4)
Returns: array of price for fibo levels : (0.0, 0.118, 0.236, 0.384, 0.5, 0.618, 0.786, 1.0, 1.27,-0.27,1.618,-0.618)
conditionLibrary "condition"
True/False Condition tools and toggles for booleans and utility.
suggested use is checking if a calculation is required, or can be skipped
speeding up script calculations in realtime and historical scenarios.
isonlywihtout(_first_cond, _second_cond)
output is true only if first true and second false
Parameters:
_first_cond : (bool) First Condition
_second_cond : (bool) Second Condition
Returns: True if coditions met
isonlywih(_first_cond, _second_cond)
output is true only for the first condition if the second condition is also true
Parameters:
_first_cond : (bool) First Condition
_second_cond : (bool) Second Condition
Returns: True if coditions met
isactive(_cond)
output is true active only while actively true
Parameters:
_cond : (bool) Condition met
Returns: True if coditions met
isnotactive(_cond)
output is true only while condition is not active
Parameters:
_cond : (bool) Condition met
Returns: True if coditions met
isontoggle(_cond)
output is true and holds on True activation , na input has no effect, only a false will disengage
Parameters:
_cond : (bool) Condition met
Returns: True if coditions met
isofftoggle(_cond)
output is true and holds on False activation, na input has no effect, only a true will disengage
Parameters:
_cond : (bool) Condition met
Returns: True if coditions met
isnotboth(_first_cond, _second_cond)
output is false only if both are active, either or neither pass true
Parameters:
_first_cond : (bool) First Condition
_second_cond : (bool) Second Condition
Returns: True if coditions met
isneither(_first_cond, _second_cond)
output is false only if both are active, either or neither pass true
Parameters:
_first_cond : (bool) First Condition
_second_cond : (bool) Second Condition
Returns: True if coditions met
isbothtoggled(_first_cond, _second_cond)
output is true and held when both trigger true, and only disengages if both are false at once
Parameters:
_first_cond : (bool) First Condition
_second_cond : (bool) Second Condition
Returns: True if coditions met
LibIndicadoresUteisLibrary "LibIndicadoresUteis"
Collection of useful indicators. This collection does not do any type of plotting on the graph, as the methods implemented can and should be used to get the return of mathematical formulas, in a way that speeds up the development of new scripts. The current version contains methods for stochastic return, slow stochastic, IFR, leverage calculation for B3 futures market, leverage calculation for B3 stock market, bollinger bands and the range of change.
estocastico(PeriodoEstocastico)
Returns the value of stochastic
Parameters:
PeriodoEstocastico : Period for calculation basis
Returns: Float with the stochastic value of the period
estocasticoLento(PeriodoEstocastico, PeriodoMedia)
Returns the value of slow stochastic
Parameters:
PeriodoEstocastico : Stochastic period for calculation basis
PeriodoMedia : Average period for calculation basis
Returns: Float with the value of the slow stochastic of the period
ifrInvenenado(PeriodoIFR, OrigemIFR)
Returns the value of the RSI/IFR Poisoned of Guima
Parameters:
PeriodoIFR : RSI/IFR period for calculation basis
OrigemIFR : Source of RSI/IFR for calculation basis
Returns: Float with the RSI/IFR value for the period
calculoAlavancagemFuturos(margem, alavancagemMaxima)
Returns the number of contracts to work based on margin
Parameters:
margem : Margin for contract unit
alavancagemMaxima : Maximum number of contracts to work
Returns: Integer with the number of contracts suggested for trading
calculoAlavancagemAcoes(alavancagemMaxima)
Returns the number of batches to work based on the margin
Parameters:
alavancagemMaxima : Maximum number of batches to work
Returns: Integer with the amount of lots suggested for trading
bandasBollinger(periodoBB, origemBB, desvioPadrao)
Returns the value of bollinger bands
Parameters:
periodoBB : Period of bollinger bands for calculation basis
origemBB : Origin of bollinger bands for calculation basis
desvioPadrao : Standard Deviation of bollinger bands for calculation basis
Returns: Two-position array with upper and lower band values respectively
theRoc(periodoROC, origemROC)
Returns the value of Rate Of Change
Parameters:
periodoROC : Period for calculation basis
origemROC : Source of calculation basis
Returns: Float with the value of Rate Of Change
base16Library "base16"
Base16 Syntax Theme Collection. dark/light Pairs placed into 2 matched groups.
included is tool for assembling your own themes, as well as all themes String names
to create your own Input menus / add to your own theme matrix, and theme selectors
addToMatrix(_mtx, _title, _choices, _theme)
To create a theme matrix with string index, use a color matrix global
add theme name to string array of theme titles
and last input a theme from above, or create your own theme arrays.
Parameters:
_mtx : (color ) matrix for storage
_title : (string ) Name of theme being added
_choices : (string ) name index
_theme : (color ) colors being added
Returns: void
addToMatrix(_mtx, _theme)
Add theme to color matrix Non-indexed
Parameters:
_mtx : (color ) matrix for storage
_theme : (color ) colors being added
dark()
Dark Themne Selection (With light Equivalent in same location)
Returns: Color matrix of dark themes
light()
light Themne Selection (With dark Equivalent in same location)
Returns: Color matrix of light themes
selectTheme(_mtx, _themes, _theme)
Get a Theme By Name
Parameters:
_mtx : (Matrix color) Name of Theme
_themes : (Array string) Array with Names of Themes
_theme : (string ) Name of Theme to select
selectTheme(_mtx, _theme)
Get a Theme By Number
Parameters:
_mtx : (Matrix color) Name of Theme
_theme : (int ) Number of Theme to select
/// all themes included:
3024
apathy
apprentice
ashes
atelier_cave_light
atelier_cave
atelier_dune_light
atelier_dune
atelier_estuary_light
atelier_estuary
atelier_forest_light
atelier_forest
atelier_heath_light
atelier_heath
atelier_lakeside_light
atelier_lakeside
atelier_plateau_light
atelier_plateau
atelier_savanna_light
atelier_savanna
atelier_seaside_light
atelier_seaside
atelier_sulphurpool_light
atelier_sulphurpool
atlas
ayu_dark
ayu_light
ayu_mirage
bespin
black_metal_bathory
black_metal_burzum
black_metal_dark_funeral
black_metal_gorgoroth
black_metal_immortal
black_metal_khold
black_metal_marduk
black_metal_mayhem
black_metal_nile
black_metal_venom
black_metal
blue_forest
blueish
brewer
bright
brogrammer
brush_trees_dark
brush_trees
catppuccin
chalk
circus
classic_dark
classic_light
codeschool
clrs
cupcake
cupertino
da_one_black
da_one_gray
da_one_ocean
da_one_paper
da_one_sea
da_one_white
danqing_light
danqing
darcula
darkmoss
darktooth
dark_violet
decaf
default_dark
default_light
dirtysea
dracula
edge_dark
edge_light
eighties
embers
emil
equilibrium_dark
equilibrium_gray_dark
equilibrium_gray_light
equilibrium_light
espresso
eva_dim
eva
everforest
flat
framer
fruit_soda
gigavolt
github
google_dark
google_light
gotham
grayscale_dark
grayscale_light
green_screen
gruber
gruvbox_dark_hard
gruvbox_dark_medium
gruvbox_dark_pale
gruvbox_dark_soft
gruvbox_light_hard
gruvbox_light_medium
gruvbox_light_soft
gruvbox_material_dark_hard
gruvbox_material_dark_medium
gruvbox_material_dark_soft
gruvbox_material_light_hard
gruvbox_material_light_medium
gruvbox_material_light_soft
hardcore
harmonic16_dark
harmonic16_light
heetch_light
heetch_dark
helios
hopscotch
horizon_dark
horizon_light
horizon_terminal_dark
horizon_terminal_light
humanoid_dark
humanoid_light
ia_dark
ia_light
icy_dark
ir_black
isotope
kanagawa
katy
kimber
lime
macintosh
marrakesh
materia
material_darker
material_lighter
material_palenight
material_vivid
material
mellow_purple
mexico_light
mocha
monokai
Nebula
nord
nova
ocean
oceanicnext
one_light
onedark
outrun_dark
pandora
papercolor_dark
papercolor_light
paraiso
pasque
phd
pico
pinky
pop
porple
primer_dark_dimmed
primer_dark
primer_light
purpledream
qualia
railscasts
rebecca
rose_pine_dawn
rose_pine_moon
rose_pine
sagelight
sakura
sandcastle
seti_ui
shades_of_purple
shadesmear_dark
shadesmear_light
shapeshifter
silk_dark
silk_light
snazzy
solar_flare_light
solar_flare
solarized_dark
solarized_light
spaceduck
spacemacs
stella
still_alive
summercamp
summerfruit_dark
summerfruit_light
synth_midnight_terminal_dark
synth_midnight_terminal_light
tango
tender
tokyo_city_dark
tokyo_city_light
tokyo_city_terminal_dark
tokyo_city_terminal_light
tokyo_night_dark
tokyo_night_light
tokyo_night_storm
tokyo_night_terminal_dark
tokyo_night_terminal_light
tokyo_night_terminal_storm
tokyodark_terminal
tokyodark
tomorrow_night_eighties
tomorrow_night
tomorrow
london_tube
twilight
unikitty_dark
unikitty_light
unikitty_reversible
uwunicorn
vice
vulcan
windows_10_light
windows_10
windows_95_light
windows_95
windows_high_contrast_light
windows_high_contrast
windows_nt_light
windows_nt
woodland
xcode_dusk
zenburn
BpaLibrary "Bpa"
TODO: library of Brooks Price Action concepts
isBreakoutBar(atr, high, low, close, open, tail, size)
TODO: check if the bar is a breakout based on the specified conditions
Parameters:
atr : TODO: atr value
high : TODO: high price
low : TODO: low price
close : TODO: close price
open : TODO: open price
tail : TODO: decimal value for a percent that represent the size of the tail of the bar that cant be preceeded to be considered strong close
size : TODO: decimal value for a percent that represents by how much the breakout bar should be bigger than others to be considered one
Returns: TODO: boolean value, true if breakout bar, false otherwise
LibraryCOTLibrary "LibraryCOT"
This library provides tools to help Pine programmers fetch Commitment of Traders (COT) data for futures.
rootToCFTCCode(root)
Accepts a futures root and returns the relevant CFTC code.
Parameters:
root : Root prefix of the future's symbol, e.g. "ZC" for "ZC1!"" or "ZCU2021".
Returns: The part of a COT ticker corresponding to `root`, or "" if no CFTC code exists for the `root`.
currencyToCFTCCode(curr)
Converts a currency string to its corresponding CFTC code.
Parameters:
curr : Currency code, e.g., "USD" for US Dollar.
Returns: The corresponding to the currency, if one exists.
optionsToTicker(includeOptions)
Returns the part of a COT ticker using the `includeOptions` value supplied, which determines whether options data is to be included.
Parameters:
includeOptions : A "bool" value: 'true' if the symbol should include options and 'false' otherwise.
Returns: The part of a COT ticker: "FO" for data that includes options and "F" for data that doesn't.
metricNameAndDirectionToTicker(metricName, metricDirection)
Returns a string corresponding to a metric name and direction, which is one component required to build a valid COT ticker ID.
Parameters:
metricName : One of the metric names listed in this library's chart. Invalid values will cause a runtime error.
metricDirection : Metric direction. Possible values are: "Long", "Short", "Spreading", and "No direction". Valid values vary with metrics. Invalid values will cause a runtime error.
Returns: The part of a COT ticker ID string, e.g., "OI_OLD" for "Open Interest" and "No direction", or "TC_L" for "Traders Commercial" and "Long".
typeToTicker(metricType)
Converts a metric type into one component required to build a valid COT ticker ID. See the "Old and Other Futures" section of the CFTC's Explanatory Notes for details on types.
Parameters:
metricType : Metric type. Accepted values are: "All", "Old", "Other".
Returns: The part of a COT ticker.
convertRootToCOTCode(mode, convertToCOT)
Depending on the `mode`, returns a CFTC code using the chart's symbol or its currency information when `convertToCOT = true`. Otherwise, returns the symbol's root or currency information. If no COT data exists, a runtime error is generated.
Parameters:
mode : A string determining how the function will work. Valid values are:
"Root": the function extracts the futures symbol root (e.g. "ES" in "ESH2020") and looks for its CFTC code.
"Base currency": the function extracts the first currency in a pair (e.g. "EUR" in "EURUSD") and looks for its CFTC code.
"Currency": the function extracts the quote currency ("JPY" for "TSE:9984" or "USDJPY") and looks for its CFTC code.
"Auto": the function tries the first three modes (Root -> Base Currency -> Currency) until a match is found.
convertToCOT : "bool" value that, when `true`, causes the function to return a CFTC code. Otherwise, the root or currency information is returned. Optional. The default is `true`.
Returns: If `convertToCOT` is `true`, the part of a COT ticker ID string. If `convertToCOT` is `false`, the root or currency extracted from the current symbol.
COTTickerid(COTType, CTFCCode, includeOptions, metricName, metricDirection, metricType)
Returns a valid TradingView ticker for the COT symbol with specified parameters.
Parameters:
COTType : A string with the type of the report requested with the ticker, one of the following: "Legacy", "Disaggregated", "Financial".
CTFCCode : The for the asset, e.g., wheat futures (root "ZW") have the code "001602".
includeOptions : A boolean value. 'true' if the symbol should include options and 'false' otherwise.
metricName : One of the metric names listed in this library's chart.
metricDirection : Direction of the metric, one of the following: "Long", "Short", "Spreading", "No direction".
metricType : Type of the metric. Possible values: "All", "Old", and "Other".
Returns: A ticker ID string usable with `request.security()` to fetch the specified Commitment of Traders data.
NumberOfVisibleBarsLibrary "NumberOfVisibleBars"
This library calculates the number of visible bars on the user screen
NumberOfVisibleBars(No)
Calculates the number of visible bars on the user screen
Parameters:
No : paramters needed
Returns: The numbers of visible bars on the user screen (int)
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
TradingWolfLibaryLibrary "TradingWolfLibary"
getMA(int, string)
Gets a Moving Average based on type
Parameters:
int : length The MA period
string : maType The type of MA
Returns: A moving average with the given parameters
minStop(float, simple, float, string)
Calculates and returns Minimum stop loss
Parameters:
float : entry price (Close if calculating on the entry candle)
simple : int Calculate how many bars back to look at swings
float : Minimum Stop Loss allowed (Should be x 0.01) if input
string : Direciton of trade either "Long" or "Short"
Returns: Stop Loss Value
intersectLibrary "intersect"
Find Line Intersection X/Y coordinates.
Simple to use, will find intersection if it exists on the segments
if the line segments do not cross on segment, an 'na' value will be returned
if you plot new items with the output coords, they still plot.
avoid this by setting a na(x) condition before plotting new items
get(l1, l2, ( optional _round) )
line intersection coordinates
Parameters:
l1 : (line) first line
l2 : (line) second line
_round : True to make an INT for plotting
if not used, will not round ( overload loophole)
Returns: with x as int if bool is used
Time_FilterLibrary "Time_Filter"
Time filters for trading strategies.
f_isInWeekDay(_timeZone, _byWeekDay, _byMon, _byTue, _byWed, _byThu, _byFri, _bySat, _bySun)
f_isInWeekDay - Filter by week day or by time delimited session.
Parameters:
_timeZone : - Time zone to use when filter allowed trading by days of the week.
_byWeekDay : - Filter allowed trading time by days of the week.
_byMon : - Is Monday a trading day?
_byTue : - Is Tuesday a trading day?
_byWed : - Is Wednesday a trading day?
_byThu : - Is Thursday a trading day?
_byFri : - Is Friday a trading day?
_bySat : - Is Saturday a trading day?
_bySun : - Is Sunday a trading day?
Returns: series of bool whether or not the time is inside the current day.
f_isInSession(_timeZone, _bySession_1, _timeSession_1, _bySession_2, _timeSession_2)
f_isInSession - Is the current time with in the allowed trading session time.
Parameters:
_timeZone : - Time zone to use when filter allowed trading by days of the week.
_bySession_1 : - Filter allowed trading time with in hours defined in _timeSession_1
_timeSession_1 : - Hours with in trading is allowed.
_bySession_2 : - Filter allowed trading time with in hours defined in _timeSession_2
_timeSession_2 : - Hours with in trading is allowed.
Returns: series of bool whether or not the time is inside selected session.
f_isTradingAllowed(_timeZone, _byWeekDay, _byMon, _byTue, _byWed, _byThu, _byFri, _bySat, _bySun, _bySession_1, _timeSession_1, _bySession_2, _timeSession_2)
f_isTradingAllowed - Is the current time with in the allowed.
Parameters:
_timeZone : - Time zone to use when filter allowed trading by days of the week.
_byWeekDay : - Filter allowed trading time by days of the week.
_byMon : - Is Monday a trading day?
_byTue : - Is Tuesday a trading day?
_byWed : - Is Wednesday a trading day?
_byThu : - Is Thursday a trading day?
_byFri : - Is Friday a trading day?
_bySat : - Is Saturday a trading day?
_bySun : - Is Sunday a trading day?
_bySession_1 : - Filter allowed trading time with in hours defined in _timeSession_1
_timeSession_1 : - Hours with in trading is allowed.
_bySession_2 : - Filter allowed trading time with in hours defined in _timeSession_2
_timeSession_2 : - Hours with in trading is allowed.
Returns: series of bool whether or not trading is allowed at the current time.
String to NumberA library that exposes a method to translate strings to numbers. Adapted from MichelT 's String to Number indicator.
na_skip_highestLibrary "na_skip_highest"
Finds the highest historic value over len bars but skip na valued bars (eg, off days). In other words, this will ensure we find the highest value over len bars with a real value, and if there are any na bars in-between, we skip over but the loop will continue. This allows to mimic calculations on markets with off days (eg, weekends).
na_skip_highest(src, len)
Finds the highest historic value over len bars but skip na valued bars (eg, off days). In other words, this will ensure we find the highest value over len bars with a real value, and if there are any na bars in-between, we skip over but the loop will continue. This allows to mimic calculations on markets with off days (eg, weekends).
Parameters:
src : series float source (eg, close)
len : int length, number of recent bars to consider in the window to find the highest value
Returns: highest float highest value found over the len window
KernelFunctionsLibrary "KernelFunctions"
This library provides non-repainting kernel functions for Nadaraya-Watson estimator implementations. This allows for easy substitution/comparison of different kernel functions for one another in indicators. Furthermore, kernels can easily be combined with other kernels to create newer, more customized kernels. Compared to Moving Averages (which are really just simple kernels themselves), these kernel functions are more adaptive and afford the user an unprecedented degree of customization and flexibility.
rationalQuadratic(_src, _lookback, _relativeWeight, _startAtBar)
Rational Quadratic Kernel - An infinite sum of Gaussian Kernels of different length scales.
Parameters:
_src : The source series.
_lookback : The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
_relativeWeight : Relative weighting of time frames. Smaller values result in a more stretched-out curve, and larger values will result in a more wiggly curve. As this value approaches zero, the longer time frames will exert more influence on the estimation. As this value approaches infinity, the behavior of the Rational Quadratic Kernel will become identical to the Gaussian kernel.
_startAtBar : Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
Returns: yhat The estimated values according to the Rational Quadratic Kernel.
gaussian(_src, _lookback, _startAtBar)
Gaussian Kernel - A weighted average of the source series. The weights are determined by the Radial Basis Function (RBF).
Parameters:
_src : The source series.
_lookback : The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
_startAtBar : Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
Returns: yhat The estimated values according to the Gaussian Kernel.
periodic(_src, _lookback, _period, _startAtBar)
Periodic Kernel - The periodic kernel (derived by David Mackay) allows one to model functions that repeat themselves exactly.
Parameters:
_src : The source series.
_lookback : The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
_period : The distance between repititions of the function.
_startAtBar : Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
Returns: yhat The estimated values according to the Periodic Kernel.
locallyPeriodic(_src, _lookback, _period, _startAtBar)
Locally Periodic Kernel - The locally periodic kernel is a periodic function that slowly varies with time. It is the product of the Periodic Kernel and the Gaussian Kernel.
Parameters:
_src : The source series.
_lookback : The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars.
_period : The distance between repititions of the function.
_startAtBar : Bar index on which to start regression. The first bars of a chart are often highly volatile, and omitting these initial bars often leads to a better overall fit.
Returns: yhat The estimated values according to the Locally Periodic Kernel.
inChart - LibLibrary "inChart"
determine if price value is between chart high + x% and low - x% on the visible chart.
inChart()
ahpuhelperLibrary "ahpuhelper"
Helper Library for Auto Harmonic Patterns UltimateX. It is not meaningful for others. This is supposed to be private library. But, publishing it to make sure that I don't delete accidentally. Some functions may be useful for coders.
insert_open_trades_table_column(showOpenTrades, table_id, column, colors, values, intStatus, harmonicTrailingStartState, lblSizeOpenTrades)
add data to open trades table column
Parameters:
showOpenTrades : flag to show open trades table
table_id : Table Id
column : refers to pattern data
colors : backgroud and text color array
values : cell values
intStatus : status as integer
harmonicTrailingStartState : trailing Start state as per configs
lblSizeOpenTrades : text size
Returns: nextColumn
populate_closed_stats(ClosedStatsPosition, bullishCounts, bearishCounts, bullishRetouchCounts, bearishRetouchCounts, bullishSizeMatrix, bearishSizeMatrix, bullishRR, bearishRR, allPatternLabels, flags, rowMain, rowHeaders)
populate closed stats for harmonic patterns
Parameters:
ClosedStatsPosition : Table position for closed stats
bullishCounts : Matrix containing bullish trade stats
bearishCounts : Matrix containing bearish trade stats
bullishRetouchCounts : Matrix containing bullish trade stats for those which retouched entry
bearishRetouchCounts : Matrix containing bearish trade stats for those which retouched entry
bullishSizeMatrix : Matrix containing data about size of bullish patterns
bearishSizeMatrix : Matrix containing data about size of bearish patterns
bullishRR : Matrix containing Risk Reward data of bullish patterns
bearishRR : Matrix containing Risk Reward data of bearish patterns
allPatternLabels : array containing pattern labels
flags : display flags
rowMain : Pattern header data
rowHeaders : header grouping data
Returns: void
get_rr_details(patternTradeDetails, harmonicTrailingStartState, disableTrail, breakEvenTrail)
calculate and return risk reward based on targets and stops
Parameters:
patternTradeDetails : array containing stop, entry and targets
harmonicTrailingStartState : trailing point
disableTrail : If set, ignores trailing point
breakEvenTrail : If set, trailing does not go beyond breakeven.
Returns: nextColumn
taLibrary "ta"
This library is a Pine Script™ programmer’s tool containing calcs for my oscillators and some helper functions.
buoyancy(src, targetPeriod, maxLookback)
Calculates buoyancy using a target of `src` summed over `targetPeriod` bars, not searching back farther than `maxLookback` bars. See:
Parameters:
src : (series float) The source value that is summed to constitute the target.
targetPeriod : (series int) The qty of bars to sum `src` for in order to calculate the target.
maxLookback : (simple int) The maximum number of bars back the function will search.
Returns: (series float) Buoyancy: the gap between the avg distance of past up and dn bars added to reach the target, divided by the max distance reached. Returns zero when an error condition occurs.
efficientWork(length)
Calculates Efficient Work on `length` bars. See:
Parameters:
length : (simple int) The length of the ALMA used to calculate the result.
Returns: (series float) A -1 to +1 value representing the efficiency of price travel, bar to bar.
ma(type, src, length)
Returns the `type` MA of the `src` over the `length`.
Parameters:
type : (simple string) The type of MA required (uses constants that must be defined earlier in the script).
src : (series float) The source value used to calculate the MA.
length : (simple int) The length value used to calculate the MA.
Returns: (series float) The MA value.
divergenceChannel(divergence, hiSrc, loSrc, breachHiSrc, breachLoSrc)
Calculates the levels and states of divergence channels, which are created when divergences occur.
Parameters:
divergence : (series bool) `true` on divergences, which can be defined any way. On breached channels it creates a new channel, otherwise, channel levels are expanded.
hiSrc : (series float) The price source used to set the channel's hi level when a divergence occurs.
loSrc : (series float) The price source used to set the channel's lo level when a divergence occurs.
breachHiSrc : (series float) The price source that must breach over the channel's `channelHi` level for a breach to occur.
breachLoSrc : (series float) The price source that must breach under the channel's `channelLo` level for a breach to occur.
Returns: A tuple containing the following values:
sourceStrToFloat(srcString)
Converts the name of a source in the `srcString` to its numerical equivalent.
Parameters:
srcString : (series string) The string representing the name of the source value to be returned.
Returns: (series float) The source's value.
fastlog2Library "fastlog2"
Description:
Returns the approximation of Log2 with the maximal error of: 0.000061011436
Reference:
www.anycodings.com
fastlog2(x)
Returns the approximation of Log2 with the maximal error of: 0.000061011436
Parameters:
x : float
Returns: float, log2 of x
EconomicCalendarLibrary "EconomicCalendar"
This library is a data provider for important dates and times from the Economic Calendar.
events()
Returns the list of dates supported by this library as a string array.
Returns: array : Names of events supported by this library
fomcMeetings()
Gets the FOMC Meeting Dates. The FOMC meets eight times a year to determine the course of monetary policy. The FOMC announces its decision on the federal funds rate at the conclusion of each meeting and also issues a statement that provides information on the economic outlook and the Committee's assessment of the risks to the outlook.
Returns: array : FOMC Meeting Dates as timestamps
fomcMinutes()
Gets the FOMC Meeting Minutes Dates. The FOMC Minutes are released three weeks after each FOMC meeting. The Minutes provide information on the Committee's deliberations and decisions at the meeting.
Returns: array : FOMC Meeting Minutes Dates as timestamps
ppiReleases()
Gets the Producer Price Index (PPI) Dates. The Producer Price Index (PPI) measures the average change over time in the selling prices received by domestic producers for their output. The PPI is a leading indicator of CPI, and CPI is a leading indicator of inflation.
Returns: array : PPI Dates as timestamps
cpiReleases()
Gets the Consumer Price Index (CPI) Rekease Dates. The Consumer Price Index (CPI) measures changes in the price level of a market basket of consumer goods and services purchased by households. The CPI is a leading indicator of inflation.
Returns: array : CPI Dates as timestamps
csiReleases()
Gets the CSI release dates. The Consumer Sentiment Index (CSI) is a survey of consumer attitudes about the economy and their personal finances. The CSI is a leading indicator of consumer spending.
Returns: array : CSI Dates as timestamps
cciReleases()
Gets the CCI release dates. The Conference Board's Consumer Confidence Index (CCI) is a survey of consumer attitudes about the economy and their personal finances. The CCI is a leading indicator of consumer spending.
Returns: array : CCI Dates as timestamps
nfpReleases()
Gets the NFP release dates. Nonfarm payrolls is an employment report released monthly by the Bureau of Labor Statistics (BLS) that measures the change in the number of employed people in the United States.
Returns: array : NFP Dates as timestamps