PINE LIBRARY

Mad_MATH

ที่อัปเดต:
Library "MAD_MATH"
This is a mathematical library where I store useful kernels, filters and selectors for the different types of computations.

This library also contains opensource code from other scripters.
Future extensions are very likely, there are some functions I would like to add, but I have to wait for approvals so i can include them.


Ehlers_EMA(_src, _length)
  Calculates the Ehlers Exponential Moving Average (Ehlers_EMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers EMA
  Returns: The Ehlers EMA value

Ehlers_Gaussian(_src, _length)
  Calculates the Ehlers Gaussian Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Gaussian Filter
  Returns: The Ehlers Gaussian Filter value

Ehlers_supersmoother(_src, _length)
  Calculates the Ehlers Supersmoother
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Supersmoother
  Returns: The Ehlers Supersmoother value

Ehlers_SMA_fast(_src, _length)
  Calculates the Ehlers Simple Moving Average (SMA) Fast
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers SMA Fast
  Returns: The Ehlers SMA Fast value

Ehlers_EMA_fast(_src, _length)
  Calculates the Ehlers Exponential Moving Average (EMA) Fast
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers EMA Fast
  Returns: The Ehlers EMA Fast value

Ehlers_RSI_fast(_src, _length)
  Calculates the Ehlers Relative Strength Index (RSI) Fast
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers RSI Fast
  Returns: The Ehlers RSI Fast value

Ehlers_Band_Pass_Filter(_src, _length)
  Calculates the Ehlers BandPass Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers BandPass Filter
  Returns: The Ehlers BandPass Filter value

Ehlers_Butterworth(_src, _length)
  Calculates the Ehlers Butterworth Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Butterworth Filter
  Returns: The Ehlers Butterworth Filter value

Ehlers_Two_Pole_Gaussian_Filter(_src, _length)
  Calculates the Ehlers Two-Pole Gaussian Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Two-Pole Gaussian Filter
  Returns: The Ehlers Two-Pole Gaussian Filter value

Ehlers_Two_Pole_Butterworth_Filter(_src, _length)
  Calculates the Ehlers Two-Pole Butterworth Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Two-Pole Butterworth Filter
  Returns: The Ehlers Two-Pole Butterworth Filter value

Ehlers_Band_Stop_Filter(_src, _length)
  Calculates the Ehlers Band Stop Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Band Stop Filter
  Returns: The Ehlers Band Stop Filter value

Ehlers_Smoother(_src)
  Calculates the Ehlers Smoother
  Parameters:
    _src (float): The source series for calculation
  Returns: The Ehlers Smoother value

Ehlers_High_Pass_Filter(_src, _length)
  Calculates the Ehlers High Pass Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers High Pass Filter
  Returns: The Ehlers High Pass Filter value

Ehlers_2_Pole_High_Pass_Filter(_src, _length)
  Calculates the Ehlers Two-Pole High Pass Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Two-Pole High Pass Filter
  Returns: The Ehlers Two-Pole High Pass Filter value

pr(_src, _length)
  pr Calculates the percentage rank (PR) of a value within a range.
  Parameters:
    _src (float): The source value for which the percentage rank is calculated. It represents the value to be ranked within the range.
    _length (simple int): The _length of the range over which the percentage rank is calculated. It determines the number of bars considered for the calculation.
  Returns: The percentage rank (PR) of the source value within the range, adjusted by adding 50 to the result.

smma(_src, _length)
  Calculates the SMMA (Smoothed Moving Average)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int)
  Returns: The SMMA value

