PINE LIBRARY
Обновлено

TA

226
█ TA Library

📊 OVERVIEW

TA is a Pine Script technical analysis library. This library provides 25+ moving averages and smoothing filters, from classic SMA/EMA to Kalman Filters and adaptive algorithms, implemented based on academic research.

🎯 Core Features
  • Academic Based - Algorithms follow original papers and formulas
  • Performance Optimized - Pre-calculated constants for faster response
  • Unified Interface - Consistent function design
  • Research Based - Integrates technical analysis research


🎯 CONCEPTS

Library Design Philosophy
This technical analysis library focuses on providing:

Academic Foundation
  • Algorithms based on published research papers and academic standards
  • Implementations that follow original mathematical formulations
  • Clear documentation with research references


Developer Experience
  • Unified interface design for consistent usage patterns
  • Pre-calculated constants for optimal performance
  • Comprehensive function collection to reduce development time
  • Single import statement for immediate access to all functions
  • Each indicator encapsulated as a simple function call - one line of code simplifies complexity


Technical Excellence
  • 25+ carefully implemented moving averages and filters
  • Support for advanced algorithms like Kalman Filter and MAMA/FAMA
  • Optimized code structure for maintainability and reliability
  • Regular updates incorporating latest research developments


🚀 USING THIS LIBRARY

Import Library
Pine Script®
//@version=6 import DCAUT/TA/1 as dta indicator("Advanced Technical Analysis", overlay=true)


Basic Usage Example
Pine Script®
// Classic moving average combination ema20 = ta.ema(close, 20) kama20 = dta.kama(close, 20) plot(ema20, "EMA20", color.red, 2) plot(kama20, "KAMA20", color.green, 2)


Advanced Trading System
Pine Script®
// Adaptive moving average system kama = dta.kama(close, 20, 2, 30) [mamaValue, famaValue] = dta.mamaFama(close, 0.5, 0.05) // Trend confirmation and entry signals bullTrend = kama > kama[1] and mamaValue > famaValue bearTrend = kama < kama[1] and mamaValue < famaValue longSignal = ta.crossover(close, kama) and bullTrend shortSignal = ta.crossunder(close, kama) and bearTrend plot(kama, "KAMA", color.blue, 3) plot(mamaValue, "MAMA", color.orange, 2) plot(famaValue, "FAMA", color.purple, 2) plotshape(longSignal, "Buy", shape.triangleup, location.belowbar, color.green) plotshape(shortSignal, "Sell", shape.triangledown, location.abovebar, color.red)


📋 FUNCTIONS REFERENCE

ewma(source, alpha)
Calculates the Exponentially Weighted Moving Average with dynamic alpha parameter.

Parameters:
source (series float): Series of values to process.
alpha (series float): The smoothing parameter of the filter.

Returns: (float) The exponentially weighted moving average value.

dema(source, length)
Calculates the Double Exponential Moving Average (DEMA) of a given data series.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.

Returns: (float) The calculated Double Exponential Moving Average value.

tema(source, length)
Calculates the Triple Exponential Moving Average (TEMA) of a given data series.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.

Returns: (float) The calculated Triple Exponential Moving Average value.

zlema(source, length)
Calculates the Zero-Lag Exponential Moving Average (ZLEMA) of a given data series. This indicator attempts to eliminate the lag inherent in all moving averages.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.

Returns: (float) The calculated Zero-Lag Exponential Moving Average value.

tma(source, length)
Calculates the Triangular Moving Average (TMA) of a given data series. TMA is a double-smoothed simple moving average that reduces noise.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.

Returns: (float) The calculated Triangular Moving Average value.

frama(source, length)
Calculates the Fractal Adaptive Moving Average (FRAMA) of a given data series. FRAMA adapts its smoothing factor based on fractal geometry to reduce lag. Developed by John Ehlers.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.

Returns: (float) The calculated Fractal Adaptive Moving Average value.

kama(source, length, fastLength, slowLength)
Calculates Kaufman's Adaptive Moving Average (KAMA) of a given data series. KAMA adjusts its smoothing based on market efficiency ratio. Developed by Perry J. Kaufman.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the efficiency calculation.
fastLength (simple int): Fast EMA length for smoothing calculation. Optional. Default is 2.
slowLength (simple int): Slow EMA length for smoothing calculation. Optional. Default is 30.

Returns: (float) The calculated Kaufman's Adaptive Moving Average value.

