OPEN-SOURCE SCRIPT

+ REX Oscillator

Updated
So, what is the REX oscillator, you might be asking yourself.
"The Rex oscillator is an indicator that measures market behavior based on the relationship of the close to the open, high and low values of the same bar. A big difference between the high and close on a bar indicates weakness, and wide disparity between the low and close indicates strength. The difference between open and close also indicates market performance."

The True Value of a Bar (TVB) gives an indication of how healthy the market is. A negative close and a positive TVB (or vice versa) is an indication of the market building strength on the opposing side of the trend. The Rex oscillator is a moving average of the TVB value with the specified period.

I first came across this watching one of many No Nonsense Forex videos. Mostly, from comments I've read, it is used as an exit indicator for people who trade with a system similar or identical to the one VP espouses in his NNFX blog. I think it's perfectly apt to use as an entry indicator as well, or even as both, perhaps, depending on the moving average you chose to apply to the TVB.

There are a few other versions of this on tradingview, but I thought I'd make an updated version. Added Donchian Channels because I like the idea of a dynamic sort of overbought/sold area. I left out the basis because the indicator pivots around a center line, and has a signal line as well. A basis line just seemed like too much, and would likely not be very useful.

The additional usual things that I incorporate into my indicators are included here: optional candle coloring, alerts, and probably a too large selection of moving averages.

Credit to Nemozny for the FRAMA calculation. I may add that to other indicators I have.
Release Notes
a user mentioned to me a tweak that I should make to the Jurik Moving Average, so I have done so. It's a simple thing, changing the power value from an integer to a float so that you can fine tune the MA more so than whole integers would allow.

also made the donchian channel band thickness adjustable. Anywhere from 3 on up is fine. Once you get past around 8 it's pretty negligible changes though. Smaller numbers are wider (2 would basically start the bands at the basis), and the bands can only go so thin, hence why anything beyond 8 doesn't change much.
Release Notes
made a few minor tweaks in the case of language, but the big update, as suggested in the comments (and something I was thinking about implementing anyway) is adding divergences to the indicator. Thanks to AtomOfScent for the suggestion (and also the suggestion for the change in the JMA).
I've actually added this across all my oscillating indicators, because why not. In the case of the REX Oscillator I've set it so that you can set divergences to plot from either the REX or the Signal Line.

snapshot
Release Notes
added alert conditions for divergences
Release Notes
-conversion to pinescript v5
-added T3, RMA, and UMA moving averages for REX and as signal line
-added option for plots for signal line crosses
-added histogram option. This works the same as it does for MACD. It's just measuring the distance between the REX and Signal line
-histogram is also selectable as a candle coloration option and as a divergence option
Release Notes
-added an alert for histogram crossing the center line
Release Notes
I'm publishing updates to all of my indicators, so I'm just going to comment on everything here since most of the updates are common across most of my indicators.

User Non-Visible Updates (basically backend stuff that makes:
- changes in code legibility and consistency across all indicators (basically standardizing the coding across as many indicators as possible)
- implementation of libraries into my indicators; which helps significantly in doing what I typed above; which in turn will make creating any new indicators, if they are of the type to use these libraries, much simpler
- updated descriptions for all indicators, which should (it's possible I've forgotten things) reflect changes I've made recently and any I may have made in the past after first publication (this is very minor, but as I was changing so much I thought I may as well--I don't intend to update these much, if at all, in the future)

User Visible Updates:
- as I mentioned everything now uses my moving averages library and volatility bands library--this cuts down the total amount of code significantly, and has made it easier for me to add moving averages, or volatility bands to these indicators because I only had to/have to add it one time (to the library) rather than multiple times across all indicators*
- since creating these libraries I've added several new moving averages (Kaufman Adaptive, Laguerre Filter, McGinley Dynamic (doesn't work for all), and Zero-lag) to them while retaining all the previous with the exception of the UMA, which wasn't implemented consistently across all indicators anyway
- eliminated having two Bollinger Bands with different standard deviations and a fill between them in exchange for one with the band fill implementation that I use on my Donchian Channels Bands
- part of my code consistency across all indicators resulted in a much needed organization of the 'style' tab

*(affects all but the Wavetrend Oscillator, Wavetrend Oscillator Overlay, Jurik KDJ, Average Candle Bodies Range, Bollinger Bands Width, ALMA Trend Detector, Ultimate Moving Average, Donchian Channels, and Dynamic Donchian Channels)
barcolorCandlestick analysisDivergenceexit_indicatorMomentum OscillatorsMoving AveragesnononsenseforexnononsensefxOscillatorsrexoscillatorsignalline

Open-source script

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.

Want to use this script on a chart?


Also on:

Disclaimer