STD/Clutter-Filtered, Variety FIR Filters [Loxx]STD/Clutter-Filtered, Variety FIR Filters is a FIR filter explorer. The following FIR Digital Filters are included.
Rectangular - simple moving average
Hanning
Hamming
Blackman
Blackman/Harris
Linear weighted
Triangular
There are 10s of windowing functions like the ones listed above. This indicator will be updated over time as I create more windowing functions in Pine.
Uniform/Rectangular Window
The uniform window (also called the rectangular window) is a time window with unity amplitude for all time samples and has the same effect as not applying a window.
Use this window when leakage is not a concern, such as observing an entire transient signal.
The uniform window has a rectangular shape and does not attenuate any portion of the time record. It weights all parts of the time record equally. Because the uniform window does not force the signal to appear periodic in the time record, it is generally used only with functions that are already periodic within a time record, such as transients and bursts.
The uniform window is sometimes called a transient or boxcar window.
For sine waves that are exactly periodic within a time record, using the uniform window allows you to measure the amplitude exactly (to within hardware specifications) from the Spectrum trace.
Hanning Window
The Hanning window attenuates the input signal at both ends of the time record to zero. This forces the signal to appear periodic. The Hanning window offers good frequency resolution at the expense of some amplitude accuracy.
This window is typically used for broadband signals such as random noise. This window should not be used for burst or chirp source types or other strictly periodic signals. The Hanning window is sometimes called the Hann window or random window.
Hamming Window
Computers can't do computations with an infinite number of data points, so all signals are "cut off" at either end. This causes the ripple on either side of the peak that you see. The hamming window reduces this ripple, giving you a more accurate idea of the original signal's frequency spectrum.
Blackman
The Blackman window is a taper formed by using the first three terms of a summation of cosines. It was designed to have close to the minimal leakage possible. It is close to optimal, only slightly worse than a Kaiser window.
Blackman-Harris
This is the original "Minimum 4-sample Blackman-Harris" window, as given in the classic window paper by Fredric Harris "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform", Proceedings of the IEEE, vol 66, no. 1, pp. 51-83, January 1978. The maximum side-lobe level is -92.00974072 dB.
Linear Weighted
A Weighted Moving Average puts more weight on recent data and less on past data. This is done by multiplying each bar’s price by a weighting factor. Because of its unique calculation, WMA will follow prices more closely than a corresponding Simple Moving Average.
Triangular Weighted
Triangular windowing is known for very smooth results. The weights in the triangular moving average are adding more weight to central values of the averaged data. Hence the coefficients are specifically distributed. Some of the examples that can give a clear picture of the coefficients progression:
period 1 : 1
period 2 : 1 1
period 3 : 1 2 1
period 4 : 1 2 2 1
period 5 : 1 2 3 2 1
period 6 : 1 2 3 3 2 1
period 7 : 1 2 3 4 3 2 1
period 8 : 1 2 3 4 4 3 2 1
Read here to read about how each of these filters compare with each other: Windowing
What is a Finite Impulse Response Filter?
In signal processing, a finite impulse response (FIR) filter is a filter whose impulse response (or response to any finite length input) is of finite duration, because it settles to zero in finite time. This is in contrast to infinite impulse response (IIR) filters, which may have internal feedback and may continue to respond indefinitely (usually decaying).
The impulse response (that is, the output in response to a Kronecker delta input) of an Nth-order discrete-time FIR filter lasts exactly {\displaystyle N+1}N+1 samples (from first nonzero element through last nonzero element) before it then settles to zero.
FIR filters can be discrete-time or continuous-time, and digital or analog.
A FIR filter is (similar to, or) just a weighted moving average filter, where (unlike a typical equally weighted moving average filter) the weights of each delay tap are not constrained to be identical or even of the same sign. By changing various values in the array of weights (the impulse response, or time shifted and sampled version of the same), the frequency response of a FIR filter can be completely changed.
An FIR filter simply CONVOLVES the input time series (price data) with its IMPULSE RESPONSE. The impulse response is just a set of weights (or "coefficients") that multiply each data point. Then you just add up all the products and divide by the sum of the weights and that is it; e.g., for a 10-bar SMA you just add up 10 bars of price data (each multiplied by 1) and divide by 10. For a weighted-MA you add up the product of the price data with triangular-number weights and divide by the total weight.
Ultra Low Lag Moving Average's weights are designed to have MAXIMUM possible smoothing and MINIMUM possible lag compatible with as-flat-as-possible phase response.
What is a Clutter Filter?
For our purposes here, this is a filter that compares the slope of the trading filter output to a threshold to determine whether to shift trends. If the slope is up but the slope doesn't exceed the threshold, then the color is gray and this indicates a chop zone. If the slope is down but the slope doesn't exceed the threshold, then the color is gray and this indicates a chop zone. Alternatively if either up or down slope exceeds the threshold then the trend turns green for up and red for down. Fro demonstration purposes, an EMA is used as the moving average. This acts to reduce the noise in the signal.
Included
Bar coloring
Loxx's Expanded Source Types
Signals
Alerts
Related Indicators
STD/Clutter-Filtered, Kaiser Window FIR Digital Filter
STD- and Clutter-Filtered, Non-Lag Moving Average
Clutter-Filtered, D-Lag Reducer, Spec. Ops FIR Filter
STD-Filtered, Ultra Low Lag Moving Average
Triangular
AveragesLibrary "Averages"
Contains utilities for generating averages from arrays. Useful for manipulated or cleaned data.
triangular(src, startingWeight) Calculates the triangular weighted average of a set of values where the last value has the highest weight.
Parameters:
src : The array to derive the average from.
startingWeight : The weight to begin with when calculating the average. Higher numbers will decrease the bias.
weighted(src, weights, weightDefault) Calculates the weighted average of a set of values.
Parameters:
src : The array to derive the average from.
weights : The array containing the weights for the source.
weightDefault : The default value to use when a weight is NA.
triangularWeighted(src, weights, startingWeight) Calculates the weighted average of a set of values where the last value has the highest triangular multiple.
Parameters:
src : The array to derive the average from.
weights : The array containing the weights for the source.
startingWeight : The multiple to begin with when calculating the average. Higher numbers will decrease the bias.
exponential(src) Calculates the exponential average of a set of values where the last value has the highest weight.
Parameters:
src : The array to derive the average from.
arrayFrom(src, len, omitNA) Creates an array from the provided series (oldest to newest).
Parameters:
src : The array to derive from.
len : The target length of the array.
omitNA : If true, NA values will not be added to the array and the resultant array may be shorter than the target length.
Triangular Momentum Oscillator & Real Time Divergences [LuxAlgo]Oscillators are widely used in technical analysis and can return a large amount of information to the trader depending on their design. It is common to use oscillators to detect divergences with the price, divergences occur when the tops/bottoms made by the oscillator and price are negatively correlated.
The following oscillator is based on the momentum of a triangular moving average, hence the name "triangular momentum" because of the very smooth property of the triangular moving average, we aimed at a real-time detection of divergences instead of using more common methods such as relying on pivot high/low detection which are suitable for more noisy oscillators.
The oscillator can also be colored based on a gradient derived from the correlation between its output and the price which can be useful to detect when the oscillator is out of phase (significantly lagging or leading the price).
Settings
length : Period of the oscillator, higher values return a smoother output.
src : Input source of the indicator.
Show Lines : Show lines connecting the current top/bottom with the previous one made by the oscillator when a divergence is detected. True by default.
Color Based On Price/Oscillator Correlation : Allows the color of the oscillator to change based on its correlation with the price, with red colors suggesting a negative correlation.
Usages
The advantage of having a smoother oscillator for divergences detection is that it can be done in real-time since a top or bottom is present when the oscillator first difference cross 0. Smoother oscillators are also easier to interpret, however, they will still suffer from lag.
The divergences detected by the oscillator are regular divergences, where the oscillator leads price variations.
Using higher values of length allows the oscillator to filter out longer-term variations thus being smoother as a result.
By using the color mode based on the price/oscillator correlation we can see where the oscillator leads or lag the price, and since divergences are based on the price and oscillator going in the opposite direction we can have information where price might reverse.
It is also possible to interpret the oscillator without relying on the divergence detection, with a decreasing value of the oscillator indicating a downtrend and an increasing value indicating an uptrend.
The TMA Slope - TMSlope Oscillator The TMA Slope oscillator is a simple slope of a Triangular Moving Average compared and normalized with the Average True Range of the last 100 periods (default setting).
This specific version add 2 triggers to give trading signals according to the slope:
- Above superior trigger, the trend is bullish, so trading is “Buy”
- Below inferior trigger, the trend is bearish, trading is “Sell”
- If the slope is included between these 2 levels, the market is probably ranging and no new orders should be initiated
High Low Bands Backtest As the name suggests, High low bands are two bands surrounding the underlying’s
price. These bands are generated from the triangular moving averages calculated
from the underlying’s price. The triangular moving average is, in turn, shifted
up and down by a fixed percentage. The bands, thus formed, are termed as High
low bands. The main theme and concept of High low bands is based upon the triangular
moving average.
You can change long to short in the Input Settings
WARNING:
- For purpose educate only
- This script to change bars colors.
High Low Bands Strategy As the name suggests, High low bands are two bands surrounding the underlying’s
price. These bands are generated from the triangular moving averages calculated
from the underlying’s price. The triangular moving average is, in turn, shifted
up and down by a fixed percentage. The bands, thus formed, are termed as High
low bands. The main theme and concept of High low bands is based upon the triangular
moving average.
WARNING:
- This script to change bars colors.
Triangular Price Divergence Oscillator [DW]This is an experimental study designed to show discrepancies in price using the formula S(a/$) = S(a/b)*S(b/$).
For example: EUR/USD = (EUR/GBP)(GBP/USD), USD/JPY = (USD/CHF)(CHF/JPY), etc.
NOTE: If the pairs you entered do not fit this criteria, the results are invalid.
Different Charting types deliver different divergences.
Triangular Price Divergence [DW]This is an experimental study designed to show discrepancies in price using the formula S(a/$) = S(a/b)*S(b/$).
For example: EUR/USD = (EUR/GBP)(GBP/USD), USD/JPY = (USD/CHF)(CHF/JPY), etc.
NOTE: If the pairs you entered do not fit this criteria, the results are invalid.
Different Charting types deliver different divergences.
[RS]Triangular Moving Average Slope Indicator V1request for ChartArt: using swma() builtin function, for the function unsmoothed output just set length to 1.