MLExtensions_Core

A set of extension methods for a novel implementation of a Approximate Nearest Neighbors (ANN) algorithm in Lorentzian space, focused on computation.
normalizeDeriv(src, quadraticMeanLength)
Returns the smoothed hyperbolic tangent of the input series.
Parameters:
src (float): <series float> The input series (i.e., the first-order derivative for price).
quadraticMeanLength (int): <int> The length of the quadratic mean (RMS).
Returns: nDeriv <series float> The normalized derivative of the input series.
normalize(src, min, max)
Rescales a source value with an unbounded range to a target range.
Parameters:
src (float): <series float> The input series
min (float): <float> The minimum value of the unbounded range
max (float): <float> The maximum value of the unbounded range
Returns: <series float> The normalized series
rescale(src, oldMin, oldMax, newMin, newMax)
Rescales a source value with a bounded range to anther bounded range
Parameters:
src (float): <series float> The input series
oldMin (float): <float> The minimum value of the range to rescale from
oldMax (float): <float> The maximum value of the range to rescale from
newMin (float): <float> The minimum value of the range to rescale to
newMax (float): <float> The maximum value of the range to rescale to
Returns: <series float> The rescaled series
getColorShades(color)
Creates an array of colors with varying shades of the input color
Parameters:
color (color): <color> The color to create shades of
Returns: <array color> An array of colors with varying shades of the input color
getPredictionColor(prediction, neighborsCount, shadesArr)
Determines the color shade based on prediction percentile
Parameters:
prediction (float): <float> Value of the prediction
neighborsCount (int): <int> The number of neighbors used in a nearest neighbors classification
shadesArr (array<color>): <array color> An array of colors with varying shades of the input color
Returns: shade <color> Color shade based on prediction percentile
color_green(prediction)
Assigns varying shades of the color green based on the KNN classification
Parameters:
prediction (float): Value (int|float) of the prediction
Returns: color <color>
color_red(prediction)
Assigns varying shades of the color red based on the KNN classification
Parameters:
prediction (float): Value of the prediction
Returns: color
tanh(src)
Returns the the hyperbolic tangent of the input series. The sigmoid-like hyperbolic tangent function is used to compress the input to a value between -1 and 1.
Parameters:
src (float): <series float> The input series (i.e., the normalized derivative).
Returns: tanh <series float> The hyperbolic tangent of the input series.
dualPoleFilter(src, lookback)
Returns the smoothed hyperbolic tangent of the input series.
Parameters:
src (float): <series float> The input series (i.e., the hyperbolic tangent).
lookback (int): <int> The lookback window for the smoothing.
Returns: filter <series float> The smoothed hyperbolic tangent of the input series.
tanhTransform(src, smoothingFrequency, quadraticMeanLength)
Returns the tanh transform of the input series.
Parameters:
src (float): <series float> The input series (i.e., the result of the tanh calculation).
smoothingFrequency (int)
quadraticMeanLength (int)
Returns: signal <series float> The smoothed hyperbolic tangent transform of the input series.
n_rsi(src, n1, n2)
Returns the normalized RSI ideal for use in ML algorithms.
Parameters:
src (float): <series float> The input series (i.e., the result of the RSI calculation).
n1 (simple int): <int> The length of the RSI.
n2 (simple int): <int> The smoothing length of the RSI.
Returns: signal <series float> The normalized RSI.
n_cci(src, n1, n2)
Returns the normalized CCI ideal for use in ML algorithms.
Parameters:
src (float): <series float> The input series (i.e., the result of the CCI calculation).
n1 (simple int): <int> The length of the CCI.
n2 (simple int): <int> The smoothing length of the CCI.
Returns: signal <series float> The normalized CCI.
n_wt(src, n1, n2)
Returns the normalized WaveTrend Classic series ideal for use in ML algorithms.
Parameters:
src (float): <series float> The input series (i.e., the result of the WaveTrend Classic calculation).
n1 (simple int)
n2 (simple int)
Returns: signal <series float> The normalized WaveTrend Classic series.
n_adx(highSrc, lowSrc, closeSrc, n1)
Returns the normalized ADX ideal for use in ML algorithms.
Parameters:
highSrc (float): <series float> The input series for the high price.
lowSrc (float): <series float> The input series for the low price.
closeSrc (float): <series float> The input series for the close price.
n1 (simple int): <int> The length of the ADX.
regime_filter(src, threshold, useRegimeFilter)
Parameters:
src (float)
threshold (float)
useRegimeFilter (bool)
filter_adx(src, length, adxThreshold, useAdxFilter)
filter_adx
Parameters:
src (float): <series float> The source series.
length (simple int): <int> The length of the ADX.
adxThreshold (int): <int> The ADX threshold.
useAdxFilter (bool): <bool> Whether to use the ADX filter.
Returns: <series float> The ADX.
filter_volatility(minLength, maxLength, sensitivityMultiplier, useVolatilityFilter)
filter_volatility
Parameters:
minLength (simple int): <int> The minimum length of the ATR.
maxLength (simple int): <int> The maximum length of the ATR.
sensitivityMultiplier (float): <float> Multiplier for the historical ATR to control sensitivity.
useVolatilityFilter (bool): <bool> Whether to use the volatility filter.
Returns: <bool> Boolean indicating whether or not to let the signal pass through the filter.
Added:
norm(src)
Normalizes a value if mean is 0
This function does not access global variables.
Parameters:
src (float): <series float> The input series to normalize.
Returns: <series float> The normalized series.
Libreria Pine
In pieno spirito TradingView, l'autore ha pubblicato questo codice Pine come libreria open-source in modo che altri programmatori Pine della nostra comunità possano riutilizzarlo. Complimenti all'autore! È possibile utilizzare questa libreria privatamente o in altre pubblicazioni open-source, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento.
Declinazione di responsabilità
Libreria Pine
In pieno spirito TradingView, l'autore ha pubblicato questo codice Pine come libreria open-source in modo che altri programmatori Pine della nostra comunità possano riutilizzarlo. Complimenti all'autore! È possibile utilizzare questa libreria privatamente o in altre pubblicazioni open-source, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento.