OPEN-SOURCE SCRIPT

True Amplitude Envelopes (TAE)

The True Envelopes indicator is an adaptation of the True Amplitude Envelope (TAE) method, based on the research paper "Improved Estimation of the Amplitude Envelope of Time Domain Signals Using True Envelope Cepstral Smoothing" by Caetano and Rodet. This indicator aims to create an asymmetric price envelope with strong predictive power, closely following the methodology outlined in the paper.

Due to the inherent limitations of Pine Script, the indicator utilizes a Kernel Density Estimator (KDE) in place of the original Cepstral Smoothing technique described in the paper. While this approach was chosen out of necessity rather than superiority, the resulting method is designed to be as effective as possible within the constraints of the Pine environment.

This indicator is ideal for traders seeking an advanced tool to analyze price dynamics, offering insights into potential price movements while working within the practical constraints of Pine Script. Whether used in dynamic mode or with a static setting, the True Envelopes indicator helps in identifying key support and resistance levels, making it a valuable asset in any trading strategy.

Key Features:
  • Dynamic Mode: The indicator dynamically estimates the fundamental frequency of the price, optimizing the envelope generation process in real-time to capture critical price movements.
  • High-Pass Filtering: Uses a high-pass filtered signal to identify and smoothly interpolate price peaks, ensuring that the envelope accurately reflects significant price changes.
  • Kernel Density Estimation: Although implemented as a workaround, the KDE technique allows for flexible and adaptive smoothing of the envelope, aimed at achieving results comparable to the more sophisticated methods described in the original research.
  • Symmetric and Asymmetric Envelopes: Provides options to select between symmetric and asymmetric envelopes, accommodating various trading strategies and market conditions.
  • Smoothness Control: Features adjustable smoothness settings, enabling users to balance between responsiveness and the overall smoothness of the envelopes.

The True Envelopes indicator comes with a variety of input settings that allow traders to customize the behavior of the envelopes to match their specific trading needs and market conditions. Understanding each of these settings is crucial for optimizing the indicator's performance.

Main Settings
  • Source: This is the data series on which the indicator is applied, typically the closing price (close). You can select other price data like open, high, low, or a custom series to base the envelope calculations.
  • History: This setting determines how much historical data the indicator should consider when calculating the envelopes. A value of 0 will make the indicator process all available data, while a higher value restricts it to the most recent n bars. This can be useful for reducing the computational load or focusing the analysis on recent market behavior.
  • Iterations: This parameter controls the number of iterations used in the envelope generation algorithm. More iterations will typically result in a smoother envelope, but can also increase computation time. The optimal number of iterations depends on the desired balance between smoothness and responsiveness.
  • Kernel Style: The smoothing kernel used in the Kernel Density Estimator (KDE). Available options include Sinc, Gaussian, Epanechnikov, Logistic, and Triangular. Each kernel has different properties, affecting how the smoothing is applied. For example, Gaussian provides a smooth, bell-shaped curve, while Epanechnikov is more efficient computationally with a parabolic shape.
  • Envelope Style: This setting determines whether the envelope should be Static or Dynamic. The Static mode applies a fixed period for the envelope, while the Dynamic mode automatically adjusts the period based on the fundamental frequency of the price data. Dynamic mode is typically more responsive to changing market conditions.
  • High Q: This option controls the quality factor (Q) of the high-pass filter. Enabling this will increase the Q factor, leading to a sharper cutoff and more precise isolation of high-frequency components, which can help in better identifying significant price peaks.
  • Symmetric: This setting allows you to choose between symmetric and asymmetric envelopes. Symmetric envelopes maintain an equal distance from the central price line on both sides, while asymmetric envelopes can adjust differently above and below the price line, which might better capture market conditions where upside and downside volatility are not equal.
  • Smooth Envelopes: When enabled, this setting applies additional smoothing to the envelopes. While this can reduce noise and make the envelopes more visually appealing, it may also decrease their responsiveness to sudden market changes.

Dynamic Settings
  • Extra Detrend: This setting toggles an additional high-pass filter that can be applied when using a long filter period. The purpose is to further detrend the data, ensuring that the envelope focuses solely on the most recent price oscillations.
  • Filter Period Multiplier: This multiplier adjusts the period of the high-pass filter dynamically based on the detected fundamental frequency. Increasing this multiplier will lengthen the period, making the filter less sensitive to short-term price fluctuations.
  • Filter Period (Min) and Filter Period (Max): These settings define the minimum and maximum bounds for the high-pass filter period. They ensure that the filter period stays within a reasonable range, preventing it from becoming too short (and overly sensitive) or too long (and too sluggish).
  • Envelope Period Multiplier: Similar to the filter period multiplier, this adjusts the period for the envelope generation. It scales the period dynamically to match the detected price cycles, allowing for more precise envelope adjustments.
  • Envelope Period (Min) and Envelope Period (Max): These settings establish the minimum and maximum bounds for the envelope period, ensuring the envelopes remain adaptive without becoming too reactive or too slow.

