PINE LIBRARY

MovingAveragesLibrary

Library "MovingAveragesLibrary"
This is a library allowing one to select between many different Moving Average formulas to smooth out any float variable.

You can use this library to apply a Moving Average function to any series of data as long as your source is a float.

The default application would be for applying Moving Averages onto your chart. However, the scope of this library is beyond that. Any indicator or strategy you are building can benefit from this library.

You can apply different types of smoothing and moving average functions to your indicators, momentum oscillators, average true range calculations, support and resistance zones, envelope bands, channels, and anything you can think of to attempt to smooth out noise while finding a delicate balance against lag.

If you are developing an indicator, you can use the 'ave_func' to allow your users to select any Moving Average for any function or variable by creating an input string with the following structure:

var_name = input.string(<title>, <defval>, <options>)

Where the types of Moving Average you would like to be provided would be included in options.

Example:

i_ma_type = input.string(title = "Moving Average Type", defval = "Hull Moving Average", options = )

Where you would add after options the strings I have included for you at the top of the PineScript for your convenience.

Then for the output you desire, simply call 'ave_func' like so:

ma = ave_func(source, length, i_ma_type)

Now the plotted Moving Average will be the same as what you or your users select from the Input.

ema(src, len) Exponential Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: Float value.

sma(src, len) Simple Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: Float value.

rma(src, len) Relative Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: Float value.

wma(src, len) Weighted Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: Float value.

dv2(len) Donchian V2 function.
  Parameters:
    len: Lookback length to use.
  Returns: Open + Close / 2 for the selected length.

ModFilt(src, len) Modular Filter smoothing function.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: Float value.

EDSMA(src, len) Ehlers Dynamic Smoothed Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: EDSMA smoothing.

dema(x, t) Double Exponential Moving Average.
  Parameters:
    x: Series to use ('close' is used if no argument is supplied).
    t: Lookback length to use.
  Returns: DEMA smoothing.

tema(src, len) Triple Exponential Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: TEMA smoothing.

smma(x, t) Smoothed Moving Average.
  Parameters:
    x: Series to use ('close' is used if no argument is supplied).
    t: Lookback length to use.
  Returns: SMMA smoothing.

vwma(x, t) Volume Weighted Moving Average.
  Parameters:
    x: Series to use ('close' is used if no argument is supplied).
    t: Lookback length to use.
  Returns: VWMA smoothing.

hullma(x, t) Hull Moving Average.
  Parameters:
    x: Series to use ('close' is used if no argument is supplied).
    t: Lookback length to use.
  Returns: Hull smoothing.

covwma(x, t) Coefficient of Variation Weighted Moving Average.
  Parameters:
    x: Series to use ('close' is used if no argument is supplied).
    t: Lookback length to use.
  Returns: COVWMA smoothing.

frama(x, t) Fractal Reactive Moving Average.
  Parameters:
    x: Series to use ('close' is used if no argument is supplied).
    t: Lookback length to use.
  Returns: FRAMA smoothing.

kama(x, t) Kaufman's Adaptive Moving Average.
  Parameters:
    x: Series to use ('close' is used if no argument is supplied).
    t: Lookback length to use.
  Returns: KAMA smoothing.

donchian(len) Donchian Calculation.
  Parameters:
    len: Lookback length to use.
  Returns: Average of the highest price and the lowest price for the specified look-back period.

tma(src, len) Triangular Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: TMA smoothing.

VAMA(src, len) Volatility Adjusted Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: VAMA smoothing.

Jurik(src, len) Jurik Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: JMA smoothing.

MCG(src, len) McGinley smoothing.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: McGinley smoothing.

zlema(series, length) Zero Lag Exponential Moving Average.
  Parameters:
    series: Series to use ('close' is used if no argument is supplied).
    length: Lookback length to use.
  Returns: ZLEMA smoothing.

xema(src, len) Optimized Exponential Moving Average.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    len: Lookback length to use.
  Returns: XEMA smoothing.

EhlersSuperSmoother(src, lower) Ehlers Super Smoother.
  Parameters:
    src: Series to use ('close' is used if no argument is supplied).
    lower: Smoothing value to use.
  Returns: Ehlers Super smoothing.

EhlersEmaSmoother(sig, smoothK, smoothP) Ehlers EMA Smoother.
  Parameters:
    sig: Series to use ('close' is used if no argument is supplied).
    smoothK: Lookback length to use.
    smoothP: Smothing value to use.
  Returns: Ehlers EMA smoothing.

ave_func(in_src, in_len, in_type) Returns the source after running it through a Moving Average function.
  Parameters:
    in_src: Series to use ('close' is used if no argument is supplied).
    in_len: Lookback period to be used for the Moving Average function.
    in_type: Type of Moving Average function to use. Must have a string input to select the options from that MUST match the type-casing in the function below.
  Returns: The source as a float after running it through the Moving Average function.
Bitcoin (Cryptocurrency)inputsMATHtechindicatorzerolagema

ספריית Pine

ברוח TradingView אמיתית, המחבר פרסם קוד Pine זה כספריית קוד פתוח כדי שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומים אחרים בקוד פתוח, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית.


Build Your First Trading Strategy With Us!
crackingcryptocurrency.com

Copy Trade Me On Fairdesk - Earn While You Sleep!
fairdesk.com/signup?vipCode=CrackingCrypto
גם על:

כתב ויתור