This is an experimental study designed to reverse engineer price levels from centered oscillators at user defined sample rates. This study aims to educate users on the process of oscillator reverse engineering, and to give users an alternative perspective on some of the most commonly used oscillators in the trading game.
Reverse engineering price levels from an oscillator is actually a rather simple, straightforward process. Rather than plugging price values into a function to solve for oscillator values, we rearrange the function using some basic algebraic operations and plug in a specified oscillator value to solve for price values instead. This process tells us what price value is needed in order for the oscillator to equal a certain value. For example, if you wanted to know what price value would be considered “overbought” or “oversold” according to your oscillator, you can do that using this process.
In this study, the reverse engineering functions are used to calculate the price values of user defined high and low oscillator thresholds, and the price values for the oscillator center. This allows you to visualize what prices will trigger thresholds as a sort of confidence interval, which is information that isn't inherently available when simply analyzing the oscillator directly.
This script is equipped with three reverse engineering functions to choose from for calculating the band values: -> Reverse Relative Strength Index (RRSI) -> Reverse Stochastic Oscillator (RStoch) -> Reverse Commodity Channel Index (RCCI) You can easily select the function you want to utilize from the "Band Calculation Type" dropdown tab.
These functions are specially designed to calculate at any sample rate (up to 1 bar per sample) utilizing the process of downsampling that I introduced in my Resampling Filter Pack. The sample rate can be determined with any of these three methods: -> BPS - Resamples based on the number of bars. -> Interval - Resamples based on time in multiples of current charting timeframe. -> PA - Resamples based on changes in price action by a specified size. The PA algorithm in this script is derived from my Range Filter algorithm. The range for PA method can be sized in points, pips, ticks, % of price, ATR, average change, and absolute quantity.
Utilizing downsampled rates allows you to visualize the reverse engineered values of an oscillator calculated at larger sample scales. This can be rather beneficial for trend analysis since lower sample rates completely remove certain levels of noise. By default, the sample rate is set to 1 BPS, which is the same as bar-to-bar calculation. Feel free to experiment with the sample rate parameters and configure them how you like.
Custom bar colors are included as well. The color scheme is based on disparity between sources and the reverse engineered center level.
In addition, background highlights are included to indicate when price is outside the bands, thus indicating "overbought" and "oversold" conditions according to the thresholds you set.
I also included four external output variables for easy integration of signals with other scripts: -> Trend Signals (Current Resolution Prices) - Outputs 1 for bullish and -1 for bearish based on disparity between current resolution source and the central level output. -> Trend Signals (Resampled Prices) - Outputs 1 for bullish and -1 for bearish based on disparity between resampled source and the central level output. -> Outside Band Signal (Current Resolution Prices) - Outputs 1 for overbought and -1 for oversold based on current resolution source being outside the bands. Returns 0 otherwise. -> Outside Band Signal (Resampled Prices) - Outputs 1 for overbought and -1 for oversold based on resampled source being outside the bands. Returns 0 otherwise. To use these signals with another script, simply select the corresponding external output you want to use from your script's source input dropdown tab.
Reverse engineering oscillators is a simple, yet powerful approach to incorporate into your momentum or trend analysis setup. By incorporating projected price levels from oscillators into our analysis setups, we are able to gain valuable insights, make (potentially) smarter trading decisions, and visualize the oscillators we know and love in a totally different way.
I hope you all find this script useful and enjoyable!
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.