OPEN-SOURCE SCRIPT
已更新 Fourier Analysis and Filtering [tbiktag]

This tool uses Fourier transform to decompose the input time series into its periodic constituents and seasonalities, in other words, its frequency components. It also can reconstruct the time-domain data while using only the frequency components within a user-defined range (band-pass filtering). Thereby, this tool can reveal the cyclical characteristics of the studied market.
USAGE
The source and the size of the input data can be chosen by the “Dataset Source” and “Dataset Size” options. Price, volume, or some technical indicator (e.g., RSI, MACD, etc.) can serve as a source of the input data.
“Action” defines the type of the plot that will be displayed. Two options are available:
- Fourier Analysis
If selected, the frequency spectrum of the squares of the Fourier coefficient magnitudes is displayed. The zero-frequency component is on the right. Since the magnitudes of half of the coefficients are repeated, the graph displays only half of the frequency components.
The squared magnitude of a given frequency component is a measure of its power, that is, its contribution to the total variance of the dataset. Thus, by analyzing the frequency-domain spectrum, one can identify the most prominent seasonalities and then visualize them by using the "Band-pass Filtering" option (see below). Note that the zero component stores information about the amount of data, so it is naturally higher when the data is not centered at zero.
By activating the "Info about Frequency Component" option, the user can display information about the power and frequency of the selected Fourier component.
-Band-pass Filter
This option reconstructs and plots the dataset in the time domain, blocking frequency components outside of the cutoff frequencies (defined by the input parameters “Upper Cutoff” and “Lower Cutoff” input parameters in the “Band-pass Filter Properties” section).
FURTHER READING
In general, Fourier analysis has a long history of attempted applications for analyzing price data and estimating market cycles. For example, see the paper by John Ehlers
mesasoftware.com/papers/FourierTransformForTraders.pdf
and also some tools available here on TradingView, such as:
“Function: Discrete Fourier Transform” by RicardoSantos
“Fourier series Model Of The Market” by @e2e4mfck
“Ehlers Discrete Fourier Transform” by cheatcountry
Thus, I tried to make this tool versatile and user-friendly so you all can experiment with your own analysis.
Enjoy and don't hesitate to leave your feedback in the comments below!
USAGE
The source and the size of the input data can be chosen by the “Dataset Source” and “Dataset Size” options. Price, volume, or some technical indicator (e.g., RSI, MACD, etc.) can serve as a source of the input data.
“Action” defines the type of the plot that will be displayed. Two options are available:
- Fourier Analysis
If selected, the frequency spectrum of the squares of the Fourier coefficient magnitudes is displayed. The zero-frequency component is on the right. Since the magnitudes of half of the coefficients are repeated, the graph displays only half of the frequency components.
The squared magnitude of a given frequency component is a measure of its power, that is, its contribution to the total variance of the dataset. Thus, by analyzing the frequency-domain spectrum, one can identify the most prominent seasonalities and then visualize them by using the "Band-pass Filtering" option (see below). Note that the zero component stores information about the amount of data, so it is naturally higher when the data is not centered at zero.
By activating the "Info about Frequency Component" option, the user can display information about the power and frequency of the selected Fourier component.
-Band-pass Filter
This option reconstructs and plots the dataset in the time domain, blocking frequency components outside of the cutoff frequencies (defined by the input parameters “Upper Cutoff” and “Lower Cutoff” input parameters in the “Band-pass Filter Properties” section).
FURTHER READING
In general, Fourier analysis has a long history of attempted applications for analyzing price data and estimating market cycles. For example, see the paper by John Ehlers
mesasoftware.com/papers/FourierTransformForTraders.pdf
and also some tools available here on TradingView, such as:
“Function: Discrete Fourier Transform” by RicardoSantos
“Fourier series Model Of The Market” by @e2e4mfck
“Ehlers Discrete Fourier Transform” by cheatcountry
Thus, I tried to make this tool versatile and user-friendly so you all can experiment with your own analysis.
Enjoy and don't hesitate to leave your feedback in the comments below!
發行說明
Added the option to adjust the scale of the filtered data to the original input time series.+ cosmetic changes in the code
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
DISCLAIMER: I am not a financial advisor, and my scripts are for educational purposes only. Any trades you make are at your own risk.
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
DISCLAIMER: I am not a financial advisor, and my scripts are for educational purposes only. Any trades you make are at your own risk.
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。