t3(source, length, volumeFactor)
Calculates the Tilson Moving Average (T3) of a given data series. T3 is a triple-smoothed exponential moving average with improved lag characteristics. Developed by Tim Tillson.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.
volumeFactor (simple float): Volume factor affecting responsiveness. Optional. Default is 0.7.

Returns: (float) The calculated Tilson Moving Average value.

ultimateSmoother(source, length)
Calculates the Ultimate Smoother of a given data series. Uses advanced filtering techniques to reduce noise while maintaining responsiveness. Based on digital signal processing principles by John Ehlers.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the smoothing calculation.

Returns: (float) The calculated Ultimate Smoother value.

kalmanFilter(source, processNoise, measurementNoise)
Calculates the Kalman Filter of a given data series. Optimal estimation algorithm that estimates true value from noisy observations. Based on the Kalman Filter algorithm developed by Rudolf Kalman (1960).

Parameters:
source (series float): Series of values to process.
processNoise (simple float): Process noise variance (Q). Controls adaptation speed. Optional. Default is 0.05.
measurementNoise (simple float): Measurement noise variance (R). Controls smoothing. Optional. Default is 1.0.

Returns: (float) The calculated Kalman Filter value.

mcginleyDynamic(source, length)
Calculates the McGinley Dynamic of a given data series. McGinley Dynamic is an adaptive moving average that adjusts to market speed changes. Developed by John R. McGinley Jr.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the dynamic calculation.

Returns: (float) The calculated McGinley Dynamic value.

mama(source, fastLimit, slowLimit)
Calculates the Mesa Adaptive Moving Average (MAMA) of a given data series. MAMA uses Hilbert Transform Discriminator to adapt to market cycles dynamically. Developed by John F. Ehlers.

Parameters:
source (series float): Series of values to process.
fastLimit (simple float): Maximum alpha (responsiveness). Optional. Default is 0.5.
slowLimit (simple float): Minimum alpha (smoothing). Optional. Default is 0.05.

Returns: (float) The calculated Mesa Adaptive Moving Average value.

fama(source, fastLimit, slowLimit)
Calculates the Following Adaptive Moving Average (FAMA) of a given data series. FAMA follows MAMA with reduced responsiveness for crossover signals. Developed by John F. Ehlers.

Parameters:
source (series float): Series of values to process.
fastLimit (simple float): Maximum alpha (responsiveness). Optional. Default is 0.5.
slowLimit (simple float): Minimum alpha (smoothing). Optional. Default is 0.05.

Returns: (float) The calculated Following Adaptive Moving Average value.

mamaFama(source, fastLimit, slowLimit)
Calculates Mesa Adaptive Moving Average (MAMA) and Following Adaptive Moving Average (FAMA).

Parameters:
source (series float): Series of values to process.
fastLimit (simple float): Maximum alpha (responsiveness). Optional. Default is 0.5.
slowLimit (simple float): Minimum alpha (smoothing). Optional. Default is 0.05.

Returns: ([float, float]) Tuple containing [MAMA, FAMA] values.

laguerreFilter(source, length, gamma, order)
Calculates the standard N-order Laguerre Filter of a given data series. Standard Laguerre Filter uses uniform weighting across all polynomial terms. Developed by John F. Ehlers.

Parameters:
source (series float): Series of values to process.
length (simple int): Length for UltimateSmoother preprocessing.
gamma (simple float): Feedback coefficient (0-1). Lower values reduce lag. Optional. Default is 0.8.
order (simple int): The order of the Laguerre filter (1-10). Higher order increases lag. Optional. Default is 8.

Returns: (float) The calculated standard Laguerre Filter value.

laguerreBinomialFilter(source, length, gamma)
Calculates the Laguerre Binomial Filter of a given data series. Uses 6-pole feedback with binomial weighting coefficients. Developed by John F. Ehlers.

Parameters:
source (series float): Series of values to process.
length (simple int): Length for UltimateSmoother preprocessing.
gamma (simple float): Feedback coefficient (0-1). Lower values reduce lag. Optional. Default is 0.5.

Returns: (float) The calculated Laguerre Binomial Filter value.

superSmoother(source, length)
Calculates the Super Smoother of a given data series. SuperSmoother is a second-order Butterworth filter from aerospace technology. Developed by John F. Ehlers.

Parameters:
source (series float): Series of values to process.
length (simple int): Period for the filter calculation.

Returns: (float) The calculated Super Smoother value.

rangeFilter(source, length, multiplier)
Calculates the Range Filter of a given data series. Range Filter reduces noise by filtering price movements within a dynamic range.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the average range calculation.
multiplier (simple float): Multiplier for the smooth range. Higher values increase filtering. Optional. Default is 2.618.

