GMC Trend FilterAvoid Fake Signals, and identify the trend.
How it works ?
- it calculates main trend direction by using the length that is user-defined. so you can change it as you wish
- then it calculates trend direction for each 9 lower lengths. if you set the length = 20 then the lengths are 19, 18,...11
- and it checks if the trend directions that came from lower lengths is same or not with main trend direction.
- it changes the trend color of the ribbon.
Filter
Ehlers Median Average Adaptive Filter [CC]The Median Average Adaptive Filter was created by John Ehlers and this is another in my current series of undiscovered gems. I'm sure you are all saying but Franklin, Ehlers doesn't have any undiscovered gems but in this case you would be wrong. This was actually an indicator so buried on the internet that I had to use the wayback machine to find the original source code. Ehlers notoriously hates adaptive moving averages which is funny because he has made a decent amount of them. This is a very unique indicator that uses a while loop to adjust the length and I thought it deserved some extra recognition from the TV community. I have included strong buy and sell signals in addition to normal ones so strong signals are darker in color and normal signals are lighter in color. Buy when the line turns green and sell when it turns red.
Let me know if there are any other scripts or indicators you would like to see me publish!
Reverse Moving Average Convergence Divergence [CC]The Reverse Macd was created by Johnny Dough (Stocks and Commodities Jan 2012) and this is another indicator in my ongoing series to find those hidden gems. This indicator works in a few very powerful ways. For example the blue line shows you what the current price would be if the macd was at the macd level that you choose. I set the default to 0 but feel free to change it if you want. This will give you short to medium term info by telling you if it is an uptrend when the price is above the blue line or vice versa. It also creates the reverse macd line and it's signal line by using information from the previous day to decompile the macd and show you the price that it would be at if the macd was at that level. It turns this into a new moving average that closely tracks price movements and with the two competing signals, gives you more than enough info to find the perfect entry and exit points. Like always I have included strong buy and sell signals in addition to normal ones so darker colors are strong signals and lighter colors are normal signals. Buy when the line is green and sell when it is red.
Let me know if there are any other scripts you would like to see me publish!
Tillson IE/2 [CC]The IE/2 was created by Tim Tillson (Stocks and Commodities Jan 1998) and this is a practically undiscovered gem because in that same article he goes on to to create the popular T3 moving average and the GDEma but practically no one seemed to notice the IE2 or maybe it is just my imagination. Anyway this indicator name is short for Integral of Linear Regression Slope + Endpoint Moving Average / 2 so you can why it was shortened to IE/2. Like the name implies this takes two variations of smoothing that complement each other and averages them together to in theory get the benefits of each. The EPMA is much noiser but follows the data more closely and the complete opposite for the ILRS so you can see the idea in action. Like all of my indicators I include strong buy and sell signals in addition to normal ones so strong signals are darker in color and normal signals are lighter in color. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators or scripts you would like to see me publish!
Ehlers Hann Relative Strength Index [CC]The Hann Relative Strength Index was created by John Ehlers (Stocks and Commodities Jan 2022 pgs 26-28) and this indicator builds upon his Hann Window Indicator to create an unique rsi indicator that doesn't rely on overbought or oversold levels to determine a reversal point and also provides a very superior smoothing without any of the lag associated with traditional smoothing. A much more useful RSI than the standard version in my honest opinion. Short term you buy when the line turns green and sell when it turns red. Medium to long term you buy when the indicator rises above the 0 line and sell when it falls below the 0 line. I have included strong buy and sell signals in addition to normal ones so strong signals are darker in color and normal signals are lighter in color.
Let me know if there are any other indicators or scripts you would like to see me publish!
Time Session Filter - Visual Only - @Davi117 Simple visual adjustable time filter to highlight certain times of the day.
For instance if you only trade between 06:00 and 10:00 etc.
Includes Time Zone Selector using GMT
E.g if you live in London then you time zone will be just GMT, else if you live in Paris it would be GMT+1.
Ensure Trading View's time zone selection in the bottom right to the left of the Auto Scale toggle, is also set also set to your time zone, else it will be misaligned.
Ehlers_Super_SmootherThe 2 Pole and 3 Pole Super Smoother Filters were developed by John Ehlers and described in "Chapter 13: Super Smother" of his book Cybernetic Analysis for Stocks and Futures .
The 2 Pole Smoother is described as being a better approximation of price, whereas the 3 Pole Smoother has superior smoothing.
Library "Ehlers_Super_Smoother"
Provides the functions to calculate Double and Triple Exponentional Moving Averages (DEMA & TEMA)
twoPole(_source, _length) Calculates 2 Pole Ehlers Super Smoother Filter
Parameters:
_source : -> Open, Close, High, Low, etc ('close' is used if no argument is supplied)
_length : -> Ehlers Super Smoother length
Returns: 2 Pole Ehlers Super Smoothing to an input source at the specified input length
threePole(_source, _length) Calculates 3 Pole Ehlers Super Smoother Filter
Parameters:
_source : -> Open, Close, High, Low, etc ('close' is used if no argument is supplied)
_length : -> Ehlers Super Smoother length
Returns: 3 Pole Ehlers Super Smoothing to an input source at the specified input length
Laguerre FilterThis is the Laguerre Filter by John F. Ehlers. He published this filter design in the article Time Wrap - Without Space Travel.
This study open gamma and weight of each filter for to customize the filter design.
For example, setting gamma to 0.2, 0.7, 0.8,0.8 and weight 1,2,2,1, the curve is a very nice simulation to ALMZ(50),
setting gamma to 0.3, 0.3, 0.8, 0.9 and weight of 1,3,3,1 will produce a curve close to EMA(20),
basically, the Laguerre filter can simulate various type of moving averages.
The beauty of this Filter is it use only one data point and 3 filters output to reproduce various moving average, it is
an innovative approach to develop smoothing lines, and to avoid whipsaws on the price.
Each filter can be plotted for evaluation too.
Data of the first filter allows to input any bar, eg. 0 for current bar, 1 for one previous, for the purpose to evaluate forecasting idea.
Follows Ehlers' paper, this study allows to plot the weighted average line with all filter off.
[DSPrated] Modified EMD for swing tradeModified Ehlers Empirical Mode Decomposition indicator for swing trade based on Butterworth 2nd order IIR filter
Description
This script is inspired by John Ehlers' TECHNICAL PAPERS - Truncating Indicators and Empirical Mode Decomposition. But instead of detecting trend it applies to finding swing regions.
Also here is suggested canonical DSP approach for designing coefficients for Butterworth 2nd order IIR filters - bandpass and lowpass.
Besides, truncated IIR filter with configurable length parameter is used. It worth mentioning, that although truncated filter is more robust than original IIR, it losses specified properties (bandpass) the more, the less is length parameter.
Butterworth Bandpass Infinite Impulse Response (IIR) Filter
This is the 2nd order Butterworth Bandpass Infinite Impulse Response (IIR) Filter based on the transform from the 1st order lowpass
Based on the example 8.8 on p476 from book Digital Signal Processing: A Practical Approach 2nd Edition by Emmanuel C. Ifeachor (Author), Barrie W. Jervis (Author)
It differs from Ehlers BandPass Filter only in the way you initialize input parameters. Here you can define cutoff periods of region of interest. For example on a timeframe, where one bar equals 1 hour you can define periods 18 and 22, which mean you'll see the swing intensity of price movement components within specified range.
Parameters
Source
Period 1 - cutoff period of bandpass begining
Period 2 - cutoff period of the end of bandpass
length - IIR truncation length
Concept of usage
Within specified bandpass this indicator eliminates the Trend line according to Ehlers EMD. The bandpass periods is recommended to choose accordingly to personal comfortable trading style and timeframe.
The trendline painted with 3 colors depending of the next modes:
up tend - green
cycling - black
downtrend - red
So the buy signal is generated when trend line in cycling mode and filtered component reaches it local minimum.
And the sell signal is generated when trend line in cycling mode and filtered component reaches it local maximum.
Secure long and short zones marked with color.
---
// TO DO
// - compare truncated and full version using signal generators
// - apply zero lag filter modification fordetectig ternd and swing peroids
// - implement strategy scripts
// - implement somewhat "true" EMD with sevral IMFs(intrinsic mode function)
// - better description?
// - parameter optimization
---
Please, feel free to report any issues and improvement suggestions.
Ehlers Deviation Scaled Super Smoother [CC]The Deviation Scaled Super Smoother was created by John Ehlers and this is an excellent moving average that changes direction very quickly and can keep up with the current underlying trend. This indicator works by applying a Hann Windowed Moving Average to the stock's momentum and scaling that by the Root Mean Square and then using that value in the input for a Super Smoother . I have included strong buy and sell signals in addition to normal ones so lighter colors are normal signals and darker colors are strong ones. Buy when the line turns green and sell when it turns red.
Let me know if there are any other scripts you would like to see me publish!
FFTLibraryLibrary "FFTLibrary" contains a function for performing Fast Fourier Transform (FFT) along with a few helper functions. In general, FFT is defined for complex inputs and outputs. The real and imaginary parts of formally complex data are treated as separate arrays (denoted as x and y). For real-valued data, the array of imaginary parts should be filled with zeros.
FFT function
fft(x, y, dir) : Computes the one-dimensional discrete Fourier transform using an in-place complex-to-complex FFT algorithm . Note: The transform also produces a mirror copy of the frequency components, which correspond to the signal's negative frequencies.
Parameters:
x : float array, real part of the data, array size must be a power of 2
y : float array, imaginary part of the data, array size must be the same as x ; for real-valued input, y must be an array of zeros
dir : string, options = , defines the direction of the transform: forward" (time-to-frequency) or inverse (frequency-to-time)
Returns: x, y : tuple (float array, float array), real and imaginary parts of the transformed data (original x and y are changed on output)
Helper functions
fftPower(x, y) : Helper function that computes the power of each frequency component (in other words, Fourier amplitudes squared).
Parameters:
x : float array, real part of the Fourier amplitudes
y : float array, imaginary part of the Fourier amplitudes
Returns: power : float array of the same length as x and y , Fourier amplitudes squared
fftFreq(N) : Helper function that returns the FFT sample frequencies defined in cycles per timeframe unit. For example, if the timeframe is 5m, the frequencies are in cycles/(5 minutes).
Parameters:
N : int, window length (number of points in the transformed dataset)
Returns: freq : float array of N, contains the sample frequencies (with zero at the start).
Ehlers Average Error Filter [CC]The Average Error Filter was created by John Ehlers and this is a variation of a Zero Lag Exponential Moving Average that uses a Super Smoother to filter out the noise and then uses a second Super Smoother of the difference between the current price and the filtered data. This works well as a trendline and does give out a few false signals like all indicators inevitably do but most signals do a good job of keeping up with the trend and providing clear entries and exits when the trend changes. I have included strong buy and sell signals in addition to normal ones so like always darker colors are strong signals and lighter colors are normal ones. Buy when the line turns green and sell when it turns red.
Let me know if there are any other scripts you would like to see me publish!
Nadaraya-Watson Envelope [LuxAlgo]This indicator builds upon the previously posted Nadaraya-Watson smoothers. Here we have created an envelope indicator based on Kernel Smoothing with integrated alerts from crosses between the price and envelope extremities. Unlike the Nadaraya-Watson estimator, this indicator follows a contrarian methodology.
Please note that by default this indicator can be subject to repainting. Users can use a non-repainting smoothing method available from the settings. The triangle labels are designed so that the indicator remains useful in real-time applications.
🔶 USAGE
🔹 Non Repainting
This tool can outline extremes made by the prices. This is achieved by estimating the underlying trend in the price, then calculating the mean absolute deviations from it, the obtained result is added/subtracted to the estimated underlying trend.
The non-repainting method estimates the underlying trend in price using an "endpoint Nadaraya-Watson estimator", and would return similar results to more classical band indicators.
🔹 Repainting
The repainting method makes use of the Nadaraya-Watson estimator to estimate the underlying trend in the price. The construction of the band extremities is the same as in the non-repainting method.
We can expect the price to reverse when crossing one of the envelope extremities. Crosses between the price and the envelopes extremities are indicated with triangles on the chart.
For real-time applications, triangles are always displayed when a cross occurs and remain displayed at the location it first appeared even if the cross is no longer visible after a recalculation of the envelope.
By popular demand, we have integrated alerts for this indicator from the crosses between the price and the envelope extremities. However, we do not recommend this precise method to be used alone or for solely real-time applications. We do not have data supporting the performance of this tool over more classical bands/envelope/channels indicators.
🔶 SETTINGS
Bandwidth: Controls the degree of smoothness of the envelopes, with higher values returning smoother results.
Mult: Controls the envelope width.
Source: Input source of the indicator.
Repainting Smoothing: Determine if a repainting or non-repainting method should be used for the calculation of the indicator.
🔶 RELATED SCRIPTS
For more information on the Nadaraya-Watson estimator see:
Ehlers High Pass Filter [CC]The High Pass Filter was created by John Ehlers and I would define this indicator as both a momentum indicator but also a predictor indicator. This does a pretty good job of predicting future price action even though I have double smoothed it to provide clear buy and sell signals. I will be publishing quite a few more Ehlers indicators very soon so stay tuned. This indicator can be interpreted in a few different ways but most importantly it is a mid to long term sell signal when the indicator falls below the zero line and vice versa. It also falls below the zero line when the underlying price data starts losing momentum so it can be used also as a price reversal. I have included strong buy and sell signals in addition to normal ones so darker colors are strong signals and lighter colors are normal signals. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish!
Ehlers Cycle BandPass Filter [CC]The Cycle BandPass Filter was created by John Ehlers (Cycle Modes and Trend Modes) and this is an alternate to the default BandPass Filter by changing some settings. This will be another series I will be introducing showing some indicators created by Ehlers and that didn't get much attention. This identifies the underlying cycle in the price data and these indicators aren't very common so I want to introduce more of these to tv. Buying and selling with these indicators can be a bit tricky but overall what Ehlers recommends is to buy at the lowest point and sell at the highest point to capture the underlying cycle. I have included strong buy and sell signals as darker colors and normal signals as lighter colors. Buy when the line turns green and sell when it turns red.
Let me know if there are any other scripts you would like to see me publish!
Nadaraya-Watson Smoothers [LuxAlgo]The following tool smoothes the price data using various methods derived from the Nadaraya-Watson estimator, a simple Kernel regression method. This method makes use of the Gaussian kernel as a weighting function.
Users have the option to use a non-repainting as well as a repainting method, see the USAGE section for more information.
🔶 USAGE
🔹 Non Repainting
When Repainting Smoothing is disabled the returned indicator acts similarly to a regular causal moving average. This result could be described as an "endpoint Nadaraya-Watson estimator".
Unlike a regular moving average whose degree of smoothness is commonly determined by the length of its calculation window, the degree of smoothness of the proposed indicator is determined by the bandwidth setting, with a higher value returning smoother results.
In the above chart, a bandwidth value of 50 is used. An increasing value of the smoother is indicative of an uptrend, while a decreasing value is indicative of a downtrend.
🔹 Repainting
Non-causal smoothing methods have found low support from technical analysts because they tend to repaint. Yet, they can provide powerful insights such as estimating underlying trends in the price as well as seeing how far prices deviate from them. They can also make drawing certain patterns easier and can help see underlying structures in the price more clearly.
Using higher bandwidth values allows for estimating longer-term trends in the price.
Triangular labels highlight points where the direction of the estimator change. This allows for the identification of tops and bottoms in the underlying trend which can be compared to the actual price tops and bottoms.
Note that multiple labels can appear in real time, highlighting real-time changes in the estimator's direction. The most recent label on a series of labels is the first to appear. This can eventually be useful for the real-time predictive application of the estimator. However, it is not a usage we particularly recommend.
🔶 DETAILS
The Nadaraya-Watson estimator can be described as a series of weighted averages using a specific normalized kernel as a weighting function. For each point of the estimator at time t , the peak of the kernel is located at time t , as such the highest weights are attributed to values neighboring the price located at time t .
A lower bandwidth value would contribute toward a more important weighting of the price at a precise point and would as such less smooth results. In the case where our bandwidth is so small that the resulting kernel is just an impulse, we would get the raw price back.
However, when the bandwidth is sufficiently large, prices would be weighted similarly, thus resulting in a result closer to the price mean.
It can be interesting to note that due to the nature of the estimator and its weighting procedure, real-time results would not deviate drastically for points in the estimator near the center of the calculation window.
🔶 SETTINGS
Bandwidth : controls the bandwidth of the Gaussian kernel, with higher values returning smoother results.
Src : Input source of the kernel regression.
Repainting Smoothing : Determine if the smoothing method should repaint or not. If disabled the "endpoint Nadaraya-Watson estimator" is returned.
Ehlers Simple Window Indicator [CC]The Simple Window Indicator was created by John Ehlers (Stocks and Commodities Sep 2021) and this is the last of the 4 new indicators that he published in the latest issue of Stocks & Commodities. Since these are all part of a series, the idea behind each indicator is the exact same. The only difference is of course the calculation for each indicator. This script is different mostly because it is extremely noisy in comparison so I had to smooth it twice to provide clear buy and sell signals. Window functions are used in digital signal processing to filter out noise and the end result is an oscillator that centers around the 0 line. The easy way to understand these indicators that I will be publishing and those are that when they are above 0, it usually means an uptrend and below 0 then a downtrend. For more immediate signals, I have included both normal and strong buy and sell signals so darker colors for strong signals and lighter colors for normal signals. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like me to publish!
Ehlers Triangle Window Indicator [CC]The Triangle Window Indicator was created by John Ehlers (Stocks and Commodities Sep 2021) and this is one of 4 new indicators that he published in the latest issue of Stocks & Commodities and I will be publishing the last one tomorrow. Since these are all part of a series, the idea behind each indicator is the exact same. The only difference is of course the calculation for each indicator. Window functions are used in digital signal processing to filter out noise and the end result is an oscillator that centers around the 0 line. The easy way to understand these indicators that I will be publishing and those are that when they are above 0, it usually means an uptrend and below 0 then a downtrend. For more immediate signals, I have included both normal and strong buy and sell signals so darker colors for strong signals and lighter colors for normal signals. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like me to publish!
Ehlers Hamming Window Indicator [CC]The Hamming Window Indicator was created by John Ehlers (Stocks and Commodities Sep 2021) and this is one of 4 new indicators that he published in the latest issue of Stocks & Commodities and I will be publishing the other 2 in the next few days. Since these are all part of a series, the idea behind each indicator is the exact same. The only difference is of course the calculation for each indicator. Window functions are used in digital signal processing to filter out noise and the end result is an oscillator that centers around the 0 line. The easy way to understand these indicators that I will be publishing and those are that when they are above 0, it usually means an uptrend and below 0 then a downtrend. For more immediate signals, I have included both normal and strong buy and sell signals so darker colors for strong signals and lighter colors for normal signals. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like me to publish!
Ehlers Hann Window Indicator [CC]The Hann Window Indicator was created by John Ehlers (Stocks & Commodities Sep 2021) and this is one of 4 new indicators that he published in the latest issue of Stocks & Commodities and I will be publishing the other 3 in the next few days. Since these are all part of a series, the idea behind each indicator is the exact same. The only difference is of course the calculation for each indicator. Window functions are used in digital signal processing to filter out noise and the end result is an oscillator that centers around the 0 line. The easy way to understand these indicators that I will be publishing and those are that when they are above 0, it usually means an uptrend and below 0 then a downtrend. For more immediate signals, I have included both normal and strong buy and sell signals so darker colors for strong signals and lighter colors for normal signals. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like me to publish!
Ehlers Optimum Predictor [CC]The Optimum Predictor was created by John Ehlers (Rocket Science For Traders pgs 209-210) and this indicator does a pretty good job of predicting major market moves. When the blue line crosses over the red line then this indicator is predicting an upcoming uptrend and when the blue line crosses under the red line then it is predicting an upcoming downtrend. Ehlers recommends using this indicator with an entire trading system to filter out any bad signals but most of the signals it gives are pretty accurate. He uses advanced digital signal processing to predict the future prices and uses it in an ema formula for the calculation. There are several ways to interpret this indicator: you can look for crossovers, you can also look for when the indicator goes above 0 for a general uptrend or below 0 for a general downtrend.
Let me know if there are any other scripts you would like to see me publish!
Ehlers Adaptive Bandpass Filter [CC]The Adaptive Bandpass Filter was created by John Ehlers (Cycle Analytics For Traders pgs 153-156) and this uses his autocorrelation code to provide the adaptive lengths to use for the underlying bandpass filter. The bandpass filter is a common way in digital signal processing to filter out the underlying noise in the data. It can actually be turned into a leading indicator by changing the bw variable to a smaller amount. Since this indicator is adaptive using the cycle period, the buy and sell signals are different compared to the normal bandpass filter. Buy signals for this indicator according to Ehlers are when the line is red and the line is under the oversold line (also red) then you buy when the indicator line turns green and then you exit when the indicator line turns red and is above the overbought line. This indicator doesn't provide clear buy and sell signals in all circumstances but generally speaking buy when the indicator line turns green and sell when it turns red. Feel free to experiment with this one.
Let me know if there are any other scripts you would like to see me publish!
Fast Fourier Transform (FFT) FilterDear friends!
I'm happy to present an implementation of the Fast Fourier Transform (FFT) algorithm. The script uses the FFT procedure to decompose the input time series into its cyclical constituents, in other words, its frequency components , and convert it back to the time domain with modified frequency content, that is, to filter it.
Input Description and Usage
Source and Length :
Indicates where the data comes from and the size of the lookback window used to build the dataset.
Standardize Input Dataset :
If enabled, the dataset is preprocessed by subtracting its mean and normalizing the result by the standard deviation, which is sometimes useful when analyzing seasonalities. This procedure is not recommended when using the FFT filter for smoothing (see below), as it will not preserve the average of the dataset.
Show Frequency-Domain Power Spectrum :
When enabled, the results of Fourier analysis (for the last price bar!) are plotted as a frequency-domain power spectrum , where “power” is a measure of the significance of the component in the dataset. In the spectrum, lower frequencies (longer cycles) are on the right, higher frequencies are on the left. The graph does not display the 0th component, which contains only information about the mean value. Frequency components that are allowed to pass through the filter (see below) are highlighted in magenta .
Dominant Cycles, Rows :
If this option is activated, the periods and relative powers of several dominant cyclical components that is, those that have a higher power, are listed in the table. The number of the component in the power spectrum (N) is shown in the first column. The number of rows in the table is defined by the user.
Show Inverse Fourier Transform (Filtered) :
When enabled, the reconstructed and filtered time-domain dataset (for the last price bar!) is displayed.
Apply FFT Filter in a Moving Window :
When enabled, the FFT filter with the same parameters is applied to each bar. The last data point of the reconstructed and filtered dataset is used to build a new time series. For example, by getting rid of high-frequency noise, the FFT filter can make the data smoother. By removing slowly evolving low-frequency components (including non-periodic constituents), one can reveal and analyze shorter cycles. Since filtering is done in real-time in a moving window (similar to the moving average), the modified data can potentially be used as part of a strategy and be subjected to other technical indicators.
Lowest Allowed N :
Indicates the number of the lowest frequency component used in the reconstructed time series.
Highest Allowed N :
Indicates the number of the highest frequency component used in the reconstructed time series.
Filtering Time Range block:
Specifies the time range over which real-time FFT filtering is applied. The reason for the presence of this block is that the FFT procedure is relatively computationally intensive. Therefore, the script execution may encounter the time limit imposed by TradingView when all historical bars are processed.
As always, I look forward to your feedback!
Also, leave a comment if you'd be interested in the tutorial on how to use this tool and/or in seeing the FFT filter in a strategy.