Possible RSI [Loxx]Possible RSI is a normalized, variety second-pass normalized, Variety RSI with Dynamic Zones and optionl High-Pass IIR digital filtering of source price input. This indicator includes 7 types of RSI.
High-Pass Fitler (optional)
The Ehlers Highpass Filter is a technical analysis tool developed by John F. Ehlers. Based on aerospace analog filters, this filter aims at reducing noise from price data. Ehlers Highpass Filter eliminates wave components with periods longer than a certain value. This reduces lag and makes the oscialltor zero mean. This turns the RSI output into something more similar to Stochasitc RSI where it repsonds to price very quickly.
First Normalization Pass
RSI (Relative Strength Index) is already normalized. Hence, making a normalized RSI seems like a nonsense... if it was not for the "flattening" property of RSI. RSI tends to be flatter and flatter as we increase the calculating period--to the extent that it becomes unusable for levels trading if we increase calculating periods anywhere over the broadly recommended period 8 for RSI. In order to make that (calculating period) have less impact to significant levels usage of RSI trading style in this version a sort of a "raw stochastic" (min/max) normalization is applied.
Second-Pass Variety Normalization Pass
There are three options to choose from:
1. Gaussian (Fisher Transform), this is the default: The Fisher Transform is a function created by John F. Ehlers that converts prices into a Gaussian normal distribution. The normaliztion helps highlights when prices have moved to an extreme, based on recent prices. This may help in spotting turning points in the price of an asset. It also helps show the trend and isolate the price waves within a trend.
2. Softmax: The softmax function, also known as softargmax: or normalized exponential function, converts a vector of K real numbers into a probability distribution of K possible outcomes. It is a generalization of the logistic function to multiple dimensions, and used in multinomial logistic regression. The softmax function is often used as the last activation function of a neural network to normalize the output of a network to a probability distribution over predicted output classes, based on Luce's choice axiom.
3. Regular Normalization (devaitions about the mean): Converts a vector of K real numbers into a probability distribution of K possible outcomes without using log sigmoidal transformation as is done with Softmax. This is basically Softmax without the last step.
Dynamic Zones
As explained in "Stocks & Commodities V15:7 (306-310): Dynamic Zones by Leo Zamansky, Ph .D., and David Stendahl"
Most indicators use a fixed zone for buy and sell signals. Here’ s a concept based on zones that are responsive to past levels of the indicator.
One approach to active investing employs the use of oscillators to exploit tradable market trends. This investing style follows a very simple form of logic: Enter the market only when an oscillator has moved far above or below traditional trading lev- els. However, these oscillator- driven systems lack the ability to evolve with the market because they use fixed buy and sell zones. Traders typically use one set of buy and sell zones for a bull market and substantially different zones for a bear market. And therein lies the problem.
Once traders begin introducing their market opinions into trading equations, by changing the zones, they negate the system’s mechanical nature. The objective is to have a system automatically define its own buy and sell zones and thereby profitably trade in any market — bull or bear. Dynamic zones offer a solution to the problem of fixed buy and sell zones for any oscillator-driven system.
An indicator’s extreme levels can be quantified using statistical methods. These extreme levels are calculated for a certain period and serve as the buy and sell zones for a trading system. The repetition of this statistical process for every value of the indicator creates values that become the dynamic zones. The zones are calculated in such a way that the probability of the indicator value rising above, or falling below, the dynamic zones is equal to a given probability input set by the trader.
To better understand dynamic zones, let's first describe them mathematically and then explain their use. The dynamic zones definition:
Find V such that:
For dynamic zone buy: P{X <= V}=P1
For dynamic zone sell: P{X >= V}=P2
where P1 and P2 are the probabilities set by the trader, X is the value of the indicator for the selected period and V represents the value of the dynamic zone.
The probability input P1 and P2 can be adjusted by the trader to encompass as much or as little data as the trader would like. The smaller the probability, the fewer data values above and below the dynamic zones. This translates into a wider range between the buy and sell zones. If a 10% probability is used for P1 and P2, only those data values that make up the top 10% and bottom 10% for an indicator are used in the construction of the zones. Of the values, 80% will fall between the two extreme levels. Because dynamic zone levels are penetrated so infrequently, when this happens, traders know that the market has truly moved into overbought or oversold territory.
Calculating the Dynamic Zones
The algorithm for the dynamic zones is a series of steps. First, decide the value of the lookback period t. Next, decide the value of the probability Pbuy for buy zone and value of the probability Psell for the sell zone.
For i=1, to the last lookback period, build the distribution f(x) of the price during the lookback period i. Then find the value Vi1 such that the probability of the price less than or equal to Vi1 during the lookback period i is equal to Pbuy. Find the value Vi2 such that the probability of the price greater or equal to Vi2 during the lookback period i is equal to Psell. The sequence of Vi1 for all periods gives the buy zone. The sequence of Vi2 for all periods gives the sell zone.
In the algorithm description, we have: Build the distribution f(x) of the price during the lookback period i. The distribution here is empirical namely, how many times a given value of x appeared during the lookback period. The problem is to find such x that the probability of a price being greater or equal to x will be equal to a probability selected by the user. Probability is the area under the distribution curve. The task is to find such value of x that the area under the distribution curve to the right of x will be equal to the probability selected by the user. That x is the dynamic zone.
7 Types of RSI
See here to understand which RSI types are included:
Included:
Bar coloring
4 signal types
Alerts
Loxx's Expanded Source Types
Loxx's Variety RSI
Loxx's Dynamic Zones
Elhers
DSS of Advanced Kaufman AMA [Loxx]DSS of Advanced Kaufman AMA is a double smoothed stochastic oscillator using a Kaufman adaptive moving average with the option of using the Jurik Fractal Dimension Adaptive calculation. This helps smooth the stochastic oscillator thereby making it easier to identify reversals and trends.
What is the double smoothed stochastic?
The Double Smoothed Stochastic indicator was created by William Blau. It applies Exponential Moving Averages (EMAs) of two different periods to a standard Stochastic %K. The components that construct the Stochastic Oscillator are first smoothed with the two EMAs. Then, the smoothed components are plugged into the standard Stochastic formula to calculate the indicator.
What is KAMA?
Developed by Perry Kaufman, Kaufman's Adaptive Moving Average (KAMA) is a moving average designed to account for market noise or volatility . KAMA will closely follow prices when the price swings are relatively small and the noise is low. KAMA will adjust when the price swings widen and follow prices from a greater distance. This trend-following indicator can be used to identify the overall trend, time turning points and filter price movements.
What is the efficiency ratio?
In statistical terms, the Efficiency Ratio tells us the fractal efficiency of price changes. ER fluctuates between 1 and 0, but these extremes are the exception, not the norm. ER would be 1 if prices moved up 10 consecutive periods or down 10 consecutive periods. ER would be zero if price is unchanged over the 10 periods.
What is Jurik Fractal Dimension?
There is a weak and a strong way to measure the random quality of a time series.
The weak way is to use the random walk index ( RWI ). You can download it from the Omega web site. It makes the assumption that the market is moving randomly with an average distance D per move and proposes an amount the market should have changed over N bars of time. If the market has traveled less, then the action is considered random, otherwise it's considered trending.
The problem with this method is that taking the average distance is valid for a Normal (Gaussian) distribution of price activity. However, price action is rarely Normal, with large price jumps occuring much more frequently than a Normal distribution would expect. Consequently, big jumps throw the RWI way off, producing invalid results.
The strong way is to not make any assumption regarding the distribution of price changes and, instead, measure the fractal dimension of the time series. Fractal Dimension requires a lot of data to be accurate. If you are trading 30 minute bars, use a multi-chart where this indicator is running on 5 minute bars and you are trading on 30 minute bars.
Included
-Toggle bar colors on/offf
Hybrid, Zero lag, Adaptive cycle MACD [Loxx]TASC's March 2008 edition Traders' Tips includes an article by John Ehlers titled "Measuring Cycle Periods," and describes the use of bandpass filters to estimate the length, in bars, of the currently dominant price cycle.
What are Dominant Cycles and Why should we use them?
Even the most casual chart reader will be able to spot times when the market is cycling and other times when longer-term trends are in play. Cycling markets are ideal for swing trading however attempting to “trade the swing” in a trending market can be a recipe for disaster. Similarly, applying trend trading techniques during a cycling market can equally wreak havoc in your account. Cycle or trend modes can readily be identified in hindsight. But it would be useful to have an objective scientific approach to guide you as to the current market mode.
There are a number of tools already available to differentiate between cycle and trend modes. For example, measuring the trend slope over the cycle period to the amplitude of the cyclic swing is one possibility.
We begin by thinking of cycle mode in terms of frequency or its inverse, periodicity. Since the markets are fractal; daily, weekly, and intraday charts are pretty much indistinguishable when time scales are removed. Thus it is useful to think of the cycle period in terms of its bar count. For example, a 20 bar cycle using daily data corresponds to a cycle period of approximately one month.
When viewed as a waveform, slow-varying price trends constitute the waveform's low frequency components and day-to-day fluctuations (noise) constitute the high frequency components. The objective in cycle mode is to filter out the unwanted components--both low frequency trends and the high frequency noise--and retain only the range of frequencies over the desired swing period. A filter for doing this is called a bandpass filter and the range of frequencies passed is the filter's bandwidth .
Indicator Features
-Zero lag or Regular MACD/signal calculation
- Fixed or Band-pass Dominant Cycle for MACD and Signal MA period inputs
-10 different moving average options for both MACD and Signal MA calculations
-Separate Band-pass Dominant Cycle calculations for both MACD and Signal MA calculations
- Slow-to-Fast Band-pass Dominant Cycle input to tweak the ratio of MACD MA input periods as they relate to each other
John Ehlers - The Price RadioPrice curves consist of much noise and little signal. For separating the latter from the former, John Ehlers proposed in the Stocks&Commodities May 2021 issue an unusual approach: Treat the price curve like a radio wave. Apply AM and FM demodulating technology for separating trade signals from the underlying noise.
reference: financial-hacker.com
RSI With Noise Elimination Technology (John Ehlers)Indicator translation to Pinescript requested by cookie_crusher on Twitter. The "RSI With Noise Elimination Technology" (NET) is an indicator developed by John Elhers.
The indicator is simply a rolling Kendall rank correlation coefficient of a normalized momentum oscillator (a version of the RSI introduced by Elhers in the May 2018 issue of Stocks & Commodities). It can be interesting to note that the absolute value of this oscillator is equal to the efficiency ratio used in the Kaufman adaptive moving average (KAMA).
Even if both the normalized momentum oscillator and rolling Rank correlation are scale-invariant oscillators, they do not have the same behaviors when increasing their settings, that is the normalized momentum oscillator scale range will become lower while the Kendall correlation will stay close to 1/-1, here is a closed-form approximation of the mean of the absolute value of the normalized momentum oscillator absolute value (efficiency ratio):
E (er) ≈ 1/√p
Where E (er) is the mean of the efficiency ratio er while p is the period of the efficiency ratio, as such the scale of the normalized momentum oscillator will shrink with a higher period, maybe that both are not intended to be plotted at the same time but that's what the original code does.
It's still a coll indicator. The link to J. Elhers article is in the code.
Center Of Linearity - A More Efficient Alternative To Elhers CGIntroduction
The center of gravity oscillator (CG) is one of the oscillators presented in Elhers book "cybernetic analysis for stocks and futures". This oscillator can be described as a bandpass filter centered around 0, its simplicity is ridiculous yet this indicator managed to get a pretty great popularity, this might be due to Elhers saying that he has substantial advantages over conventional oscillators used in technical analysis.
Today i propose a more efficient estimation of the center of gravity oscillator, this estimation will only use one convolution, while the original and other estimations use 2. I will also explain everything about the center of gravity oscillator, because even if its name can be imposing its actually super easy to understand.
The Center Of Gravity Oscillator
The CG oscillator is a bandpass filter, in short it filter high frequencies components as well as low frequency ones, this is why the oscillator is both smooth (no high frequencies) as well as detrended (no low frequencies), and therefore the oscillator focus exclusively on the cycles.
Its calculation is simple, its just a linearly weighted moving average minus a simple moving average wma - sma , this is not what is showcased in its book, but the result is just the same, the only thing that change is the scale, this is why some estimates have a weird scale that is not centered around 0, the output is technically the same but the scale isn't, however the scale of an oscillator isn't a big deal as long as the oscillator is centered around 0 and we don't plan to use it as input for overlay indicators.
If you are familiar with moving averages you'll know that the wma is more reactive than the sma, this is because more recent values have higher weights, and since subtracting a low-pass filter with another one conserve the smoothness while removing low-frequency components, we end up with a bandpass filter, yay!
Why "Center" Of Gravity ?
Elhers explain the idea behind this title with a pretty blurry analogy, so i'll try to give a visual explanation, we said earlier that the center of gravity was simply : wma - sma, ok lets look at their respective impulse responses,
Those are basically the weights of each filters, also called filter coefficients, lets denote the coefficients of the wma as a and the coefficients of the moving average as b . So whats the meaning behind center of gravity ? We basically want to "center" the weights of the wma, this can be done with a - b
The coefficients of the wma are therefore centered around 0, but actually there is more to that than a simple title explanation, basically a - b = c , where c are the coefficients of the center of gravity bandpass filter, therefore if we where to apply convolution to the price with c , we would get the center of gravity oscillator. Thats the thing with FIR filters, we can use convolution for describing a lot of FIR systems, and the difference between two impulse responses of two low-pass filters (here wma, sma) give us the coefficients of a bandpass filter.
The Center Of Linearity
At this point we could simply get the oscillator by using length/2 - i as coefficient, however in order to propose a more interesting variation i decided to go with a less efficient but more original approach, the center of linearity. Imagine two convolutions :
a = i*src and b = i*src
a only has a reversed index length-i , and is therefore describe a simple wma. Both convolutions give the following impulse responses :
Both are symmetrical to each others, and cross at a point, denoted center of linearity. The difference of each responses is :
Using it as coefficients would give us a bandpass filter who would look exactly like the Cg oscillator, this would be calculated as follows in our convolution :
i*src -i*src ) = i*(src -src )
Lets compare our estimate with the CG oscillator,
Conclusion
I this post i explained the calculation of the CG oscillator and proposed an efficient estimation of it by using an original approach. The CG oscillator isn't something complicated to use nor calculate, and is in fact closely related to the rolling covariance between the price and a linear function, so if you want to use the crosses between the center of gravity and 0 you can just use : correlation(close,bar_index,length) instead, thats basically the same.
The proposed indicator can also use other weightings instead of a linear one, each impulses responses would remain symmetrical.
Dominant Cycle Tuned RsiIntroduction
Adaptive technical indicators are importants in a non stationary market, the ability to adapt to a situation can boost the efficiency of your strategy. A lot of methods have been proposed to make technical indicators "smarters" , from the use of variable smoothing constant for exponential smoothing to artificial intelligence.
The dominant cycle tuned rsi depend on the dominant cycle period of the market, such method allow the rsi to return accurate peaks and valleys levels. This indicator is an estimation of the cycle finder tuned rsi proposed by Lars von Thienen published in Decoding the Hidden Market Rhythm/Fine-tuning technical indicators using the dominant market vibration/2010 using the cycle measurement method described by John F.Ehlers in Cybernetic Analysis for Stocks and Futures .
The following section is for information purpose only, it can be technical so you can skip directly to the The Indicator section.
Frequency Estimation and Maximum Entropy Spectral Analysis
“Looks like rain,” said Tom precipitously.
Tom would have been a great weather forecaster, but market patterns are more complex than weather ones. The ability to measure dominant cycles in a complex signal is hard, also a method able to estimate it really fast add even more challenge to the task. First lets talk about the term dominant cycle , signals can be decomposed in a sum of various sine waves of different frequencies and amplitudes, the dominant cycle is considered to be the frequency of the sine wave with the highest amplitude. In general the highest frequencies are those who form the trend (often called fundamentals) , so detrending is used to eliminate those frequencies in order to keep only mid/mid - highs ones.
A lot of methods have been introduced but not that many target market price, Lars von Thienen proposed a method relying on the following processing chain :
Lars von Thienen Method = Input -> Filtering and Detrending -> Discrete Fourier Transform of the result -> Selection using Bartels statistical test -> Output
Thienen said that his method is better than the one proposed by Elhers. The method from Elhers called MESA was originally developed to interpret seismographic information. This method in short involve the estimation of the phase using low amount of information which divided by 360 return the frequency. At first sight there are no relations with the Maximum entropy spectral estimation proposed by Burg J.P. (1967). Maximum Entropy Spectral Analysis. Proceedings of 37th Meeting, Society of Exploration Geophysics, Oklahoma City.
You may also notice that these methods are plotted in the time domain where more classic method such as : power spectrum, spectrogram or FFT are not. The method from Elhers is the one used to tune our rsi.
The Indicator
Our indicator use the dominant cycle frequency to calculate the period of the rsi thus producing an adaptive rsi . When our adaptive rsi cross under 70, price might start a downtrend, else when our adaptive rsi crossover 30, price might start an uptrend. The alpha parameter is a parameter set to be always lower than 1 and greater than 0. Lower values of alpha minimize the number of detected peaks/valleys while higher ones increase the number of those. 0.07 for alpha seems like a great parameter but it can sometimes need to be changed.
The adaptive indicator can also detect small top/bottoms of small periods
Of course the indicator is subject to failures
At the end it is totally dependent of the dominant cycle estimation, which is still a rough method subject to uncertainty.
Conclusion
Tuning your indicator is a great way to make it adapt to the market, but its also a complex way to do so and i'm not that convinced about the complexity/result ratio. The version using chart background will be published separately.
Feel free to tune your indicators with the estimator from elhers and see if it provide a great enhancement :)
Thanks for reading !
References
for the calculation of the dominant cycle estimator originally from www.davenewberg.com
Decoding the Hidden Market Rhythm (2010) Lars von Thienen
Ehlers , J. F. 2004 . Cybernetic Analysis for Stocks and Futures: Cutting-Edge DSP Technology to Improve Your Trading . Wiley