Returns: ([float, int, float, float]) Tuple containing filtered value, trend direction, upper band, and lower band.

qqe(source, rsiLength, rsiSmooth, qqeFactor)
Calculates the Quantitative Qualitative Estimation (QQE) of a given data series. QQE is an improved RSI that reduces noise and provides smoother signals. Developed by Igor Livshin.

Parameters:
source (series float): Series of values to process.
rsiLength (simple int): Number of bars for the RSI calculation. Optional. Default is 14.
rsiSmooth (simple int): Number of bars for smoothing the RSI. Optional. Default is 5.
qqeFactor (simple float): QQE factor for volatility band width. Optional. Default is 4.236.

Returns: ([float, float]) Tuple containing smoothed RSI and QQE trend line.

sslChannel(source, length)
Calculates the Semaphore Signal Level (SSL) Channel of a given data series. SSL Channel provides clear trend signals using moving averages of high and low prices.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.

Returns: ([float, float]) Tuple containing SSL Up and SSL Down lines.

ma(source, length, maType)
Calculates a Moving Average based on the specified type. Universal interface supporting all moving average algorithms.

Parameters:
source (series float): Series of values to process.
length (simple int): Number of bars for the moving average calculation.
maType (simple MaType): Type of moving average to calculate. Optional. Default is SMA.

Returns: (float) The calculated moving average value based on the specified type.

atr(length, maType)
Calculates the Average True Range (ATR) using the specified moving average type. Developed by J. Welles Wilder Jr.

Parameters:
length (simple int): Number of bars for the ATR calculation.
maType (simple MaType): Type of moving average to use for smoothing. Optional. Default is RMA.

Returns: (float) The calculated Average True Range value.

macd(source, fastLength, slowLength, signalLength, maType, signalMaType)
Calculates the Moving Average Convergence Divergence (MACD) with customizable MA types. Developed by Gerald Appel.

Parameters:
source (series float): Series of values to process.
fastLength (simple int): Period for the fast moving average.
slowLength (simple int): Period for the slow moving average.
signalLength (simple int): Period for the signal line moving average.
maType (simple MaType): Type of moving average for main MACD calculation. Optional. Default is EMA.
signalMaType (simple MaType): Type of moving average for signal line calculation. Optional. Default is EMA.

Returns: ([float, float, float]) Tuple containing MACD line, signal line, and histogram values.

dmao(source, fastLength, slowLength, maType)
Calculates the Dual Moving Average Oscillator (DMAO) of a given data series. Uses the same algorithm as the Percentage Price Oscillator (PPO), but can be applied to any data series.

Parameters:
source (series float): Series of values to process.
fastLength (simple int): Period for the fast moving average.
slowLength (simple int): Period for the slow moving average.
maType (simple MaType): Type of moving average to use for both calculations. Optional. Default is EMA.

Returns: (float) The calculated Dual Moving Average Oscillator value as a percentage.

continuationIndex(source, length, gamma, order)
Calculates the Continuation Index of a given data series. The index represents the Inverse Fisher Transform of the normalized difference between an UltimateSmoother and an N-order Laguerre filter. Developed by John F. Ehlers, published in TASC 2025.09.

Parameters:
source (series float): Series of values to process.
length (simple int): The calculation length.
gamma (simple float): Controls the phase response of the Laguerre filter. Optional. Default is 0.8.
order (simple int): The order of the Laguerre filter (1-10). Optional. Default is 8.

Returns: (float) The calculated Continuation Index value.

📚 RELEASE NOTES

v1.0 (2025.09.24)
  • ✅ 25+ technical analysis functions
  • ✅ Complete adaptive moving average series (KAMA, FRAMA, MAMA/FAMA)
  • ✅ Advanced signal processing filters (Kalman, Laguerre, SuperSmoother, UltimateSmoother)
  • ✅ Performance optimized with pre-calculated constants and efficient algorithms
  • ✅ Unified function interface design following TradingView best practices
  • ✅ Comprehensive moving average collection (DEMA, TEMA, ZLEMA, T3, etc.)
  • ✅ Volatility and trend detection tools (QQE, SSL Channel, Range Filter)
  • ✅ Continuation Index - Latest research from TASC 2025.09
  • ✅ MACD and ATR calculations supporting multiple moving average types
  • ✅ Dual Moving Average Oscillator (DMAO) for arbitrary data series analysis
