Range Expansion Index (REI)

I'm sharing an indicator today that I have developed: the Range Expansion Index (REI). This powerful oscillator was developed by the renowned technical analyst Thomas DeM., known for his unique approach to market timing and price exhaustion. The REI was introduced as part of his comprehensive suite of technical tools, detailed in his influential work, such as "The New Science of Technical Analysis."
DeM. designed the REI to be a more refined momentum oscillator. His goal was to create an indicator that could accurately reflect the underlying strength or weakness of price movements while minimizing the false signals often generated by traditional oscillators during sideways or choppy markets. The REI achieves this by focusing on significant price expansions and contractions, comparing recent price behavior to the overall price changes over a specified lookback period.
You can find more information and the basis for this indicator here:
QuantifiedStrategies: https://www.quantifiedstrategies.com/range-expansion-index/
Infront Help Center: https://infront-portfolio-manager.helpcenter.infront.co/en/pm/latest/range-expansion-index
How the REI Works
The core of the REI's calculation lies in identifying and quantifying "strong" price changes within a given period (typically 8 bars). It does this by evaluating specific price relationships and conditions between current and past bars. The indicator then computes a ratio comparing the sum of these "strong" price changes to the sum of the absolute total price changes over the lookback period, scaling the result to oscillate between -100 and +100.
The key levels for interpreting the REI are generally:
+60: Overbought Zone
-60: Oversold Zone
Unlike oscillators that might simply signal overbought/oversold upon entering these zones, the REI's interpretation, according to DeM., often focuses on the exit from these extreme areas.
Traditional Trading Signals
Based on DeM.'s methodology and the descriptions in the provided links, the primary trading signals generated by the REI occur when the indicator crosses back from an extreme zone:
- Sell Signal: The REI moves above the +60 level and then crosses back down below +60. This suggests potential price weakness after a period of strong upward momentum.
- Buy Signal: The REI moves below the -60 level and then crosses back up above -60. This indicates potential price strength after a period of strong downward momentum.
- Duration Analysis: An Optional Signal Filter
The QuantifiedStrategies link highlights the concept of "Duration Analysis," suggesting that the amount of time (number of bars) the REI spends in the overbought or oversold region can add crucial context. A brief stay might precede a reversal, while a prolonged stay could indicate a strong, persistent trend.
The indicator incorporates this concept as an optional filter. You can enable this feature and specify a number of bars. When enabled, a buy or sell signal will only be triggered if the REI crosses the respective overbought/oversold level AND the duration of the REI being in that extreme zone precisely matches the number of bars you specify in the input settings.
Indicator Features in This Pine Script
The Pine Script code I have developed provides a comprehensive implementation of the REI with additional trading utilities:
- REI Calculation: Implements the core REI formula based on conditional price changes and summations over a defined period.
- Configurable REI Period: Easily adjust the main lookback period for the REI calculation.
- Customizable Lookback Parameters: Fine-tune the specific lookback periods used in the internal conditions (n1L, n2L, n3L) as described in the calculation method.
- Plotting: Displays the REI line in a separate pane, along with horizontal lines at +60 (Overbought), -60 (Oversold), and 0 (Zero Line) for clear visual analysis.
- Configurable Alerts: Set up Buy and Sell alerts that trigger when the REI crosses the +60/-60 levels. Control global alert enabling, and specifically enable/disable Buy and Sell alerts.
- Plot Shapes for Signals: Optionally display visual triangle shapes directly on the price chart (red triangle down for Sell above the bar, green triangle up for Buy below the bar) to easily spot signal occurrences. Control global shape enabling and specifically enable/disable Buy/Sell shapes.
- Optional Duration Analysis Filter: Activate a filter that requires the REI to have spent an exact number of consecutive bars in the overbought/oversold zone at the moment of the cross for a signal to be considered valid. Configure the required number of bars.
How to Use This Code in TradingView
- Open TradingView and navigate to the Pine Editor (usually the [] icon on the left sidebar or via the bottom panel).
- Delete any existing code in the editor and paste the REI code.
- Save the script (you can name it "Range Expansion Index with Duration Filter" or similar).
- Add the indicator to your chart by clicking the "Add to Chart" button in the Pine Editor.
- Access the indicator's settings on your chart to adjust the REI Period, Lookbacks, and enable/disable Alerts, Plot Shapes, and the optional Duration Filter (including setting the number of bars).
- To receive actual notifications: You must set up alerts manually through the TradingView platform's alert system (right-click on the indicator -> Add alert on Range Expansion Index (REI)...). Select the specific conditions "REI Sell Signal" or "REI Buy Signal" from the dropdown menu and configure your desired notification methods (popup, email, etc.).
Disclaimer:
Trading financial markets involves risk, and past performance is not indicative of future results. This indicator is a tool for analysis and should be used as part of a comprehensive trading strategy, always combined with other techniques and proper risk management. Always conduct your own research and backtest the indicator to understand its behavior on the markets and timeframes you trade.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
Declinazione di responsabilità
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.