█ OVERVIEW

This script implements a suite of tools for identifying and utilizing dominant cycles in time series data, as introduced by John Ehlers in the "Linear Predictive Filters And Instantaneous Frequency" article featured in the January 2025 edition of TASC's Traders' Tips. Dominant cycle information can help traders adapt their indicators and strategies to changing market conditions.


█ CONCEPTS

Conventional technical indicators and strategies often rely on static, unchanging parameters, which may fail to account for the dynamic nature of market data. In his article, John Ehlers applies digital signal processing principles to address this issue, introducing linear predictive filters to identify cyclic information for adapting indicators and strategies to evolving market conditions.

This approach treats market data as a complex series in the time domain. Analyzing the series in the frequency domain reveals information about its cyclic components. To reduce the impact of frequencies outside a range of interest and focus on a specific range of cycles, Ehlers applies second-order highpass and lowpass filters to the price data, which attenuate or remove wavelengths outside the desired range. This band-limited analysis isolates specific parts of the frequency spectrum for various trading styles, e.g., longer wavelengths for position trading or shorter wavelengths for swing trading.

After filtering the series to produce band-limited data, Ehlers applies a linear predictive filter to predict future values a few bars ahead. The filter, calculated based on the techniques proposed by Lloyd Griffiths, adaptively minimizes the error between the latest data point and prediction, successively adjusting its coefficients to align with the band-limited series. The filter's coefficients can then be applied to generate an adaptive estimate of the band-limited data's structure in the frequency domain and identify the dominant cycle.


█ USAGE

This script implements the following tools presented in the article:
  • Griffiths Predictor
    This tool calculates a linear predictive filter to forecast future data points in band-limited price data. The crosses between the prediction and signal lines can provide potential trade signals.
  • Griffiths Spectrum
    This tool calculates a partial frequency spectrum of the band-limited price data derived from the linear predictive filter's coefficients, displaying a color-coded representation of the frequency information in the pane.
  • Griffiths Dominant Cycle
    This tool compares the cyclic components within the partial spectrum and identifies the frequency with the highest power, i.e., the dominant cycle. Traders can use this dominant cycle information to tune other indicators and strategies, which may help promote better alignment with dynamic market conditions.


Notes on parameters

Bandpass boundaries:
In the article, Ehlers recommends an upper bound of 125 bars or higher to capture longer-term cycles for position trading. He recommends an upper bound of 40 bars and a lower bound of 18 bars for swing trading. If traders use smaller lower bounds, Ehlers advises a minimum of eight bars to minimize the potential effects of aliasing.

Data length:
The Griffiths predictor can use a relatively small data length, as autocorrelation diminishes rapidly with lag. However, for optimal spectrum and dominant cycle calculations, the length must match or exceed the upper bound of the bandpass filter. Ehlers recommends avoiding excessively long lengths to maintain responsiveness to shorter-term cycles.
Cyclesehlerstasc

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الرمز في المنشور يخضع لقواعد‎‎قوانين الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟


Tools and ideas for all Pine coders: tradingview.com/u/PineCoders/
Pine news broadcasts: t.me/PineCodersSquawkBox or twitter.com/PineCoders
TASC: traders.com/
يعمل أيضًا:

إخلاء المسؤولية