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.

Script open-source

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questo script sui tuoi grafici?