Информация о релизе
v2 (2025.09.25)
  • Added stochastic() function - Stochastic Oscillator with customizable high/low sources and flexible smoothing
  • Added rsi() function - Relative Strength Index with customizable moving average types for gain/loss smoothing


Added Functions:

stochastic(source, highSource, lowSource, kLength, kSmooth, dSmooth, maType)
Calculates the Stochastic Oscillator (%K and %D lines). Measures the current value relative to its range over a specified period, providing momentum and overbought/oversold signals. Standard interpretation: Above 80 = overbought, Below 20 = oversold.

Parameters:
source (series float): Series of values to process (typically close).
highSource (series float): Series of high values.
lowSource (series float): Series of low values.
kLength (simple int): Period for %K calculation.
kSmooth (simple int): Smoothing period for %K (1=Fast, 3=Slow).
dSmooth (simple int): Smoothing period for %D signal line.
maType (simple MaType): Moving average type. Optional. Default is SMA.

Returns: ([float, float]) Tuple containing %K and %D stochastic values.

rsi(source, length, maType)
Calculates the Relative Strength Index (RSI) with customizable smoothing. RSI measures the magnitude of recent price changes to evaluate overbought or oversold conditions. Developed by J. Welles Wilder Jr. Standard interpretation: Above 70 = overbought, Below 30 = oversold.

Parameters:
source (series float): Series of values to process (typically close price).
length (simple int): Period for RSI calculation (typically 14).
maType (simple MaType): Moving average type for gain/loss smoothing. Optional. Default is RMA (Wilder's original).

Returns: (float) The calculated RSI value (0-100 range).
Информация о релизе
v3 (2025.10.11)
  • Added bb() function - Bollinger Bands with customizable moving average types
  • Added kc() function - Keltner Channel with dual MA type support for middle band and ATR smoothing
  • Added dc() function - Donchian Channel supporting arbitrary data series
  • Standardized all channel functions to return [basis, upper, lower] tuple format (aligned with TradingView official convention)


Added Functions:

bb(source, length, multiplier, maType)
Calculates Bollinger Bands with customizable moving average type. Bollinger Bands consist of a middle band (moving average) and two outer bands placed at standard deviations above and below the middle band. Developed by John Bollinger in the 1980s. Standard interpretation: Price touching upper band suggests overbought, lower band suggests oversold.

Parameters:
source (series float): Series of values to process (typically close price).
length (simple int): Period for moving average calculation (typically 20).
multiplier (simple float): Standard deviation multiplier for band width (typically 2.0). Optional. Default is 2.0.
maType (simple MaType): Moving average type for middle band calculation. Optional. Default is SMA (Bollinger's original).

Returns: ([float, float, float]) Tuple containing middle band (basis), upper band, and lower band values.

kc(source, length, atrLength, multiplier, maType, atrMaType)
Calculates Keltner Channel with customizable moving average types. Keltner Channel uses a moving average as the middle line and ATR to set the channel bands. Unlike Bollinger Bands which use standard deviation, Keltner uses ATR for band width, making it smoother and less prone to whipsaws. Originally developed by Chester Keltner (1960), modernized by Linda Bradford Raschke.

Parameters:
source (series float): Series of values for middle band calculation (typically close price).
length (simple int): Period for middle band moving average (typically 20).
atrLength (simple int): Period for ATR calculation (typically 10 or equal to length).
multiplier (simple float): ATR multiplier for band width (typically 2.0). Optional. Default is 2.0.
maType (simple MaType): Moving average type for middle band. Optional. Default is EMA (modern standard).
atrMaType (simple MaType): Moving average type for ATR smoothing. Optional. Default is RMA (Wilder's method).

Returns: ([float, float, float]) Tuple containing middle band (basis), upper band, and lower band values.

dc(highSeries, lowSeries, length)
Calculates Donchian Channel based on highest and lowest values. Donchian Channel identifies the highest and lowest values over a specified period, creating a breakout channel. This is a pure price action indicator without any smoothing or volatility adjustments. Developed by Richard Donchian, known as the "father of trend following" (1970s). Standard interpretation: Breakout above upper band = buy signal, below lower band = sell signal.

Parameters:
highSeries (series float): Series of high values (typically high price, but can be any data series).
lowSeries (series float): Series of low values (typically low price, but can be any data series).
length (simple int): Lookback period for highest/lowest calculation (typically 20 or 50).

Returns: ([float, float, float]) Tuple containing middle band (basis), upper band, and lower band values.

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.