hullma(_src, _length)
  Calculates the Hull Moving Average (HullMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the HullMA
  Returns: The HullMA value

tma(_src, _length)
  Calculates the Triple Moving Average (TMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the TMA
  Returns: The TMA value

dema(_src, _length)
  Calculates the Double Exponential Moving Average (DEMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the DEMA
  Returns: The DEMA value

tema(_src, _length)
  Calculates the Triple Exponential Moving Average (TEMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the TEMA
  Returns: The TEMA value

w2ma(_src, _length)
  Calculates the Normalized Double Moving Average (N2MA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the N2MA
  Returns: The N2MA value

wma(_src, _length)
  Calculates the Normalized Moving Average (NMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the NMA
  Returns: The NMA value

nma(_open, _close, _length)
  Calculates the Normalized Moving Average (NMA)
  Parameters:
    _open (float): The open price series
    _close (float): The close price series
    _length (simple int): The _length for finding the highest and lowest values
  Returns: The NMA value

lma(_src, _length)
  Parameters:
    _src (float)
    _length (simple int)

zero_lag(_src, _length, gamma1, zl)
  Calculates the Zero Lag Moving Average (ZeroLag)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the moving average
    gamma1 (simple int): The coefficient for calculating 'd'
    zl (simple bool): Boolean flag for applying Zero Lag
  Returns: An array containing the ZeroLag Moving Average and a boolean flag indicating if it's flat
copyright HPotter, thanks for that great function

chebyshevI(src, len, ripple)
  Calculates the Chebyshev Type I Filter
  Parameters:
    src (float): The source series for calculation
    len (int): The length of the filter
    ripple (float): The ripple factor for the filter
  Returns: The output of the Chebyshev Type I Filter
math from Pafnuti Lwowitsch Tschebyschow (1821–1894)
Thanks peacefulLizard50262 for the find and translation

chebyshevII(src, len, ripple)
  Calculates the Chebyshev Type II Filter
  Parameters:
    src (float): The source series for calculation
    len (int): The length of the filter
    ripple (float): The ripple factor for the filter
  Returns: The output of the Chebyshev Type II Filter
math from Pafnuti Lwowitsch Tschebyschow (1821–1894)
Thanks peacefulLizard50262 for the find

wavetrend(_src, _n1, _n2)
  Calculates the WaveTrend indicator
  Parameters:
    _src (float): The source series for calculation
    _n1 (simple int): The period for the first EMA calculation
    _n2 (simple int): The period for the second EMA calculation
  Returns: The WaveTrend value

f_getma(_type, _src, _length, ripple)
  Calculates various types of moving averages
  Parameters:
    _type (simple string): The type of indicator to calculate
    _src (float): The source series for calculation
    _length (simple int): The length for the moving average or indicator
    ripple (simple float)
  Returns: The calculated moving average or indicator value

f_getfilter(_type, _src, _length)
  Calculates various types of filters
  Parameters:
    _type (simple string): The type of indicator to calculate
    _src (float): The source series for calculation
    _length (simple int): The length for the moving average or indicator
  Returns: The filtered value

f_getoszillator(_type, _src, _length)
  Calculates various types of Deviations and other indicators
  Parameters:
    _type (simple string): The type of indicator to calculate
    _src (float): The source series for calculation
    _length (simple int): The length for the moving average or indicator
  Returns: The calculated moving average or indicator value
เอกสารเผยแพร่
v2
Changed the Strings for calling the Switches to Clearnames

Added:
Ehlers_Supersmoother(_src, _length)
  Calculates the Ehlers Supersmoother
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Supersmoother
  Returns: The Ehlers Supersmoother value

ChebyshevI(src, len, ripple)
  Calculates the Chebyshev Type I Filter
  Parameters:
    src (float): The source series for calculation
    len (int): The length of the filter
    ripple (float): The ripple factor for the filter
  Returns: The output of the Chebyshev Type I Filter
math from Pafnuti Lwowitsch Tschebyschow (1821–1894)
Thanks peacefulLizard50262 for the find and translation

ChebyshevII(src, len, ripple)
  Calculates the Chebyshev Type II Filter
  Parameters:
    src (float): The source series for calculation
    len (int): The length of the filter
    ripple (float): The ripple factor for the filter
  Returns: The output of the Chebyshev Type II Filter
math from Pafnuti Lwowitsch Tschebyschow (1821–1894)
Thanks peacefulLizard50262 for the find

Removed:
Ehlers_supersmoother(_src, _length)
  Calculates the Ehlers Supersmoother

zero_lag(_src, _length, gamma1, zl)
  Calculates the Zero Lag Moving Average (ZeroLag)
  removed because of wrong information

chebyshevI(src, len, ripple)
  Calculates the Chebyshev Type I Filter

chebyshevII(src, len, ripple)
  Calculates the Chebyshev Type II Filter
เอกสารเผยแพร่
Added alexgrovers ARMA A2RMA
Cleanup
Default Values


v3

Added:
Ehlers_Two_Pole_High_Pass_Filter(_src, _length)
  Calculates the Ehlers Two-Pole High Pass Filter
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers Two-Pole High Pass Filter
  Returns: The Ehlers Two-Pole High Pass Filter value

PR(_src, _length)
  PR Calculates the percentage rank (PR) of a value within a range.
  Parameters:
    _src (float): The source value for which the percentage rank is calculated. It rePResents the value to be ranked within the range.
    _length (simple int): The _length of the range over which the percentage rank is calculated. It determines the number of bars considered for the calculation.
  Returns: The percentage rank (PR) of the source value within the range, adjusted by adding 50 to the result.

SMMA(_src, _length)
  Calculates the SMMA (Smoothed Moving Average)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int)
  Returns: The SMMA value

HULLMA(_src, _length)
  Calculates the Hull Moving Average (HULLMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the HULLMA
  Returns: The HULLMA value

TMA(_src, _length)
  Calculates the Triple Moving Average (TMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the TMA
  Returns: The TMA value

DEMA(_src, _length)
  Calculates the Double Exponential Moving Average (DEMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the DEMA
  Returns: The DEMA value

TEMA(_src, _length)
  Calculates the Triple Exponential Moving Average (TEMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the TEMA
  Returns: The TEMA value

W2MA(_src, _length)
  Calculates the Normalized Double Moving Average (N2MA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the N2MA
  Returns: The N2MA value

A2RMA(_src, _length, _gamma)
  Parameters:
    _src (float): Source float input used for the calculation
    _length (simple int): Integer value rePResenting the length of the period
    _gamma (simple float): Integer value rePResenting a factor for the calculation
  Returns: the value of the adaptive moving average

ARMA(_src, _length, _gamma, _zerolag)
  Calculates the Autonomous Recursive Moving Average (ARMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the ARMA
    _gamma (simple float): The parameter for ARMA calculation
    _zerolag (simple bool): Boolean flag indicating whether to use zero lag
  Returns: An array containing the ARMA value and a flag indicating flatness

f_getall(_type, _src, _length, _gamma, _ripple, _zerolag)
  Calculates various types of Deviations and other indicators
  Parameters:
    _type (simple string): The type of indicator to calculate
    _src (float): The source series for calculation
    _length (simple int): The length for the moving average or indicator
    _gamma (simple float)
    _ripple (simple float)
    _zerolag (simple bool)
  Returns: The calculated moving average or indicator value

Updated:
nma(_open, _close, _length)
  Calculates the Normalized Moving Average (NMA)
  Parameters:
    _open (float): The open PRice series
    _close (float): The close PRice series
    _length (simple int): The _length for finding the highest and lowest values
  Returns: The NMA value

ChebyshevI(_src, _length, _ripple)
  Calculates the Chebyshev Type I Filter
  Parameters:
    _src (float)
    _length (int)
    _ripple (float)
  Returns: The output of the Chebyshev Type I Filter
math from Pafnuti Lwowitsch Tschebyschow (1821–1894)
Thanks peacefulLizard50262 for the find and translation

ChebyshevII(_src, _length, _ripple)
  Calculates the Chebyshev Type II Filter
  Parameters:
    _src (float)
    _length (int)
    _ripple (float)
  Returns: The output of the Chebyshev Type II Filter
math from Pafnuti Lwowitsch Tschebyschow (1821–1894)
Thanks peacefulLizard50262 for the find

f_getma(_type, _src, _length, _gamma, _ripple, _zerolag)
  Calculates various types of moving averages
  Parameters:
    _type (simple string): The type of indicator to calculate
    _src (float): The source series for calculation
    _length (simple int): The length for the moving average or indicator
    _gamma (simple float)
    _ripple (simple float)
    _zerolag (simple bool)
  Returns: The calculated moving average or indicator value

Removed:
Ehlers_2_Pole_High_Pass_Filter(_src, _length)
  Calculates the Ehlers Two-Pole High Pass Filter

pr(_src, _length)
  pr Calculates the percentage rank (PR) of a value within a range.

smma(_src, _length)
  Calculates the SMMA (Smoothed Moving Average)

hullma(_src, _length)
  Calculates the Hull Moving Average (HullMA)

tma(_src, _length)
  Calculates the Triple Moving Average (TMA)

dema(_src, _length)
  Calculates the Double Exponential Moving Average (DEMA)

tema(_src, _length)
  Calculates the Triple Exponential Moving Average (TEMA)

w2ma(_src, _length)
  Calculates the Normalized Double Moving Average (N2MA)

f_getfilter(_type, _src, _length)
  Calculates various types of filters
เอกสารเผยแพร่
v4

Added:
harmonic_mean(_src, _length)
  harmonic_mean
  Parameters:
    _src (float)
    _length (simple int)
  Returns: Harmonic mean of the values in the array

geometric_mean(_src, _length)
  geometric_mean
  Parameters:
    _src (float)
    _length (simple int)
  Returns: Geometric mean of the values in the array

quadratic_mean(_src, _length)
  quadratic_mean
  Parameters:
    _src (float)
    _length (simple int)
  Returns: Quadratic mean of the values in the array

gst_dev(_src, _length)
  gstdev
  Parameters:
    _src (float)
    _length (simple int)
  Returns: Geometric standard deviation of the values in the array

hst_dev(_src, _length)
  hstdev
  Parameters:
    _src (float)
    _length (simple int)
  Returns: Harmonic standard deviation of the values in the array

avg_dev(_src, _length, base)
  avgdev
  Parameters:
    _src (float)
    _length (simple int)
    base (float): Float base value for deviation calculation
  Returns: Average deviation of the values in the array

std_dev(_src, _length, base)
  stddev
  Parameters:
    _src (float)
    _length (simple int)
    base (float): Float base value for deviation calculation
  Returns: Standard deviation of the values in the array

med_abs_dev(_src, _length, base)
  mdev
  Parameters:
    _src (float)
    _length (simple int)
    base (float): Float base value for deviation calculation
  Returns: Median of the absolute deviations of the values in the array from the base value

SGFilter(_length, _degree)
  sgFilter
  Parameters:
    _length (int): Integer representing the _length of the array
    _degree (float): Integer representing the _degree for calculation
  Returns: The Savitzky-Golay filter value

PID(_src, _ma_setpoint, _kP, _kI, _kIc, _kD, _pow, _smoother)
  Parameters:
    _src (float)
    _ma_setpoint (float)
    _kP (float)
    _kI (float)
    _kIc (float)
    _kD (float)
    _pow (float)
    _smoother (simple int)

Updated:
Ehlers_EMA(_src, _length)
  Calculates the Ehlers _pow Moving Average (Ehlers_EMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers EMA
  Returns: The Ehlers EMA value

Ehlers_EMA_fast(_src, _length)
  Calculates the Ehlers _pow Moving Average (EMA) Fast
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The length for the Ehlers EMA Fast
  Returns: The Ehlers EMA Fast value

DEMA(_src, _length)
  Calculates the Double _pow Moving Average (DEMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the DEMA
  Returns: The DEMA value

TEMA(_src, _length)
  Calculates the Triple _pow Moving Average (TEMA)
  Parameters:
    _src (float): The source series for calculation
    _length (simple int): The _length of the TEMA
  Returns: The TEMA value

A2RMA(_src, _length, _gamma)
  A2RMA - Adaptive Autonomous Recursive Moving Average
  Parameters:
    _src (float): Source float input used for the calculation
    _length (simple int): Integer value rePResenting the length of the period
    _gamma (simple float): Integer value rePResenting a factor for the calculation
  Returns: the value of the adaptive moving average
เอกสารเผยแพร่
v5

Added:
SGCoeffs(_length, _degree)
  sgCoeffs
  Parameters:
    _length (int): Integer representing the l_ength of the array
    _degree (float): Integer representing the _degree for calculation
  Returns: An array of coefficients for the Savitzky-Golay filter

ama(_x, _src, _length)
  ama (not Exported)
  Parameters:
    _x (float): Input value for the ama function
    _src (float)
    _length (simple int)
  Returns: a float value calculated based on the efficiency ratio and input value

cosh(x)
  Parameters:
    x (float)

acosh(x)
  Parameters:
    x (float)

sinh(x)
  Parameters:
    x (float)

asinh(x)
  Parameters:
    x (float)

atan(x)
  Parameters:
    x (float)

minMaxNormalize(_src, _length)
  : minMaxNormalize
  Parameters:
    _src (float)
    _length (int)

zScoreNormalize(_src, _length)
  : zScoreNormalize
  Parameters:
    _src (float)
    _length (int)

maxAbsNormalize(_src, _length)
  : maxAbsNormalize
  Parameters:
    _src (float)
    _length (int)

robustNormalize(_src, _length)
  : robustNormalize
  Parameters:
    _src (float)
    _length (int)

logTransform(_src)
  : logTransform
  Parameters:
    _src (float)

powerTransform(_src)
  : powerTransform
  Parameters:
    _src (float)

l1Normalize(_src, _length)
  : l1Normalize
  Parameters:
    _src (float)
    _length (int)

l2Normalize(_src, _length)
  : l2Normalize
  Parameters:
    _src (float)
    _length (int)

quantileTransform(_src, _length)
  : quantileTransform
  Parameters:
    _src (float)
    _length (int)

calc_operation(_src1, _src2, operation)
  : This function calculates based on selected operation
  Parameters:
    _src1 (float)
    _src2 (float)
    operation (string)

calc_and_normalize(_src1, _length, normMethod)
  : calc_and_normalize
  Parameters:
    _src1 (float)
    _length (int)
    normMethod (string)
MATHmathematics

ไลบรารีไพน์

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนได้เผยแพร่ Pine code นี้เป็นโอเพนซอร์ซไลบรารีเพื่อให้ Pine โปรแกรมเมอร์คนอื่นในชุมชนของเราสามารถนำไปใช้ซ้ำได้ ต้องขอบคุณผู้เขียน! คุณสามารถใช้ไลบรารีนี้ในแบบส่วนตัวหรือในการเผยแพร่แบบโอเพนซอร์สอื่น ๆ แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน


djmad|Bitblockart

คำจำกัดสิทธิ์ความรับผิดชอบ