Static Settings
  • Filter Period: In static mode, this setting determines the fixed period for the high-pass filter. A shorter period will make the filter more responsive to price changes, while a longer period will smooth out more of the price data.
  • Envelope Period: This setting specifies the fixed period used for generating the envelopes in static mode. It directly influences how tightly or loosely the envelopes follow the price action.
  • TAE Smoothing: This controls the degree of smoothing applied during the TAE process in static mode. Higher smoothing values result in more gradual envelope curves, which can be useful in reducing noise but may also delay the envelope’s response to rapid price movements.

Visual Settings
  • Top Band Color: This setting allows you to choose the color for the upper band of the envelope. This band represents the resistance level in the price action.
  • Bottom Band Color: Similar to the top band color, this setting controls the color of the lower band, which represents the support level.
  • Center Line Color: This is the color of the central price line, often referred to as the carrier. It represents the detrended price around which the envelopes are constructed.
  • Line Width: This determines the thickness of the plotted lines for the top band, bottom band, and center line. Thicker lines can make the envelopes more visible, especially when overlaid on price data.
  • Fill Alpha: This controls the transparency level of the shaded area between the top and bottom bands. A lower alpha value will make the fill more transparent, while a higher value will make it more opaque, helping to highlight the envelope more clearly.


The envelopes generated by the True Envelopes indicator are designed to provide a more precise and responsive representation of price action compared to traditional methods like Bollinger Bands or Keltner Channels. The core idea behind this indicator is to create a price envelope that smoothly interpolates the significant peaks in price action, offering a more accurate depiction of support and resistance levels.

One of the critical aspects of this approach is the use of a high-pass filtered signal to identify these peaks. The high-pass filter serves as an effective method of detrending the price data, isolating the rapid fluctuations in price that are often lost in standard trend-following indicators. By filtering out the lower frequency components (i.e., the trend), the high-pass filter reveals the underlying oscillations in the price, which correspond to significant peaks and troughs. These oscillations are crucial for accurately constructing the envelope, as they represent the most responsive elements of the price movement.

The algorithm works by first applying the high-pass filter to the source price data, effectively detrending the series and isolating the high-frequency price changes. This filtered signal is then used to estimate the fundamental frequency of the price movement, which is essential for dynamically adjusting the envelope to current market conditions. By focusing on the peaks identified in the high-pass filtered signal, the algorithm generates an envelope that is both smooth and adaptive, closely following the most significant price changes without overfitting to transient noise.

Compared to traditional envelopes and bands, such as Bollinger Bands and Keltner Channels, the True Envelopes indicator offers several advantages. Bollinger Bands, which are based on standard deviations, and Keltner Channels, which use the average true range (ATR), both tend to react to price volatility but do not necessarily follow the peaks and troughs of the price with precision. As a result, these traditional methods can sometimes lag behind or fail to capture sudden shifts in price momentum, leading to either false signals or missed opportunities.

In contrast, the True Envelopes indicator, by using a high-pass filtered signal and a dynamic period estimation, adapts more quickly to changes in price behavior. The envelopes generated by this method are less prone to the lag that often affects standard deviation or ATR-based bands, and they provide a more accurate representation of the price's immediate oscillations. This can result in better predictive power and more reliable identification of support and resistance levels, making the True Envelopes indicator a valuable tool for traders looking for a more responsive and precise approach to market analysis.

In conclusion, the True Envelopes indicator is a powerful tool that blends advanced theoretical concepts with practical implementation, offering traders a precise and responsive way to analyze price dynamics. By adapting the True Amplitude Envelope (TAE) method through the use of a Kernel Density Estimator (KDE) and high-pass filtering, this indicator effectively captures the most significant price movements, providing a more accurate depiction of support and resistance levels compared to traditional methods like Bollinger Bands and Keltner Channels. The flexible settings allow for extensive customization, ensuring the indicator can be tailored to suit various trading strategies and market conditions.
bandsBands and ChannelsCentered OscillatorsoscillaltorParallel ChannelVolatility

Скрипт с открытым кодом

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

Хотите использовать этот скрипт на графике?


Мои профили:

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