PINE LIBRARY
LMAs

Library "LMAs"
Credits
Thank you to QuantraSystems for dynamic calculations.
Introduction
This lightweight library offers dynamic implementations of popular moving averages that adapt their length automatically as new bars are added to the chart.
Each function is built on a dynamic length formula:
len = math.min(maxLength, bar_index + 1)
This approach ensures that calculations begin as early as the first bar, allowing for smoother initialization and more consistent behavior across all timeframes. It’s especially useful in custom scripts that run from bar 0 or when historical data is limited.
Usage
You can use this library as a drop-in replacement for standard moving averages. It provides more flexibility and stability in live or backtesting environments where fixed-length indicators may delay or fail to initialize properly.
Why Use This?
• Works from the very first bar
• Avoids na values during early bars
• Great for real-time indicators, strategies, and bar-replay
• Clean and efficient code with dynamic behavior
How to Use
Import the library into your script and call any of the included functions just like you would with their native counterparts.
Summary
A lightweight Pine Script™ library offering dynamic moving averages that work seamlessly from the very first bar. Ideal for strategies and indicators requiring robust initialization and adaptive behavior.
SMA(sourceData, maxLength)
Dynamic SMA
Parameters:
sourceData (float)
maxLength (int)
EMA(src, length)
Dynamic EMA
Parameters:
src (float)
length (int)
DEMA(src, length)
Dynamic DEMA
Parameters:
src (float)
length (int)
TEMA(src, length)
Dynamic TEMA
Parameters:
src (float)
length (int)
WMA(src, length)
Dynamic WMA
Parameters:
src (float)
length (int)
HMA(src, length)
Dynamic HMA
Parameters:
src (float)
length (int)
VWMA(src, volsrc, length)
Dynamic VWMA
Parameters:
src (float)
volsrc (float)
length (int)
SMMA(src, length)
Dynamic SMMA
Parameters:
src (float)
length (int)
LSMA(src, length, offset)
Dynamic LSMA
Parameters:
src (float)
length (int)
offset (int)
RMA(src, length)
Dynamic RMA
Parameters:
src (float)
length (int)
ALMA(src, length, offset_sigma, sigma)
Dynamic ALMA
Parameters:
src (float)
length (int)
offset_sigma (float)
sigma (float)
ZLSMA(src, length)
Dynamic ZLSMA
Parameters:
src (float)
length (int)
FRAMA(src, length)
Parameters:
src (float)
length (int)
KAMA(src, length)
Dynamic KAMA
Parameters:
src (float)
length (int)
JMA(src, length, phase)
Dynamic JMA
Parameters:
src (float)
length (int)
phase (float)
T3(src, length, volumeFactor)
Dynamic T3
Parameters:
src (float)
length (int)
volumeFactor (float)
Credits
Thank you to QuantraSystems for dynamic calculations.
Introduction
This lightweight library offers dynamic implementations of popular moving averages that adapt their length automatically as new bars are added to the chart.
Each function is built on a dynamic length formula:
len = math.min(maxLength, bar_index + 1)
This approach ensures that calculations begin as early as the first bar, allowing for smoother initialization and more consistent behavior across all timeframes. It’s especially useful in custom scripts that run from bar 0 or when historical data is limited.
Usage
You can use this library as a drop-in replacement for standard moving averages. It provides more flexibility and stability in live or backtesting environments where fixed-length indicators may delay or fail to initialize properly.
Why Use This?
• Works from the very first bar
• Avoids na values during early bars
• Great for real-time indicators, strategies, and bar-replay
• Clean and efficient code with dynamic behavior
How to Use
Import the library into your script and call any of the included functions just like you would with their native counterparts.
Summary
A lightweight Pine Script™ library offering dynamic moving averages that work seamlessly from the very first bar. Ideal for strategies and indicators requiring robust initialization and adaptive behavior.
SMA(sourceData, maxLength)
Dynamic SMA
Parameters:
sourceData (float)
maxLength (int)
EMA(src, length)
Dynamic EMA
Parameters:
src (float)
length (int)
DEMA(src, length)
Dynamic DEMA
Parameters:
src (float)
length (int)
TEMA(src, length)
Dynamic TEMA
Parameters:
src (float)
length (int)
WMA(src, length)
Dynamic WMA
Parameters:
src (float)
length (int)
HMA(src, length)
Dynamic HMA
Parameters:
src (float)
length (int)
VWMA(src, volsrc, length)
Dynamic VWMA
Parameters:
src (float)
volsrc (float)
length (int)
SMMA(src, length)
Dynamic SMMA
Parameters:
src (float)
length (int)
LSMA(src, length, offset)
Dynamic LSMA
Parameters:
src (float)
length (int)
offset (int)
RMA(src, length)
Dynamic RMA
Parameters:
src (float)
length (int)
ALMA(src, length, offset_sigma, sigma)
Dynamic ALMA
Parameters:
src (float)
length (int)
offset_sigma (float)
sigma (float)
ZLSMA(src, length)
Dynamic ZLSMA
Parameters:
src (float)
length (int)
FRAMA(src, length)
Parameters:
src (float)
length (int)
KAMA(src, length)
Dynamic KAMA
Parameters:
src (float)
length (int)
JMA(src, length, phase)
Dynamic JMA
Parameters:
src (float)
length (int)
phase (float)
T3(src, length, volumeFactor)
Dynamic T3
Parameters:
src (float)
length (int)
volumeFactor (float)
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。