SPTS_StatsPakLibFinally getting around to releasing the library component to the SPTS indicator!
This library is packed with a ton of great statistics functions to supplement SPTS, these functions add to the capabilities of SPTS including a forecast function.
The library includes the following functions
1. Linear Regression (single independent and single dependent)
2. Multiple Regression (2 independent variables, 1 dependent)
3. Standard Error of Residual Assessment
4. Z-Score
5. Effect Size
6. Confidence Interval
7. Paired Sample Test
8. Two Tailed T-Test
9. Qualitative assessment of T-Test
10. T-test table and p value assigner
11. Correlation of two arrays
12. Quadratic correlation (curvlinear)
13. R Squared value of 2 arrays
14. R Squared value of 2 floats
15. Test of normality
16. Forecast function which will push the desired forecasted variables into an array.
One of the biggest added functionalities of this library is the forecasting function.
This function provides an autoregressive, trainable model that will export forecasted values to 3 arrays, one contains the autoregressed forecasted results, the other two contain the upper confidence forecast and the lower confidence forecast.
Hope you enjoy and find use for this!
Library "SPTS_StatsPakLib"
f_linear_regression(independent, dependent, len, variable)
TODO: creates a simple linear regression model between two variables.
Parameters:
independent (float)
dependent (float)
len (int)
variable (float)
Returns: TODO: returns 6 float variables
result: The result of the regression model
pear_cor: The pearson correlation of the regresion model
rsqrd: the R2 of the regression model
std_err: the error of residuals
slope: the slope of the model (coefficient)
intercept: the intercept of the model (y = mx + b is y = slope x + intercept)
f_multiple_regression(y, x1, x2, input1, input2, len)
TODO: creates a multiple regression model between two independent variables and 1 dependent variable.
Parameters:
y (float)
x1 (float)
x2 (float)
input1 (float)
input2 (float)
len (int)
Returns: TODO: returns 7 float variables
result: The result of the regression model
pear_cor: The pearson correlation of the regresion model
rsqrd: the R2 of the regression model
std_err: the error of residuals
b1 & b2: the slopes of the model (coefficients)
intercept: the intercept of the model (y = mx + b is y = b1 x + b2 x + intercept)
f_stanard_error(result, dependent, length)
x TODO: performs an assessment on the error of residuals, can be used with any variable in which there are residual values (such as moving averages or more comlpex models)
param x TODO: result is the output, for example, if you are calculating the residuals of a 200 EMA, the result would be the 200 EMA
dependent: is the dependent variable. In the above example with the 200 EMA, your dependent would be the source for your 200 EMA
Parameters:
result (float)
dependent (float)
length (int)
Returns: x TODO: the standard error of the residual, which can then be multiplied by standard deviations or used as is.
f_zscore(variable, length)
TODO: Calculates the z-score
Parameters:
variable (float)
length (int)
Returns: TODO: returns float z-score
f_effect_size(array1, array2)
TODO: Calculates the effect size between two arrays of equal scale.
Parameters:
array1 (float )
array2 (float )
Returns: TODO: returns the effect size (float)
f_confidence_interval(array1, array2, ci_input)
TODO: Calculates the confidence interval between two arrays
Parameters:
array1 (float )
array2 (float )
ci_input (float)
Returns: TODO: returns the upper_bound and lower_bound cofidence interval as float values
paired_sample_t(src1, src2, len)
TODO: Performs a paired sample t-test
Parameters:
src1 (float)
src2 (float)
len (int)
Returns: TODO: Returns the t-statistic and degrees of freedom of a paired sample t-test
two_tail_t_test(array1, array2)
TODO: Perofrms a two tailed t-test
Parameters:
array1 (float )
array2 (float )
Returns: TODO: Returns the t-statistic and degrees of freedom of a two_tail_t_test sample t-test
t_table_analysis(t_stat, df)
TODO: This is to make a qualitative assessment of your paired and single sample t-test
Parameters:
t_stat (float)
df (float)
Returns: TODO: the function will return 2 string variables and 1 colour variable. The 2 string variables indicate whether the results are significant or not and the colour will
output red for insigificant and green for significant
t_table_p_value(df, t_stat)
TODO: This performs a quantaitive assessment on your t-tests to determine the statistical significance p value
Parameters:
df (float)
t_stat (float)
Returns: TODO: The function will return 1 float variable, the p value of the t-test.
cor_of_array(array1, array2)
TODO: This performs a pearson correlation assessment of two arrays. They need to be of equal size!
Parameters:
array1 (float )
array2 (float )
Returns: TODO: The function will return the pearson correlation.
quadratic_correlation(src1, src2, len)
TODO: This performs a quadratic (curvlinear) pearson correlation between two values.
Parameters:
src1 (float)
src2 (float)
len (int)
Returns: TODO: The function will return the pearson correlation (quadratic based).
f_r2_array(array1, array2)
TODO: Calculates the r2 of two arrays
Parameters:
array1 (float )
array2 (float )
Returns: TODO: returns the R2 value
f_rsqrd(src1, src2, len)
TODO: Calculates the r2 of two float variables
Parameters:
src1 (float)
src2 (float)
len (int)
Returns: TODO: returns the R2 value
test_of_normality(array, src)
TODO: tests the normal distribution hypothesis
Parameters:
array (float )
src (float)
Returns: TODO: returns 4 variables, 2 float and 2 string
Skew: the skewness of the dataset
Kurt: the kurtosis of the dataset
dist = the distribution type (recognizes 7 different distribution types)
implication = a string assessment of the implication of the distribution (qualitative)
f_forecast(output, input, train_len, forecast_length, output_array, upper_array, lower_array)
TODO: This performs a simple forecast function on a single dependent variable. It will autoregress this based on the train time, to the desired length of output,
then it will push the forecasted values to 3 float arrays, one that contains the forecasted result, 1 that contains the Upper Confidence Result and one with the lower confidence
result.
Parameters:
output (float)
input (float)
train_len (int)
forecast_length (int)
output_array (float )
upper_array (float )
lower_array (float )
Returns: TODO: Will return 3 arrays, one with the forecasted results, one with the upper confidence results, and a final with the lower confidence results. Example is given below.
אינדיקטורים ואסטרטגיות
[Library] VAccThis is the library version of VAcc (Velocity & Acceleration), a momentum indicator published by Scott Cong in Stocks & Commodities V. 41:09 (8–15). It applies concepts from physics, namely velocity and acceleration, to financial markets. VAcc functions similarly to the popular MACD (Moving Average Convergence Divergence) indicator when using a longer lookback period, but produces more responsive results. With shorter periods, VAcc exhibits characteristics reminiscent of the stochastic oscillator.
The indicator version of this algorithm is linked below:
🟠 Algorithm
The average velocity over the past n periods is defined as
((C - C_n) / n + (C - C_{n-1}) / (n - 1) + … + (C - C_i) / i + (C - C_1) / 1) / n
At its core, the velocity is a weighted average of the rate of change over the past n periods.
The calculation of the acceleration follows a similar process, where it’s defined as
((V - V_n) / n + (V - V_{n - 1}) / (n - 1) + … + (V - V_i) / i + (V - V_1) / 1) / n
🟠 Comparison with MACD
A comparison of VAcc and MACD on the daily Nasdaq 100 (NDX) chart from August 2022 helps demonstrate VAcc's improved sensitivity. Both indicators utilized a lookback period of 26 days and smoothing of 9 periods.
The VAcc histogram clearly shows a divergence forming, with momentum weakening as prices reached new highs. In contrast, the corresponding MACD histogram significantly lagged in confirming the divergence, highlighting VAcc's ability to identify subtle shifts in trend momentum more immediately than the traditional MACD.
XLibrary "X"
a collection of 'special' methods/functions ('special' at the time of conception)
Initial functions includes:
• count of a given number in a given array
• array.get() but option added to use negative index
• sum of all digits until the output < 10
• slope/angle calculation of lines
method count_num_in_array(arr, num)
counts how many times a given number is present in a given array (0 when not present)
Namespace types: int
Parameters:
arr (int ) : Array (int, float )
num (int) : Number that needs to be counted (int, float)
Returns: count of number in array (0 when not present)
method count_num_in_array(arr, num)
Namespace types: float
Parameters:
arr (float )
num (float)
method get_(arr, idx)
array.get() but you can use negative index (-1 is last of array, -2 is second last,...)
Namespace types: int
Parameters:
arr (int ) : Array (int, float, string, bool, label, line, box, color )
idx (int) : Index
Returns: value/object at index, 'na' if index is outside array
method get_(arr, idx)
Namespace types: float
Parameters:
arr (float )
idx (int)
method get_(arr, idx)
Namespace types: string
Parameters:
arr (string )
idx (int)
method get_(arr, idx)
Namespace types: bool
Parameters:
arr (bool )
idx (int)
method get_(arr, idx)
Namespace types: label
Parameters:
arr (label )
idx (int)
method get_(arr, idx)
Namespace types: line
Parameters:
arr (line )
idx (int)
method get_(arr, idx)
Namespace types: box
Parameters:
arr (box )
idx (int)
method get_(arr, idx)
Namespace types: color
Parameters:
arr (color )
idx (int)
method sumAllNumbers_till_under_10(num)
sums all separate digit numbers, it repeats the process until sum < 10
Namespace types: series int, simple int, input int, const int
Parameters:
num (int) : Number (int, float)
Returns: value between 0 and 9
method sumAllNumbers_till_under_10(num)
Namespace types: series float, simple float, input float, const float
Parameters:
num (float)
method XYaxis(width)
Global function to calculate Yaxis, which is used in calculate_slope() method
Namespace types: series int, simple int, input int, const int
Parameters:
width (int) : Amount of bars for reference X-axis
Returns: Yaxis
method calculate_slope(width, XYratio, Yaxis, x1, y1, x2, y2)
Returns a normalised slope
Namespace types: series int, simple int, input int, const int
Parameters:
width (int) : Amount of bars to calculate height
XYratio (float) : Ratio to calculate height (from width) normalised_slope calculation
Yaxis (float) : Y-axis from XYaxis() method
x1 (int) : x1 of line
y1 (float) : y1 of line
x2 (int) : x2 of line
y2 (float) : y2 of line
Returns: Tuple of -> slope = price difference per bar
PineUnitPineUnit by Guardian667
A comprehensive testing framework for Pine Script on TradingView. Built with well-known testing paradigms like Assertions, Units and Suites. It offers the ability to log test results in TradingView's built-in Pine Protocol view, as well as displaying them in a compact table directly on your chart, ensuring your scripts are both robust and reliable.
Unit testing Pine Script indicators, libraries, and strategies becomes seamless, ensuring the precision and dependability of your TradingView scripts. Beyond standard function testing based on predefined input values, PineUnit supports series value testing. This means a test can run on every bar, taking into account its specific values. Moreover, you can specify the exact conditions under which a test should execute, allowing for series-based testing only on bars fitting a designated scenario.
Detailed Guide & Source Code
Quick Start
To get started swiftly with PineUnit, follow this minimalistic example.
import Guardian667/PineUnit/1 as PineUnit
var testSession = PineUnit.createTestSession()
var trueTest = testSession.createSimpleTest("True is always True")
trueTest.assertTrue(true)
testSession.report()
After running your script, you'll notice a table on your chart displaying the test results. For a detailed log output, you can also utilize the Pine Protocol view in TradingView.
--------------------------------------------------------------
T E S T S
--------------------------------------------------------------
Running Default Unit
Tests run: 1, Failures: 0, Not executed: 0, Skipped: 0
To further illustrate, let's introduce a test that's destined to fail:
var bullTest = testSession.createSeriesTest("It's allways Bull Market")
bullTest.assertTrue(close > open, "Uhoh... it's not always bullish")
After executing, the test results will reflect this intentional discrepancy:
--------------------------------------------------------------
T E S T S
--------------------------------------------------------------
Running Default Unit
Tests run: 2, Failures: 1, Not executed: 0, Skipped: 0 <<< FAILURE! - in
It's allways Bull Market
Uhoh... it's not always bullish ==> expected: , but was
This shows how PineUnit efficiently captures and reports discrepancies in test expectations.
It's important to recognise the difference between `createSimpleTest()` and `createSeriesTest()`. In contrast to a simple test, a series-based test is executed on each bar, making assertions on series values.
License
This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
@ Guardian667
A Personal Note
As a software developer experienced in OO-based languages, diving into Pine Script is a unique journey. While many aspects of it are smooth and efficient, there are also notable gaps, particularly in the realm of testing. We've all been there: using `plotchar()` for debugging, trying to pinpoint those elusive issues in our scripts. I've come to appreciate the value of writing tests, which often obviates the need for such debugging. My hope is that this Testing Framework serves you well and saves you a significant amount of time, more that I invested into developing this "baby."
mathLibrary "math"
TODO: Math custom MA and more
pine_ema(src, length)
Parameters:
src (float)
length (int)
pine_dema(src, length)
Parameters:
src (float)
length (int)
pine_tema(src, length)
Parameters:
src (float)
length (int)
pine_sma(src, length)
Parameters:
src (float)
length (int)
pine_smma(src, length)
Parameters:
src (float)
length (int)
pine_ssma(src, length)
Parameters:
src (float)
length (int)
pine_rma(src, length)
Parameters:
src (float)
length (int)
pine_wma(x, y)
Parameters:
x (float)
y (int)
pine_hma(src, length)
Parameters:
src (float)
length (int)
pine_vwma(x, y)
Parameters:
x (float)
y (int)
pine_swma(x)
Parameters:
x (float)
pine_alma(src, length, offset, sigma)
Parameters:
src (float)
length (int)
offset (float)
sigma (float)
ZigLibLibrary "ZigLib"
Calculate the points for ZigZag++.
You can use custom data and resolution for your ZigZag++.
Sample Usage
import DevLucem/ZigLib/1 as ZigZag
= ZigZag.zigzag(low, high)
bgcolor(direction<0? color.rgb(255, 82, 82, 80): color.rgb(0, 230, 119, 80))
line zz = line.new(z1.time, z1.price, z2.time, z2.price, xloc.bar_time, width=3)
if direction==direction
line.delete(zz )
zigzag(_low, _high, depth, deviation, backstep)
Get current zigzag points and direction
Parameters:
_low (float)
_high (float)
depth (int)
deviation (int)
backstep (int)
Returns direction, chart point 1 and chart point 2
MTF_DrawingsLibrary 'MTF_Drawings'
This library helps with drawing indicators and candle charts on all timeframes.
FEATURES
CHART DRAWING : Library provides functions for drawing High Time Frame (HTF) and Low Time Frame (LTF) candles.
INDICATOR DRAWING : Library provides functions for drawing various types of HTF and LTF indicators.
CUSTOM COLOR DRAWING : Library allows to color candles and indicators based on specific conditions.
LINEFILLS : Library provides functions for drawing linefills.
CATEGORIES
The functions are named in a way that indicates they purpose:
{Ind} : Function is meant only for indicators.
{Hist} : Function is meant only for histograms.
{Candle} : Function is meant only for candles.
{Draw} : Function draws indicators, histograms and candle charts.
{Populate} : Function generates necessary arrays required by drawing functions.
{LTF} : Function is meant only for lower timeframes.
{HTF} : Function is meant only for higher timeframes.
{D} : Function draws indicators that are composed of two lines.
{CC} : Function draws custom colored indicators.
USAGE
Import the library into your script.
Before using any {Draw} function it is necessary to use a {Populate} function.
Choose the appropriate one based on the category, provide the necessary arguments, and then use the {Draw} function, forwarding the arrays generated by the {Populate} function.
This doesn't apply to {Draw_Lines}, {LineFill}, or {Barcolor} functions.
EXAMPLE
import Spacex_trader/MTF_Drawings/1 as tf
//Request lower timeframe data.
Security(simple string Ticker, simple string New_LTF, float Ind) =>
float Value = request.security_lower_tf(Ticker, New_LTF, Ind)
Value
Timeframe = input.timeframe('1', 'Timeframe: ')
tf.Draw_Ind(tf.Populate_LTF_Ind(Security(syminfo.tickerid, Timeframe, ta.rsi(close, 14)), 498, color.purple), 1, true)
FUNCTION LIST
HTF_Candle(BarsBack, BodyBear, BodyBull, BordersBear, BordersBull, WickBear, WickBull, LineStyle, BoxStyle, LineWidth, HTF_Open, HTF_High, HTF_Low, HTF_Close, HTF_Bar_Index)
Populates two arrays with drawing data of the HTF candles.
Parameters:
BarsBack (int) : Bars number to display.
BodyBear (color) : Candle body bear color.
BodyBull (color) : Candle body bull color.
BordersBear (color) : Candle border bear color.
BordersBull (color) : Candle border bull color.
WickBear (color) : Candle wick bear color.
WickBull (color) : Candle wick bull color.
LineStyle (string) : Wick style (Solid-Dotted-Dashed).
BoxStyle (string) : Border style (Solid-Dotted-Dashed).
LineWidth (int) : Wick width.
HTF_Open (float) : HTF open price.
HTF_High (float) : HTF high price.
HTF_Low (float) : HTF low price.
HTF_Close (float) : HTF close price.
HTF_Bar_Index (int) : HTF bar_index.
Returns: Two arrays with drawing data of the HTF candles.
LTF_Candle(BarsBack, BodyBear, BodyBull, BordersBear, BordersBull, WickBear, WickBull, LineStyle, BoxStyle, LineWidth, LTF_Open, LTF_High, LTF_Low, LTF_Close)
Populates two arrays with drawing data of the LTF candles.
Parameters:
BarsBack (int) : Bars number to display.
BodyBear (color) : Candle body bear color.
BodyBull (color) : Candle body bull color.
BordersBear (color) : Candle border bear color.
BordersBull (color) : Candle border bull color.
WickBear (color) : Candle wick bear color.
WickBull (color) : Candle wick bull color.
LineStyle (string) : Wick style (Solid-Dotted-Dashed).
BoxStyle (string) : Border style (Solid-Dotted-Dashed).
LineWidth (int) : Wick width.
LTF_Open (float ) : LTF open price.
LTF_High (float ) : LTF high price.
LTF_Low (float ) : LTF low price.
LTF_Close (float ) : LTF close price.
Returns: Two arrays with drawing data of the LTF candles.
Draw_Candle(Box, Line, Offset)
Draws HTF or LTF candles.
Parameters:
Box (box ) : Box array with drawing data.
Line (line ) : Line array with drawing data.
Offset (int) : Offset of the candles.
Returns: Drawing of the candles.
Populate_HTF_Ind(IndValue, BarsBack, IndColor, HTF_Bar_Index)
Populates one array with drawing data of the HTF indicator.
Parameters:
IndValue (float) : Indicator value.
BarsBack (int) : Indicator lines to display.
IndColor (color) : Indicator color.
HTF_Bar_Index (int) : HTF bar_index.
Returns: An array with drawing data of the HTF indicator.
Populate_LTF_Ind(IndValue, BarsBack, IndColor)
Populates one array with drawing data of the LTF indicator.
Parameters:
IndValue (float ) : Indicator value.
BarsBack (int) : Indicator lines to display.
IndColor (color) : Indicator color.
Returns: An array with drawing data of the LTF indicator.
Draw_Ind(Line, Mult, Exe)
Draws one HTF or LTF indicator.
Parameters:
Line (line ) : Line array with drawing data.
Mult (int) : Coordinates multiplier.
Exe (bool) : Display the indicator.
Returns: Drawing of the indicator.
Populate_HTF_Ind_D(IndValue_1, IndValue_2, BarsBack, IndColor_1, IndColor_2, HTF_Bar_Index)
Populates two arrays with drawing data of the HTF indicators.
Parameters:
IndValue_1 (float) : First indicator value.
IndValue_2 (float) : Second indicator value.
BarsBack (int) : Indicator lines to display.
IndColor_1 (color) : First indicator color.
IndColor_2 (color) : Second indicator color.
HTF_Bar_Index (int) : HTF bar_index.
Returns: Two arrays with drawing data of the HTF indicators.
Populate_LTF_Ind_D(IndValue_1, IndValue_2, BarsBack, IndColor_1, IndColor_2)
Populates two arrays with drawing data of the LTF indicators.
Parameters:
IndValue_1 (float ) : First indicator value.
IndValue_2 (float ) : Second indicator value.
BarsBack (int) : Indicator lines to display.
IndColor_1 (color) : First indicator color.
IndColor_2 (color) : Second indicator color.
Returns: Two arrays with drawing data of the LTF indicators.
Draw_Ind_D(Line_1, Line_2, Mult, Exe_1, Exe_2)
Draws two LTF or HTF indicators.
Parameters:
Line_1 (line ) : First line array with drawing data.
Line_2 (line ) : Second line array with drawing data.
Mult (int) : Coordinates multiplier.
Exe_1 (bool) : Display the first indicator.
Exe_2 (bool) : Display the second indicator.
Returns: Drawings of the indicators.
Barcolor(Box, Line, BarColor)
Colors the candles based on indicators output.
Parameters:
Box (box ) : Candle box array.
Line (line ) : Candle line array.
BarColor (color ) : Indicator color array.
Returns: Colored candles.
Populate_HTF_Ind_D_CC(IndValue_1, IndValue_2, BarsBack, BullColor, BearColor, IndColor_1, HTF_Bar_Index)
Populates two array with drawing data of the HTF indicators with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
Parameters:
IndValue_1 (float) : First indicator value.
IndValue_2 (float) : Second indicator value.
BarsBack (int) : Indicator lines to display.
BullColor (color) : Bull color.
BearColor (color) : Bear color.
IndColor_1 (color) : First indicator color.
HTF_Bar_Index (int) : HTF bar_index.
Returns: Three arrays with drawing and color data of the HTF indicators.
Populate_LTF_Ind_D_CC(IndValue_1, IndValue_2, BarsBack, BullColor, BearColor, IndColor_1)
Populates two arrays with drawing data of the LTF indicators with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
Parameters:
IndValue_1 (float ) : First indicator value.
IndValue_2 (float ) : Second indicator value.
BarsBack (int) : Indicator lines to display.
BullColor (color) : Bull color.
BearColor (color) : Bearcolor.
IndColor_1 (color) : First indicator color.
Returns: Three arrays with drawing and color data of the LTF indicators.
Populate_HTF_Hist_CC(HistValue, IndValue_1, IndValue_2, BarsBack, BullColor, BearColor, HTF_Bar_Index)
Populates one array with drawing data of the HTF histogram with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
Parameters:
HistValue (float) : Indicator value.
IndValue_1 (float) : First indicator value.
IndValue_2 (float) : Second indicator value.
BarsBack (int) : Indicator lines to display.
BullColor (color) : Bull color.
BearColor (color) : Bearcolor.
HTF_Bar_Index (int) : HTF bar_index
Returns: Two arrays with drawing and color data of the HTF histogram.
Populate_LTF_Hist_CC(HistValue, IndValue_1, IndValue_2, BarsBack, BullColor, BearColor)
Populates one array with drawing data of the LTF histogram with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
Parameters:
HistValue (float ) : Indicator value.
IndValue_1 (float ) : First indicator value.
IndValue_2 (float ) : Second indicator value.
BarsBack (int) : Indicator lines to display.
BullColor (color) : Bull color.
BearColor (color) : Bearcolor.
Returns: Two array with drawing and color data of the LTF histogram.
Populate_LTF_Hist_CC_VA(HistValue, Value, BarsBack, BullColor, BearColor)
Populates one array with drawing data of the LTF histogram with color based on: HistValue >= Value ? BullColor : BearColor.
Parameters:
HistValue (float ) : Indicator value.
Value (float) : First indicator value.
BarsBack (int) : Indicator lines to display.
BullColor (color) : Bull color.
BearColor (color) : Bearcolor.
Returns: Two array with drawing and color data of the LTF histogram.
Populate_HTF_Ind_CC(IndValue, IndValue_1, BarsBack, BullColor, BearColor, HTF_Bar_Index)
Populates one array with drawing data of the HTF indicator with color based on: IndValue >= IndValue_1 ? BullColor : BearColor.
Parameters:
IndValue (float) : Indicator value.
IndValue_1 (float) : Second indicator value.
BarsBack (int) : Indicator lines to display.
BullColor (color) : Bull color.
BearColor (color) : Bearcolor.
HTF_Bar_Index (int) : HTF bar_index
Returns: Two arrays with drawing and color data of the HTF indicator.
Populate_LTF_Ind_CC(IndValue, IndValue_1, BarsBack, BullColor, BearColor)
Populates one array with drawing data of the LTF indicator with color based on: IndValue >= IndValue_1 ? BullColor : BearColor.
Parameters:
IndValue (float ) : Indicator value.
IndValue_1 (float ) : Second indicator value.
BarsBack (int) : Indicator lines to display.
BullColor (color) : Bull color.
BearColor (color) : Bearcolor.
Returns: Two arrays with drawing and color data of the LTF indicator.
Draw_Lines(BarsBack, y1, y2, LineType, Fill)
Draws price lines on indicators.
Parameters:
BarsBack (int) : Indicator lines to display.
y1 (float) : Coordinates of the first line.
y2 (float) : Coordinates of the second line.
LineType (string) : Line type.
Fill (color) : Fill color.
Returns: Drawing of the lines.
LineFill(Upper, Lower, BarsBack, FillColor)
Fills two lines with linefill HTF or LTF.
Parameters:
Upper (line ) : Upper line.
Lower (line ) : Lower line.
BarsBack (int) : Indicator lines to display.
FillColor (color) : Fill color.
Returns: Linefill of the lines.
Populate_LTF_Hist(HistValue, BarsBack, HistColor)
Populates one array with drawing data of the LTF histogram.
Parameters:
HistValue (float ) : Indicator value.
BarsBack (int) : Indicator lines to display.
HistColor (color) : Indicator color.
Returns: One array with drawing data of the LTF histogram.
Populate_HTF_Hist(HistValue, BarsBack, HistColor, HTF_Bar_Index)
Populates one array with drawing data of the HTF histogram.
Parameters:
HistValue (float) : Indicator value.
BarsBack (int) : Indicator lines to display.
HistColor (color) : Indicator color.
HTF_Bar_Index (int) : HTF bar_index.
Returns: One array with drawing data of the HTF histogram.
Draw_Hist(Box, Mult, Exe)
Draws HTF or LTF histogram.
Parameters:
Box (box ) : Box Array.
Mult (int) : Coordinates multiplier.
Exe (bool) : Display the histogram.
Returns: Drawing of the histogram.
lib_retracement_patternsLibrary "lib_retracement_patterns"
types and functions for XABCD pattern detection and plotting
method set_tolerances(this, tolerance_Bmin, tolerance_Bmax, tolerance_Cmin, tolerance_Cmax, tolerance_Dmin, tolerance_Dmax)
sets tolerances for B, C and D retracements. This creates another Pattern instance that is set as tolerances field on the original and will be used for detection instead of the original ratios.
Namespace types: Pattern
create_config(pattern_line_args, pattern_point_args, name_label_args, retracement_line_args, retracement_label_args, line_args_Dtarget, line_args_completion, line_args_tp1, line_args_tp2, line_args_sl, label_args_completion, label_args_tp1, label_args_tp2, label_args_sl, label_terminal, label_terminal_up_char, label_terminal_down_char, color_bull, color_bear, color_muted, fill_opacity, draw_point_labels, draw_retracements, draw_target_range, draw_levels, hide_shorter_if_shared_legs_greater_than_max, hide_engulfed_pattern, hide_engulfed_pattern_of_same_type, hide_longer_pattern_with_same_X, mute_previous_pattern_when_next_overlaps, keep_failed_patterns)
method direction(this)
Namespace types: Match
method length(this)
return the length of this pattern, determined by the distance between X and D point
Namespace types: Match
method height(this)
return the height of this pattern, determined by the distance between the biggest distance between A/C and X/D
Namespace types: Match
method is_forming(this)
returns true if not complete, not expired and not invalidated
Namespace types: Match
method tostring(this)
return a string representation of all Matches in this map
Namespace types: Match
method tostring(this)
Namespace types: map
remove_complete_and_expired(this)
method add(this, item)
Namespace types: map
method is_engulfed_by(this, other)
checks if this Match is engulfed by the other
Namespace types: Match
method update(tracking_matches, zigzag, patterns, max_age_idx, detect_dir, pattern_minlen, pattern_maxlen, max_sub_waves, max_shared_legs, max_XB_BD_ratio, debug_log)
checks this map of tracking Matches if any of them was completed or invalidated in
Namespace types: map
method mute(this, mute_color, mute_fill_color)
mute this pattern by making it all one color (lines and labels, for pattern fill there's another)
Namespace types: Match
method mute(this, mute_color, mute_fill_color)
mute all patterns in this map by making it all one color (lines and labels, for pattern fill there's another)
Namespace types: map
method hide(this)
hide this pattern by muting it with a transparent color
Namespace types: Match
method reset_styles(this)
reset the style of a muted or hidden match back to the preset configuration
Namespace types: Match
method delete(this)
remove the plot of this Match from the chart
Namespace types: Match
method delete(this)
remove all the plots of the Matches in this map from the chart
Namespace types: map
method draw(this)
draw this Match on the chart
Namespace types: Match
method draw(this, config, all_patterns, debug_log)
draw all Matches in this map, considering all other patterns for engulfing and overlapping
Namespace types: map
method check_hide_or_mute(this, all, config, debug_log)
checks if this pattern needs to be hidden or muted based on other plotted patterns and given configuration
Namespace types: Match
method add_if(id, item, condition)
convenience function to add a search pattern to a list, only if given condition (input.bool) is true
Namespace types: Pattern
Pattern
type to hold retracement ratios and tolerances for this pattern, as well as targets for trades
Config
allows control of pattern plotting shape and colors, as well as settings for hiding overlapped patterns etc.
Match
holds all information on a Pattern and a successful match in the chart. Includes XABCD pivot points as well as all Line and Label objects to draw it
AGbayLIBLibrary "AGbayLIB"
Changes the timeframe period to the given period and returns the data matrix and sets the timeframe to the active time period
getTimeFrameValues(active_period_, period_, max_bars_)
: add function description here
Parameters:
active_period_ (string) : Current time frame period to be set after getting period_ data
period_ (string) : Target time period for returning data
max_bars_ (int) : The historical bar count to be get
Returns: An array of data_row type with size of max_bars_ which includes rows of data:
data_row
Fields:
year (series__integer)
month (series__integer)
day (series__integer)
hour (series__integer)
minute (series__integer)
second (series__integer)
fulltime (series__string)
open (series__float)
close (series__float)
high (series__float)
low (series__float)
volume (series__float)
EphemerisLibrary "Ephemeris"
TODO: add library description here
mercuryElements()
mercuryRates()
venusElements()
venusRates()
earthElements()
earthRates()
marsElements()
marsRates()
jupiterElements()
jupiterRates()
saturnElements()
saturnRates()
uranusElements()
uranusRates()
neptuneElements()
neptuneRates()
rev360(x)
Normalize degrees to within [0, 360)
Parameters:
x (float) : degrees to be normalized
Returns: Normalized degrees
scaleAngle(longitude, magnitude, harmonic)
Scale angle in degrees
Parameters:
longitude (float)
magnitude (float)
harmonic (int)
Returns: Scaled angle in degrees
julianCenturyInJulianDays()
Constant Julian days per century
Returns: 36525
julianEpochJ2000()
Julian date on J2000 epoch start (2000-01-01)
Returns: 2451545.0
meanObliquityForJ2000()
Mean obliquity of the ecliptic on J2000 epoch start (2000-01-01)
Returns: 23.43928
getJulianDate(Year, Month, Day, Hour, Minute)
Convert calendar date to Julian date
Parameters:
Year (int) : calendar year as integer (e.g. 2018)
Month (int) : calendar month (January = 1, December = 12)
Day (int) : calendar day of month (e.g. January valid days are 1-31)
Hour (int) : valid values 0-23
Minute (int) : valid values 0-60
julianCenturies(date, epoch_start)
Centuries since Julian Epoch 2000-01-01
Parameters:
date (float) : Julian date to conver to Julian centuries
epoch_start (float) : Julian date of epoch start (e.g. J2000 epoch = 2451545)
Returns: Julian date converted to Julian centuries
julianCenturiesSinceEpochJ2000(julianDate)
Calculate Julian centuries since epoch J2000 (2000-01-01)
Parameters:
julianDate (float) : Julian Date in days
Returns: Julian centuries since epoch J2000 (2000-01-01)
atan2(y, x)
Specialized arctan function
Parameters:
y (float) : radians
x (float) : radians
Returns: special arctan of y/x
eccAnom(ec, m_param, dp)
Compute eccentricity of the anomaly
Parameters:
ec (float) : Eccentricity of Orbit
m_param (float) : Mean Anomaly ?
dp (int) : Decimal places to round to
Returns: Eccentricity of the Anomaly
planetEphemerisCalc(TGen, planetElementId, planetRatesId)
Compute planetary ephemeris (longtude relative to Earth or Sun) on a Julian date
Parameters:
TGen (float) : Julian Date
planetElementId (float ) : All planet orbital elements in an array. This index references a specific planet's elements.
planetRatesId (float ) : All planet orbital rates in an array. This index references a specific planet's rates.
Returns: X,Y,Z ecliptic rectangular coordinates and R radius from reference body.
calculateRightAscensionAndDeclination(earthX, earthY, earthZ, planetX, planetY, planetZ)
Calculate right ascension and declination for a planet relative to Earth
Parameters:
earthX (float) : Earth X ecliptic rectangular coordinate relative to Sun
earthY (float) : Earth Y ecliptic rectangular coordinate relative to Sun
earthZ (float) : Earth Z ecliptic rectangular coordinate relative to Sun
planetX (float) : Planet X ecliptic rectangular coordinate relative to Sun
planetY (float) : Planet Y ecliptic rectangular coordinate relative to Sun
planetZ (float) : Planet Z ecliptic rectangular coordinate relative to Sun
Returns: Planet geocentric orbital radius, geocentric right ascension, and geocentric declination
mercuryHelio(T)
Compute Mercury heliocentric longitude on date
Parameters:
T (float)
Returns: Mercury heliocentric longitude on date
venusHelio(T)
Compute Venus heliocentric longitude on date
Parameters:
T (float)
Returns: Venus heliocentric longitude on date
earthHelio(T)
Compute Earth heliocentric longitude on date
Parameters:
T (float)
Returns: Earth heliocentric longitude on date
marsHelio(T)
Compute Mars heliocentric longitude on date
Parameters:
T (float)
Returns: Mars heliocentric longitude on date
jupiterHelio(T)
Compute Jupiter heliocentric longitude on date
Parameters:
T (float)
Returns: Jupiter heliocentric longitude on date
saturnHelio(T)
Compute Saturn heliocentric longitude on date
Parameters:
T (float)
Returns: Saturn heliocentric longitude on date
neptuneHelio(T)
Compute Neptune heliocentric longitude on date
Parameters:
T (float)
Returns: Neptune heliocentric longitude on date
uranusHelio(T)
Compute Uranus heliocentric longitude on date
Parameters:
T (float)
Returns: Uranus heliocentric longitude on date
sunGeo(T)
Parameters:
T (float)
mercuryGeo(T)
Parameters:
T (float)
venusGeo(T)
Parameters:
T (float)
marsGeo(T)
Parameters:
T (float)
jupiterGeo(T)
Parameters:
T (float)
saturnGeo(T)
Parameters:
T (float)
neptuneGeo(T)
Parameters:
T (float)
uranusGeo(T)
Parameters:
T (float)
moonGeo(T_JD)
Parameters:
T_JD (float)
mercuryOrbitalPeriod()
Mercury orbital period in Earth days
Returns: 87.9691
venusOrbitalPeriod()
Venus orbital period in Earth days
Returns: 224.701
earthOrbitalPeriod()
Earth orbital period in Earth days
Returns: 365.256363004
marsOrbitalPeriod()
Mars orbital period in Earth days
Returns: 686.980
jupiterOrbitalPeriod()
Jupiter orbital period in Earth days
Returns: 4332.59
saturnOrbitalPeriod()
Saturn orbital period in Earth days
Returns: 10759.22
uranusOrbitalPeriod()
Uranus orbital period in Earth days
Returns: 30688.5
neptuneOrbitalPeriod()
Neptune orbital period in Earth days
Returns: 60195.0
jupiterSaturnCompositePeriod()
jupiterNeptuneCompositePeriod()
jupiterUranusCompositePeriod()
saturnNeptuneCompositePeriod()
saturnUranusCompositePeriod()
planetSineWave(julianDateInCenturies, planetOrbitalPeriod, planetHelio)
Convert heliocentric longitude of planet into a sine wave
Parameters:
julianDateInCenturies (float)
planetOrbitalPeriod (float) : Orbital period of planet in Earth days
planetHelio (float) : Heliocentric longitude of planet in degrees
Returns: Sine of heliocentric longitude on a Julian date
lib_plot_composite_objectsLibrary "lib_plot_composite_objects"
library building on top of lib_plot_objects for composite objects such as Triangles and Polygons. heavily using chart.points
method tostring(this, date_format)
Namespace types: Triangle
Parameters:
this (Triangle)
date_format (simple string)
method tostring(this, date_format)
Namespace types: TriangleFill
Parameters:
this (TriangleFill)
date_format (simple string)
method tostring(this, date_format)
Namespace types: Polygon
Parameters:
this (Polygon)
date_format (simple string)
method tostring(this, date_format)
Namespace types: PolygonFill
Parameters:
this (PolygonFill)
date_format (simple string)
method tostring(this, date_format)
Namespace types: Triangle
Parameters:
this (Triangle )
date_format (simple string)
method tostring(this, date_format)
Namespace types: Polygon
Parameters:
this (Polygon )
date_format (simple string)
method tostring(this, date_format)
Namespace types: TriangleFill
Parameters:
this (TriangleFill )
date_format (simple string)
method tostring(this, date_format)
Namespace types: PolygonFill
Parameters:
this (PolygonFill )
date_format (simple string)
method create_triangle(this, b, c, args)
Namespace types: chart.point
Parameters:
this (chart.point)
b (chart.point)
c (chart.point)
args (LineArgs type from robbatt/lib_plot_objects/32)
method create_triangle(this, c)
Namespace types: D.Line
Parameters:
this (Line type from robbatt/lib_plot_objects/32)
c (chart.point)
method create_polygon(points, args)
Namespace types: chart.point
Parameters:
points (chart.point )
args (LineArgs type from robbatt/lib_plot_objects/32)
method create_polygon(start, others, args)
Namespace types: chart.point
Parameters:
start (chart.point)
others (chart.point )
args (LineArgs type from robbatt/lib_plot_objects/32)
method create_fill(this, fill_color)
Namespace types: Triangle
Parameters:
this (Triangle)
fill_color (color)
method create_fill(this, fill_color)
Namespace types: Polygon
Parameters:
this (Polygon)
fill_color (color)
method create_center_label(this, txt, args, tooltip)
Namespace types: Triangle
Parameters:
this (Triangle)
txt (string)
args (LabelArgs type from robbatt/lib_plot_objects/32)
tooltip (string)
method create_label(this, txt, args, tooltip)
Namespace types: Polygon
Parameters:
this (Polygon)
txt (string)
args (LabelArgs type from robbatt/lib_plot_objects/32)
tooltip (string)
method nz(this, default)
Namespace types: Triangle
Parameters:
this (Triangle)
default (Triangle)
method nz(this, default)
Namespace types: TriangleFill
Parameters:
this (TriangleFill)
default (TriangleFill)
method nz(this, default)
Namespace types: Polygon
Parameters:
this (Polygon)
default (Polygon)
method nz(this, default)
Namespace types: PolygonFill
Parameters:
this (PolygonFill)
default (PolygonFill)
method enqueue(id, item, max)
Namespace types: Triangle
Parameters:
id (Triangle )
item (Triangle)
max (int)
method enqueue(id, item, max)
Namespace types: Polygon
Parameters:
id (Polygon )
item (Polygon)
max (int)
method enqueue(id, item, max)
Namespace types: TriangleFill
Parameters:
id (TriangleFill )
item (TriangleFill)
max (int)
method enqueue(id, item, max)
Namespace types: PolygonFill
Parameters:
id (PolygonFill )
item (PolygonFill)
max (int)
method update(this, a, b, c)
Namespace types: Triangle
Parameters:
this (Triangle)
a (chart.point)
b (chart.point)
c (chart.point)
method update(this, points)
Namespace types: Polygon
Parameters:
this (Polygon)
points (chart.point )
method delete(this)
Namespace types: Triangle
Parameters:
this (Triangle)
method delete(this)
Namespace types: TriangleFill
Parameters:
this (TriangleFill)
method delete(this)
Namespace types: Polygon
Parameters:
this (Polygon)
method delete(this)
Namespace types: PolygonFill
Parameters:
this (PolygonFill)
method delete(this)
Namespace types: Triangle
Parameters:
this (Triangle )
method delete(this)
Namespace types: TriangleFill
Parameters:
this (TriangleFill )
method delete(this)
Namespace types: Polygon
Parameters:
this (Polygon )
method delete(this)
Namespace types: PolygonFill
Parameters:
this (PolygonFill )
method draw(this, ab_args_override, ac_args_override, bc_args_override)
Namespace types: Triangle
Parameters:
this (Triangle)
ab_args_override (LineArgs type from robbatt/lib_plot_objects/32)
ac_args_override (LineArgs type from robbatt/lib_plot_objects/32)
bc_args_override (LineArgs type from robbatt/lib_plot_objects/32)
method draw(this)
Namespace types: Polygon
Parameters:
this (Polygon)
method draw(this)
Namespace types: TriangleFill
Parameters:
this (TriangleFill)
method draw(this)
Namespace types: PolygonFill
Parameters:
this (PolygonFill)
method draw(this)
Namespace types: Triangle
Parameters:
this (Triangle )
method draw(this)
Namespace types: TriangleFill
Parameters:
this (TriangleFill )
method draw(this)
Namespace types: Polygon
Parameters:
this (Polygon )
method draw(this)
Namespace types: PolygonFill
Parameters:
this (PolygonFill )
method apply_style(this, args)
Namespace types: Triangle
Parameters:
this (Triangle)
args (LineArgs type from robbatt/lib_plot_objects/32)
method apply_style(this, args)
Namespace types: Polygon
Parameters:
this (Polygon)
args (LineArgs type from robbatt/lib_plot_objects/32)
method apply_style(this, args)
Namespace types: Triangle
Parameters:
this (Triangle )
args (LineArgs type from robbatt/lib_plot_objects/32)
method apply_style(this, args)
Namespace types: Polygon
Parameters:
this (Polygon )
args (LineArgs type from robbatt/lib_plot_objects/32)
Triangle
Fields:
a (chart.point) : first Corner
b (chart.point) : second Corner
c (chart.point) : third Corner
args (LineArgs type from robbatt/lib_plot_objects/32) : Wrapper for reusable arguments for line.new()
ab (Line type from robbatt/lib_plot_objects/32)
ac (Line type from robbatt/lib_plot_objects/32)
bc (Line type from robbatt/lib_plot_objects/32)
TriangleFill
Fields:
triangle (Triangle) : The Triangle object
plot (LineFill type from robbatt/lib_plot_objects/32) : The linefill object to be added and plotted via draw()
Polygon
Fields:
points (chart.point ) : array of points that make up the Polygon
center (chart.point) : Center point of the Polygon, can be used for a label and will be center for PolygonFill
args (LineArgs type from robbatt/lib_plot_objects/32) : Wrapper for reusable arguments for line.new()
plot (Line type from robbatt/lib_plot_objects/32) : An array of Lines that form Polygon Border
PolygonFill
Fields:
poly (Polygon) : the Polygon
fill_color (series color) : The color used to fill the space between the lines.
plot (TriangleFill )
WIPFunctionLyaponovLibrary "WIPFunctionLyaponov"
Lyapunov exponents are mathematical measures used to describe the behavior of a system over
time. They are named after Russian mathematician Alexei Lyapunov, who first introduced the concept in the
late 19th century. The exponent is defined as the rate at which a particular function or variable changes
over time, and can be positive, negative, or zero.
Positive exponents indicate that a system tends to grow or expand over time, while negative exponents
indicate that a system tends to shrink or decay. Zero exponents indicate that the system does not change
significantly over time. Lyapunov exponents are used in various fields of science and engineering, including
physics, economics, and biology, to study the long-term behavior of complex systems.
~ generated description from vicuna13b
---
To calculate the Lyapunov Exponent (LE) of a given Time Series, we need to follow these steps:
1. Firstly, you should have access to your data in some format like CSV or Excel file. If not, then you can collect it manually using tools such as stopwatches and measuring tapes.
2. Once the data is collected, clean it up by removing any outliers that may skew results. This step involves checking for inconsistencies within your dataset (e.g., extremely large or small values) and either discarding them entirely or replacing with more reasonable estimates based on surrounding values.
3. Next, you need to determine the dimension of your time series data. In most cases, this will be equal to the number of variables being measured in each observation period (e.g., temperature, humidity, wind speed).
4. Now that we have a clean dataset with known dimensions, we can calculate the LE for our Time Series using the following formula:
λ = log(||M^T * M - I||)/log(||v||)
where:
λ (Lyapunov Exponent) is the quantity that will be calculated.
||...|| denotes an Euclidean norm of a vector or matrix, which essentially means taking the square root of the sum of squares for each element in the vector/matrix.
M represents our Jacobian Matrix whose elements are given by:
J_ij = (∂fj / ∂xj) where fj is the jth variable and xj is the ith component of the initial condition vector x(t). In other words, each element in this matrix represents how much a small change in one variable affects another.
I denotes an identity matrix whose elements are all equal to 1 (or any constant value if you prefer). This term essentially acts as a baseline for comparison purposes since we want our Jacobian Matrix M^T * M to be close to it when the system is stable and far away from it when the system is unstable.
v represents an arbitrary vector whose Euclidean norm ||v|| will serve as a scaling factor in our calculation. The choice of this particular vector does not matter since we are only interested in its magnitude (i.e., length) for purposes of normalization. However, if you want to ensure that your results are accurate and consistent across different datasets or scenarios, it is recommended to use the same initial condition vector x(t) as used earlier when calculating our Jacobian Matrix M.
5. Finally, once we have calculated λ using the formula above, we can interpret its value in terms of stability/instability for our Time Series data:
- If λ < 0, then this indicates that the system is stable (i.e., nearby trajectories will converge towards each other over time).
- On the other hand, if λ > 0, then this implies that the system is unstable (i.e., nearby trajectories will diverge away from one another over time).
~ generated description from airoboros33b
---
Reference:
en.wikipedia.org
www.collimator.ai
blog.abhranil.net
www.researchgate.net
physics.stackexchange.com
---
This is a work in progress, it may contain errors so use with caution.
If you find flaws or suggest something new, please leave a comment bellow.
_measure_function(i)
helper function to get the name of distance function by a index (0 -> 13).\
Functions: SSD, Euclidean, Manhattan, Minkowski, Chebyshev, Correlation, Cosine, Camberra, MAE, MSE, Lorentzian, Intersection, Penrose Shape, Meehl.
Parameters:
i (int)
_test(L)
Helper function to test the output exponents state system and outputs description into a string.
Parameters:
L (float )
estimate(X, initial_distance, distance_function)
Estimate the Lyaponov Exponents for multiple series in a row matrix.
Parameters:
X (map)
initial_distance (float) : Initial distance limit.
distance_function (string) : Name of the distance function to be used, default:`ssd`.
Returns: List of Lyaponov exponents.
max(L)
Maximal Lyaponov Exponent.
Parameters:
L (float ) : List of Lyapunov exponents.
Returns: Highest exponent.
printerLibrary "printer"
Printer Library, designed to streamline the process of printing data directly onto charts while offering advanced features for enhanced functionality.
For full documentation, please visit faiyaz7283.github.io
Contrast Color LibraryThis lightweight library provides a utility method that analyzes any provided background color and automatically chooses the optimal black or white foreground color to ensure maximum visual contrast and readability.
🟠 Algorithm
The library utilizes the HSP Color Model to calculate the brightness of the background color. The formula for this calculation is as follows:
brightness = sqrt(0.299 * R^2 + 0.587 * G^2 + 0.114 * B^2 )
The library chooses black as the foreground color if the brightness exceeds the threshold (default 0.5), and white otherwise.
rezgaaLibrary "rezgaa"
Provides functions calculating the all-time high/low of values.
hi(val)
Calculates the all-time high of a series.
Parameters:
val (float) : Series to use (`high` is used if no argument is supplied).
Returns: The all-time high for the series.
lo(val)
Calculates the all-time low of a series.
Parameters:
val (float) : Series to use (`low` is used if no argument is supplied).
Returns: The all-time low for the series.
RationalQuadraticKernelFunctionDescription:
An optimised library for non-repainting Rational Quadratic Kernel Library. Added lookbackperiod and a validation to prevent division by zero.
Thanks to original author jdehorty.
Usage:
1. Import the library into your Pine Script code using the library function.
import vinayakavajiraya/RationalQuadraticKernelFunction/1
2. Call the Main Function:
Use the rationalQuadraticKernel function to calculate the Rational Quadratic Kernel estimate.
Provide the following parameters:
`_src` (series float): The input series of float values, typically representing price data.
`_lookback` (simple int): The lookback period for the kernel calculation (an integer).
`_relativeWeight` (simple float): The relative weight factor for the kernel (a float).
`startAtBar` (simple int): The bar index to start the calculation from (an integer).
rationalQuadraticEstimate = rationalQuadraticKernel(_src, _lookback, _relativeWeight, startAtBar)
3. Plot the Estimate:
Plot the resulting estimate on your TradingView chart using the plot function.
plot(rationalQuadraticEstimate, color = color.red, title = "Rational Quadratic Kernel Estimate")
Parameter Explanation:
`_src`: The input series of price data, such as 'close' or any other relevant data.
`_lookback`: The number of previous bars to consider when calculating the estimate. Higher values capture longer-term trends.
`_relativeWeight`: A factor that controls the importance of each data point in the calculation. A higher value emphasizes recent data.
`startAtBar`: The bar index from which the calculation begins.
Example Usage:
Here's an example of how to use the library to calculate and plot the Rational Quadratic Kernel estimate for the 'close' price series:
//@version=5
library("RationalQuadraticKernelFunctions", true)
rationalQuadraticEstimate = rationalQuadraticKernel(close, 11, 1, 24)
plot(rationalQuadraticEstimate, color = color.orange, title = "Rational Quadratic Kernel Estimate")
This example calculates the estimate for the 'close' price series, considers the previous 11 bars, assigns equal weight to all data points, and starts the calculation from the 24th bar. The result is plotted as an orange line on the chart.
Highly recommend to customize the parameters to suit your analysis needs and adapt the library to your trading strategies.
lib_profileLibrary "lib_profile"
a library with functions to calculate a volume profile for either a set of candles within the current chart, or a single candle from its lower timeframe security data. All you need is to feed the
method delete(this)
deletes this bucket's plot from the chart
Namespace types: Bucket
Parameters:
this (Bucket)
method delete(this)
Namespace types: Profile
Parameters:
this (Profile)
method delete(this)
Namespace types: Bucket
Parameters:
this (Bucket )
method delete(this)
Namespace types: Profile
Parameters:
this (Profile )
method update(this, top, bottom, value, fraction)
updates this bucket's data
Namespace types: Bucket
Parameters:
this (Bucket)
top (float)
bottom (float)
value (float)
fraction (float)
method update(this, tops, bottoms, values)
update this Profile's data (recalculates the whole profile and applies the result to this object) TODO optimisation to calculate this incremental to improve performance in realtime on high resolution
Namespace types: Profile
Parameters:
this (Profile)
tops (float ) : array of range top/high values (either from ltf or chart candles using history() function
bottoms (float ) : array of range bottom/low values (either from ltf or chart candles using history() function
values (float ) : array of range volume/1 values (either from ltf or chart candles using history() function (1s can be used for analysing candles in bucket/price range over time)
method tostring(this)
allows debug print of a bucket
Namespace types: Bucket
Parameters:
this (Bucket)
method draw(this, start_t, start_i, end_t, end_i, args, line_color)
allows drawing a line in a Profile, representing this bucket and it's value + it's value's fraction of the Profile total value
Namespace types: Bucket
Parameters:
this (Bucket)
start_t (int) : the time x coordinate of the line's left end (depends on the Profile box)
start_i (int) : the bar_index x coordinate of the line's left end (depends on the Profile box)
end_t (int) : the time x coordinate of the line's right end (depends on the Profile box)
end_i (int) : the bar_index x coordinate of the line's right end (depends on the Profile box)
args (LineArgs type from robbatt/lib_plot_objects/24) : the default arguments for the line style
line_color (color) : the color override for POC/VAH/VAL lines
method draw(this, forced_width)
draw all components of this Profile (Box, Background, Bucket lines, POC/VAH/VAL overlay levels and labels)
Namespace types: Profile
Parameters:
this (Profile)
forced_width (int) : allows to force width of the Profile Box, overrides the ProfileArgs.default_size and ProfileArgs.extend arguments (default: na)
method init(this)
Namespace types: ProfileArgs
Parameters:
this (ProfileArgs)
method init(this)
Namespace types: Profile
Parameters:
this (Profile)
profile(tops, bottoms, values, resolution, vah_pc, val_pc, bucket_buffer)
split a chart/parent bar into 'resolution' sections, figure out in which section the most volume/time was spent, by analysing a given set of (intra)bars' top/bottom/volume values. Then return price center of the bin with the highest volume, essentially marking the point of control / highest volume (poc) in the chart/parent bar.
Parameters:
tops (float ) : array of range top/high values (either from ltf or chart candles using history() function
bottoms (float ) : array of range bottom/low values (either from ltf or chart candles using history() function
values (float ) : array of range volume/1 values (either from ltf or chart candles using history() function (1s can be used for analysing candles in bucket/price range over time)
resolution (int) : amount of buckets/price ranges to sort the candle data into (analyse how much volume / time was spent in a certain bucket/price range) (default: 25)
vah_pc (float) : a threshold percentage (of values' total) for the top end of the value area (default: 80)
val_pc (float) : a threshold percentage (of values' total) for the bottom end of the value area (default: 20)
bucket_buffer (Bucket ) : optional buffer of empty Buckets to fill, if omitted a new one is created and returned. The buffer length must match the resolution
Returns: poc (price level), vah (price level), val (price level), poc_index (idx in buckets), vah_index (idx in buckets), val_index (idx in buckets), buckets (filled buffer or new)
create_profile(start_idx, tops, bottoms, values, resolution, vah_pc, val_pc, args)
split a chart/parent bar into 'resolution' sections, figure out in which section the most volume/time was spent, by analysing a given set of (intra)bars' top/bottom/volume values. Then return price center of the bin with the highest volume, essentially marking the point of control / highest volume (poc) in the chart/parent bar.
Parameters:
start_idx (int) : the bar_index at which the Profile should start drawing
tops (float ) : array of range top/high values (either from ltf or chart candles using history() function
bottoms (float ) : array of range bottom/low values (either from ltf or chart candles using history() function
values (float ) : array of range volume/1 values (either from ltf or chart candles using history() function (1s can be used for analysing candles in bucket/price range over time)
resolution (int) : amount of buckets/price ranges to sort the candle data into (analyse how much volume / time was spent in a certain bucket/price range) (default: 25)
vah_pc (float) : a threshold percentage (of values' total) for the top end of the value area (default: 80)
val_pc (float) : a threshold percentage (of values' total) for the bottom end of the value area (default: 20)
args (ProfileArgs)
Returns: poc (price level), vah (price level), val (price level), poc_index (idx in buckets), vah_index (idx in buckets), val_index (idx in buckets), buckets (filled buffer or new)
history(src, len, offset)
allows fetching an array of values from the history series with offset from current candle
Parameters:
src (int)
len (int)
offset (int)
history(src, len, offset)
allows fetching an array of values from the history series with offset from current candle
Parameters:
src (float)
len (int)
offset (int)
history(src, len, offset)
allows fetching an array of values from the history series with offset from current candle
Parameters:
src (bool)
len (int)
offset (int)
history(src, len, offset)
allows fetching an array of values from the history series with offset from current candle
Parameters:
src (string)
len (int)
offset (int)
Bucket
Fields:
idx (series int) : the index of this Bucket within the Profile starting with 0 for the lowest Bucket at the bottom of the Profile
value (series float) : the value of this Bucket, can be volume or time, for using time pass and array of 1s to the update function
top (series float) : the top of this Bucket's price range (for calculation)
btm (series float) : the bottom of this Bucket's price range (for calculation)
center (series float) : the center of this Bucket's price range (for plotting)
fraction (series float) : the fraction this Bucket's value is compared to the total of the Profile
plot_bucket_line (Line type from robbatt/lib_plot_objects/24) : the line that resembles this bucket and it's valeu in the Profile
ProfileArgs
Fields:
show_poc (series bool) : whether to plot a POC line across the Profile Box (default: true)
show_profile (series bool) : whether to plot a line for each Bucket in the Profile Box, indicating the value per Bucket (Price range), e.g. volume that occured in a certain time and price range (default: false)
show_va (series bool) : whether to plot a VAH/VAL line across the Profile Box (default: false)
show_va_fill (series bool) : whether to fill the 'value' area between VAH/VAL line (default: false)
show_background (series bool) : whether to fill the Profile Box with a background color (default: false)
show_labels (series bool) : whether to add labels to the right end of the POC/VAH/VAL line (default: false)
show_price_levels (series bool) : whether add price values to the labels to the right end of the POC/VAH/VAL line (default: false)
extend (series bool) : whether extend the Profile Box to the current candle (default: false)
default_size (series int) : the default min. width of the Profile Box (default: 30)
args_poc_line (LineArgs type from robbatt/lib_plot_objects/24) : arguments for the poc line plot
args_va_line (LineArgs type from robbatt/lib_plot_objects/24) : arguments for the va line plot
args_poc_label (LabelArgs type from robbatt/lib_plot_objects/24) : arguments for the poc label plot
args_va_label (LabelArgs type from robbatt/lib_plot_objects/24) : arguments for the va label plot
args_profile_line (LineArgs type from robbatt/lib_plot_objects/24) : arguments for the Bucket line plots
args_profile_bg (BoxArgs type from robbatt/lib_plot_objects/24)
va_fill_color (series color) : color for the va area fill plot
Profile
Fields:
start (series int) : left x coordinate for the Profile Box
end (series int) : right x coordinate for the Profile Box
resolution (series int) : the amount of buckets/price ranges the Profile will dissect the data into
vah_threshold_pc (series float) : the percentage of the total data value to mark the upper threshold for the main value area
val_threshold_pc (series float) : the percentage of the total data value to mark the lower threshold for the main value area
args (ProfileArgs) : the style arguments for the Profile Box
h (series float) : the highest price of the data
l (series float) : the lowest price of the data
total (series float) : the total data value (e.g. volume of all candles, or just one each to analyse candle distribution over time)
buckets (Bucket ) : the Bucket objects holding the data for each price range bucket
poc_bucket_index (series int) : the Bucket index in buckets, that holds the poc Bucket
vah_bucket_index (series int) : the Bucket index in buckets, that holds the vah Bucket
val_bucket_index (series int) : the Bucket index in buckets, that holds the val Bucket
poc (series float) : the according price level marking the Point Of Control
vah (series float) : the according price level marking the Value Area High
val (series float) : the according price level marking the Value Area Low
plot_poc (Line type from robbatt/lib_plot_objects/24)
plot_vah (Line type from robbatt/lib_plot_objects/24)
plot_val (Line type from robbatt/lib_plot_objects/24)
plot_poc_label (Label type from robbatt/lib_plot_objects/24)
plot_vah_label (Label type from robbatt/lib_plot_objects/24)
plot_val_label (Label type from robbatt/lib_plot_objects/24)
plot_va_fill (LineFill type from robbatt/lib_plot_objects/24)
plot_profile_bg (Box type from robbatt/lib_plot_objects/24)
two_ma_logicLibrary "two_ma_logic"
The core logic for the two moving average strategy that is used as an example for the internal logic of
the "Template Trailing Strategy" and the "Two MA Signal Indicator"
ma(source, maType, length)
ma - Calculate the moving average of the given source for the given length and type of the average
Parameters:
source (float) : - The source of the values
maType (simple string) : - The type of the moving average
length (simple int) : - The length of the moving average
Returns: - The resulted value of the calculations of the moving average
getDealConditions(drawings, longDealsEnabled, shortDealsEnabled, endDealsEnabled, cnlStartDealsEnabled, cnlEndDealsEnabled, emaFilterEnabled, emaAtrBandEnabled, adxFilterEnabled, adxSmoothing, diLength, adxThreshold)
Parameters:
drawings (TwoMaDrawings)
longDealsEnabled (simple bool)
shortDealsEnabled (simple bool)
endDealsEnabled (simple bool)
cnlStartDealsEnabled (simple bool)
cnlEndDealsEnabled (simple bool)
emaFilterEnabled (simple bool)
emaAtrBandEnabled (simple bool)
adxFilterEnabled (simple bool)
adxSmoothing (simple int)
diLength (simple int)
adxThreshold (simple float)
TwoMaDrawings
Fields:
fastMA (series__float)
slowMA (series__float)
emaLine (series__float)
emaUpperBand (series__float)
emaLowerBand (series__float)
tts_conventionLibrary "tts_convention"
This library can convert the start, end, cancel start, cancel end deal conditions that are used in the
"Template Trailing Strategy" script into a signal value and vice versa. The "two channels mod div" convention is unsed
internaly and the signal value can be composed/decomposed into two channels that contain the afforementioned actions
for long and short positions separetely.
getDealConditions(signal)
getDealConditions - Get the start, end, cancel start and cancel end deal conditions that are used in the "Template Trailing Strategy" script by decomposing the given signal
Parameters:
signal (int) : - The signal value to decompose
Returns: An object with the start, end, cancel start and cancel end deal conditions for long and short
getSignal(dealConditions)
getSignal - Get the signal value from the composition of the start, end, cancel start and cancel end deal conditions that are used in the "Template Trailing Strategy" script
Parameters:
dealConditions (DealConditions) : - The deal conditions object that containd the start, end, cancel start and cancel end deal conditions for long and short
Returns: The composed signal value
DealConditions
Fields:
startLongDeal (series__bool)
startShortDeal (series__bool)
endLongDeal (series__bool)
endShortDeal (series__bool)
cnlStartLongDeal (series__bool)
cnlStartShortDeal (series__bool)
cnlEndLongDeal (series__bool)
cnlEndShortDeal (series__bool)
CommonTypesMapUtilLibrary "CommonTypesMapUtil"
Common type Container library, for central usage across other reference libraries.
ArrayBool
Fields:
v (bool )
ArrayBox
Fields:
v (box )
ArrayPoint
Fields:
v (chart.point )
ArrayColor
Fields:
v (color )
ArrayFloat
Fields:
v (float )
ArrayInt
Fields:
v (int )
ArrayLabel
Fields:
v (label )
ArrayLine
Fields:
v (line )
ArrayLinefill
Fields:
v (linefill )
ArrayString
Fields:
v (string )
ArrayTable
Fields:
v (table )
signal_datagramThe purpose of this library is to split and merge an integer into useful pieces of information that can easily handled and plotted.
The basic piece of information is one word. Depending on the underlying numerical system a word can be a bit, octal, digit, nibble, or byte.
The user can define channels. Channels are named groups of words. Multiple words can be combined to increase the value range of a channel.
A datagram is a description of the user-defined channels in an also user-defined numeric system that also contains all runtime information that is necessary to split and merge the integer.
This library simplifies the communication between two scripts by allowing the user to define the same datagram in both scripts.
On the sender's side, the channel values can be merged into one single integer value called signal. This signal can be 'emitted' using the plot function. The other script can use the 'input.source' function to receive that signal.
On the receiver's end based on the same datagram, the signal can be split into several channels. Each channel has the piece of information that the sender script put.
In the example of this library, we use two channels and we have split the integer in half. However, the user can add new channels, change them, and give meaning to them according to the functionality he wants to implement and the type of information he wants to communicate.
Nowadays many 'input.source' calls are allowed to pass information between the scripts, When that is not a price or a floating value, this library is very useful.
The reason is that most of the time, the convention that is used is not clear enough and it is easy to do things the wrong way or break them later on.
With this library validation checks are done during the initialization minimizing the possibility of error due to some misconceptions.
Library "signal_datagram"
Conversion of a datagram type to a signal that can be "send" as a single value from an indicator to a strategy script
method init(this, positions, maxWords)
init - Initialize if the word positons array with an empty array
Namespace types: WordPosArray
Parameters:
this (WordPosArray) : - The word positions array object
positions (int ) : - The array that contains all the positions of the worlds that shape the channel
maxWords (int) : - The maximum words allowed based on the span
Returns: The initialized object
method init(this)
init - Initialize if the channels word positons map with an empty map
Namespace types: ChannelDesc
Parameters:
this (ChannelDesc) : - The channels' descriptor object
Returns: The initialized object
method init(this, numericSystem, channelDesc)
init - Initialize if the datagram
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object
numericSystem (simple string) : - The numeric system of the words to be used
channelDesc (ChannelDesc) : - The channels descriptor that contains the positions of the words that each channel consists of
Returns: The initialized object
method add_channel(this, name, positions)
add_channel - Add a new channel descriptopn with its name and its corresponding word positons to the map
Namespace types: ChannelDesc
Parameters:
this (ChannelDesc) : - The channels' descriptor object to update
name (simple string)
positions (int )
Returns: The initialized object
method set_signal(this, value)
set_signal - Set the signal value
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to update
value (int) : - The signal value to set
method get_signal(this)
get_signal - Get the signal value
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to query
Returns: The value of the signal in digits
method set_signal_sign(this, sign)
set_signal_sign - Set the signal sign
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to update
sign (int) : - The negative -1 or positive 1 sign of the underlying value
method get_signal_sign(this)
get_signal_sign - Get the signal sign
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to query
Returns: The sign of the signal value -1 if it is negative and 1 if it is possitive
method get_channel_names(this)
get_channel_names - Get an array of all channel names
Namespace types: Datagram
Parameters:
this (Datagram)
Returns: An array that has all the channel names that are used by the datagram
method set_channel_value(this, channelName, value)
set_channel_value - Set the value of the channel
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to update
channelName (simple string) : - The name of the channel to set the value to. Then name should be as described int the schemas channel descriptor
value (int) : - The channel value to set
method set_all_channels_value(this, value)
set_all_channels_value - Set the value of all the channels
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to update
value (int) : - The channel value to set
method set_all_channels_max_value(this)
set_all_channels_value - Set the value of all the channels
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to update
method get_channel_value(this, channelName)
get_channel_value - Get the value of the channel
Namespace types: Datagram
Parameters:
this (Datagram) : - The datagram object to query
channelName (simple string)
Returns: Digit group of words (bits/octals/digits/nibbles/hexes/bytes) found at the channel accodring to the schema
WordDesc
Fields:
numericSystem (series__string)
span (series__integer)
WordPosArray
Fields:
positions (array__integer)
ChannelDesc
Fields:
map (map__series__string:|WordPosArray|#OBJ)
Schema
Fields:
wordDesc (|WordDesc|#OBJ)
channelDesc (|ChannelDesc|#OBJ)
Signal
Fields:
value (series__integer)
isNegative (series__bool)
words (array__integer)
Datagram
Fields:
schema (|Schema|#OBJ)
signal (|Signal|#OBJ)
lib_retracement_labelLibrary "lib_retracement_label"
creates a retracement label between the origin and target of a retracement, updating it's position (via update + draw) when the target moves.
create_tooltip(name, min, max, tol_min, tol_max)
Parameters:
name (string)
min (float)
max (float)
tol_min (float)
tol_max (float)
method update(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel)
method create_retracement_label(this, move_endpoint, args, tooltip)
Creates a new RetracementLabel object.
Namespace types: D.Line
Parameters:
this (Line type from robbatt/lib_plot_objects/23)
move_endpoint (Point type from robbatt/lib_plot_objects/23)
args (LabelArgs type from robbatt/lib_plot_objects/23)
tooltip (string)
method create_retracement_label(this, move_end, args, tooltip)
Creates a new RetracementLabel object.
Namespace types: D.Line
Parameters:
this (Line type from robbatt/lib_plot_objects/23)
move_end (Pivot type from robbatt/lib_pivot/43)
args (LabelArgs type from robbatt/lib_plot_objects/23)
tooltip (string)
method enqueue(id, item, max)
Namespace types: RetracementLabel
Parameters:
id (RetracementLabel )
item (RetracementLabel)
max (int)
method draw(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel)
method draw(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel )
method delete(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel)
method delete(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel )
RetracementLabel
Fields:
move_endpoint (|robbatt/lib_plot_objects/23;Point|#OBJ)
center_label (|robbatt/lib_plot_objects/23;CenterLabel|#OBJ)
SimilarityMeasuresLibrary "SimilarityMeasures"
Similarity measures are statistical methods used to quantify the distance between different data sets
or strings. There are various types of similarity measures, including those that compare:
- data points (SSD, Euclidean, Manhattan, Minkowski, Chebyshev, Correlation, Cosine, Camberra, MAE, MSE, Lorentzian, Intersection, Penrose Shape, Meehl),
- strings (Edit(Levenshtein), Lee, Hamming, Jaro),
- probability distributions (Mahalanobis, Fidelity, Bhattacharyya, Hellinger),
- sets (Kumar Hassebrook, Jaccard, Sorensen, Chi Square).
---
These measures are used in various fields such as data analysis, machine learning, and pattern recognition. They
help to compare and analyze similarities and differences between different data sets or strings, which
can be useful for making predictions, classifications, and decisions.
---
References:
en.wikipedia.org
cran.r-project.org
numerics.mathdotnet.com
github.com
github.com
github.com
Encyclopedia of Distances, doi.org
ssd(p, q)
Sum of squared difference for N dimensions.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Measure of distance that calculates the squared euclidean distance.
euclidean(p, q)
Euclidean distance for N dimensions.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Measure of distance that calculates the straight-line (or Euclidean).
manhattan(p, q)
Manhattan distance for N dimensions.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Measure of absolute differences between both points.
minkowski(p, q, p_value)
Minkowsky Distance for N dimensions.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
p_value (float) : `float` P value, default=1.0(1: manhatan, 2: euclidean), does not support chebychev.
Returns: Measure of similarity in the normed vector space.
chebyshev(p, q)
Chebyshev distance for N dimensions.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Measure of maximum absolute difference.
correlation(p, q)
Correlation distance for N dimensions.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Measure of maximum absolute difference.
cosine(p, q)
Cosine distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
Returns: The Cosine distance between vectors `p` and `q`.
---
angiogenesis.dkfz.de
camberra(p, q)
Camberra distance for N dimensions.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Weighted measure of absolute differences between both points.
mae(p, q)
Mean absolute error is a normalized version of the sum of absolute difference (manhattan).
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Mean absolute error of vectors `p` and `q`.
mse(p, q)
Mean squared error is a normalized version of the sum of squared difference.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Mean squared error of vectors `p` and `q`.
lorentzian(p, q)
Lorentzian distance between provided vectors.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Lorentzian distance of vectors `p` and `q`.
---
angiogenesis.dkfz.de
intersection(p, q)
Intersection distance between provided vectors.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Intersection distance of vectors `p` and `q`.
---
angiogenesis.dkfz.de
penrose(p, q)
Penrose Shape distance between provided vectors.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Penrose shape distance of vectors `p` and `q`.
---
angiogenesis.dkfz.de
meehl(p, q)
Meehl distance between provided vectors.
Parameters:
p (float ) : `array` Vector with first numeric distribution.
q (float ) : `array` Vector with second numeric distribution.
Returns: Meehl distance of vectors `p` and `q`.
---
angiogenesis.dkfz.de
edit(x, y)
Edit (aka Levenshtein) distance for indexed strings.
Parameters:
x (int ) : `array` Indexed array.
y (int ) : `array` Indexed array.
Returns: Number of deletions, insertions, or substitutions required to transform source string into target string.
---
generated description:
The Edit distance is a measure of similarity used to compare two strings. It is defined as the minimum number of
operations (insertions, deletions, or substitutions) required to transform one string into another. The operations
are performed on the characters of the strings, and the cost of each operation depends on the specific algorithm
used.
The Edit distance is widely used in various applications such as spell checking, text similarity, and machine
translation. It can also be used for other purposes like finding the closest match between two strings or
identifying the common prefixes or suffixes between them.
---
github.com
www.red-gate.com
planetcalc.com
lee(x, y, dsize)
Distance between two indexed strings of equal length.
Parameters:
x (int ) : `array` Indexed array.
y (int ) : `array` Indexed array.
dsize (int) : `int` Dictionary size.
Returns: Distance between two strings by accounting for dictionary size.
---
www.johndcook.com
hamming(x, y)
Distance between two indexed strings of equal length.
Parameters:
x (int ) : `array` Indexed array.
y (int ) : `array` Indexed array.
Returns: Length of different components on both sequences.
---
en.wikipedia.org
jaro(x, y)
Distance between two indexed strings.
Parameters:
x (int ) : `array` Indexed array.
y (int ) : `array` Indexed array.
Returns: Measure of two strings' similarity: the higher the value, the more similar the strings are.
The score is normalized such that `0` equates to no similarities and `1` is an exact match.
---
rosettacode.org
mahalanobis(p, q, VI)
Mahalanobis distance between two vectors with population inverse covariance matrix.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
VI (matrix) : `matrix` Inverse of the covariance matrix.
Returns: The mahalanobis distance between vectors `p` and `q`.
---
people.revoledu.com
stat.ethz.ch
docs.scipy.org
fidelity(p, q)
Fidelity distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
Returns: The Bhattacharyya Coefficient between vectors `p` and `q`.
---
en.wikipedia.org
bhattacharyya(p, q)
Bhattacharyya distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
Returns: The Bhattacharyya distance between vectors `p` and `q`.
---
en.wikipedia.org
hellinger(p, q)
Hellinger distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
Returns: The hellinger distance between vectors `p` and `q`.
---
en.wikipedia.org
jamesmccaffrey.wordpress.com
kumar_hassebrook(p, q)
Kumar Hassebrook distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
Returns: The Kumar Hassebrook distance between vectors `p` and `q`.
---
github.com
jaccard(p, q)
Jaccard distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
Returns: The Jaccard distance between vectors `p` and `q`.
---
github.com
sorensen(p, q)
Sorensen distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
Returns: The Sorensen distance between vectors `p` and `q`.
---
people.revoledu.com
chi_square(p, q, eps)
Chi Square distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
eps (float)
Returns: The Chi Square distance between vectors `p` and `q`.
---
uw.pressbooks.pub
stats.stackexchange.com
www.itl.nist.gov
kulczynsky(p, q, eps)
Kulczynsky distance between provided vectors.
Parameters:
p (float ) : `array` 1D Vector.
q (float ) : `array` 1D Vector.
eps (float)
Returns: The Kulczynsky distance between vectors `p` and `q`.
---
github.com