TradingView
peacefulLizard50262
2022年12月23日午前1時34分

Band Pass Normalized Suite (BPNS) 

Micron Technology, Inc.NASDAQ

詳細

Outlier-Free Normalization and Band Pass Filtering

We present a technique for normalizing and filtering a given time series, source, in order to improve its stationarity and enhance its features. The technique includes two stages: outlier-free normalization and band pass filtering.

Outlier-Free Normalization:

In order to normalize source and reduce the impact of outliers, we first smooth the time series using an exponential moving average with a smoothing factor of alpha. The smoothed time series is then normalized by subtracting the minimum value within a given lookback period, dev_lookback, and dividing the result by the range (maximum - minimum) within the same lookback period. Outliers are detected and excluded from the normalization process by identifying values that are more than outlier_level standard deviations away from the exponentially smoothed average.

Band Pass Filtering:

After normalization, the time series is passed through a band pass filter to remove low and high frequency components. The specifics of the band pass filter implementation are not provided.

Code snippet:
bes(float source = close, float alpha = 0.7) =>
var float smoothed = na
smoothed := na(smoothed) ? source : alpha * source + (1 - alpha) * nz(smoothed[1])
max(source, outlier_level, dev_lookback)=>
var float max = na
src = array.new<float>()
stdev = math.abs((source - bes(source, 0.1))/ta.stdev(source, dev_lookback))
array.push(src, stdev < outlier_level ? source : -1.7976931348623157e+308)
max := math.max(nz(max[1]), array.get(src, 0))

min(source, outlier_level, dev_lookback) =>
var float min = na
src = array.new<float>()
stdev = math.abs((source - bes(source, 0.1))/ta.stdev(source, dev_lookback))
array.push(src, stdev < outlier_level ? source : 1.7976931348623157e+308)
min := math.min(nz(min[1]), array.get(src, 0))

min_max(src, outlier_level, dev_lookback) =>
(src - min(src, outlier_level, dev_lookback))/(max(src, outlier_level, dev_lookback) - min(src, outlier_level, dev_lookback)) * 100

To apply the outlier-free normalization and band pass filter to a given time series, source, the min_max() function can be called with the desired values for outlier_level and dev_lookback as arguments. For example:
normalized_source = min_max(source, 2, 50)

This will apply the outlier-free normalization and band pass filter to source, using an outlier_level of 2 standard deviations and a lookback period of 50 data points for both the normalization and outlier detection steps. The resulting normalized and filtered time series will be stored in normalized_source.

It is important to note that the choice of values for outlier_level and dev_lookback will have a significant impact on the resulting normalized and filtered time series. These values should be chosen carefully based on the characteristics of the input time series and the desired properties of the normalized and filtered output.

In conclusion, the outlier-free normalization and band pass filtering technique presented here provides a useful tool for preprocessing time series data and improving its stationarity and feature content. The flexibility of the method, through the choice of outlier_level and dev_lookback values, allows it to be tailored to the specific characteristics of the input time series.

リリースノート

chart fix
コメント
selene100
One of the best indicators I have ever found in Tradingview
peacefulLizard50262
@selene100, Thank you!
Ski5iS
This is ingenious!! very accurate, thanks for sharing this wonderful script!
peacefulLizard50262
@Ski5iS, You are very welcome! Im glad you like it! Try it out on btc all time 1w candles.
Ski5iS
@peacefulLizard50262, currently tested it in 1H TF, suprised by its results! As per your suggestion will switch to weekly to see the further outcome:-) I am using BPNS as a source on your other indicator "ROCCS" it has made simple rate of change into lethal weapon, insanely good. How can I set BPNS permanently as a source, by editing the script. Your help will be appreciated:-)
peacefulLizard50262
@Ski5iS, excellent! DM me and I will make you a custom script.
Ski5iS
@peacefulLizard50262, Now I got it why you asked to swtich to 1 week TF, noticed it is hitting both maximal and minimal values, followed-through with massive reversals.Great observation!
Mupsje
amazing code, thnx
peacefulLizard50262
@Mupsje, Thank you very much! :)
xmd1979
good script, thank you )
詳細