peacefulLizard50262

Sinusoidal High Pass Filter (SHPF)

Sinusoidal High Pass Filter

This script implements a sinusoidal high pass filter, which is a type of digital filter that is used to remove low frequency components from a signal. The filter is defined by a series of weights that are applied to the input data, with the weights being determined by a sinusoidal function. The resulting filtered signal is then plotted on a chart, allowing the user to visualize the effect of the filter on the original signal.

The script begins by defining the sinusoidal_hpf function, which takes three arguments: _series, _period, and _phase_shift. The _series argument is the input data series that will be filtered, and the _period argument determines the length of the filter. The _phase_shift argument is an optional parameter that allows the user to adjust the phase of the sinusoidal function that is used to calculate the filter weights.

The function then initializes a variable ma to 0.0, and loops through each data point in the input series, starting from the most recent and going back in time for the specified _period number of points. For each data point, the function calculates a weight using a sinusoidal function, and adds the weighted data point to the ma variable. Finally, the function returns the average of the weighted data points by dividing ma by the _period.

The script also includes user input fields for the Length and Phase Shift parameters, which allows the user to customize the filter according to their specific needs. The filtered signal is then plotted on a chart, along with a reference line at 0.

Overall, this script provides a useful tool for analyzing and processing financial data, and can be easily customized to fit the needs of the user.

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

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

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

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

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