PROTECTED SOURCE SCRIPT

[Rygel] Trend Reversal Indicator

已更新
This indicator is a trend reversal detector. It provides a bullish or bearish signal derived from the analysis of 22 indicators.
It analyzes and aggregates the divergences and the overbought and oversold conditions to determine a signal strength going from -100 to 100.
You can choose the appearance of the signals, how sensitive you want the signals to be and the indicators you want to use.
You can also display divergences, and show signal, divergence, overbought and oversold strength as a background color.
This indicators also provides several alerts.

You can find more information about the divergence algorithm I'm using on this page.

Please note this indicator will not give you buy nor sell signals. A bullish signal will not always be followed by a bearish one and vice-versa. You may get the same type of signals for a long time ; expect to see far more bearish signals in a bullish market and far more bullish signals in a bearish market.
You should never make a buy or sell decision based solely on this indicator, even when the signal is very strong.
This indicator is made to help you to confirm your market analysis and to warn you of possible incoming trend reversals so you can anticipate them and adapt your trading strategy accordingly. It may also help you to optimize your DCA times of purchase.

Please note a signal becomes final only after the bar after it is closed, as a divergence pivot may still be invalidated by then. When the signal bar is closed, the signal is considered as confirmed but may still disappears if it is invalidated by the next bar. When the second bar is closed, the signal is made final and stays definitely on the chart.

This indicator currently supports the following indicators as sources:

  • AO (Awesome Oscillator)
  • BBP (Bear Bull Power)
  • CCI (Commodity Channel Index)
  • CMF (Chaikin Money Flow)
  • CO (Chaikin Oscillator)
  • EOM (Ease of Movement)
  • MACD (Moving Average Convergence Divergence)
  • MACD histogram
  • MFI (Money Flow Index)
  • MOM (Momentum)
  • OBV (On-Balance Volume)
  • OBV oscillator
  • RSI (Relative Strength Index)
  • RVGI (Relative Vigor Index)
  • RVI (Relative Volatility Index)
  • Stochastic
  • Stochastic RSI
  • TSI (True Strength Index)
  • UO (Ultimate Oscillator)
  • VWMACD (Volume-Weighted MACD)
  • VWMACD histogram
  • WT (Wave Trend)


You can disable any of them in the settings. You only need one indicator source enabled for the Trend Reversal Indicator to work.
If you disable some indicators, you may need to lower the sensitivity or even use a custom one as the signals strength will probably be higher as it will be easier to match most of the indicators.

As this indicator makes a lot of computation, it takes a few seconds to load. If it's an issue for you, you may improve its performance by disabling some indicator sources.

HOW IS THE SIGNAL CALCULATED

The algorithm analyzes the last three bars (the current one and the two previous bars) and for each enabled indicator source:

  • Add one point for a positive divergence ;
  • Add one point for an oversold condition (when the indicator supports it) ;
  • Add one point for a strongly oversold condition (cumulated with the oversold point) ;
  • Remove one point for a negative divergence ;
  • Remove one point for an overbought condition ;
  • Remove one point for a strongly overbought condition (cumulated with the overbought point).


It then normalizes the signal from -100 to 100, where -100 is the minimum theoretical score and 100 is the maximum theoretical one.

The algorithm detects up to 100 bars long divergences.

SETTINGS

SIGNAL SENSITIVITY

You can set the indicator sensitivity to one of five levels.

Very low (60):

快照

Low (55):

快照

Medium (50): (this is the default value)

快照

High (45):

快照

Very high (40):

快照

You can also set a custom sensitivity by choosing "Custom" and filling the "Custom sensitivity" field.

SIGNAL APPARENCE

Show signal strength: replace the "Bear" and "Bull" label with the signal strength.

快照

Show indicator names: add the indicator names to the label to know exactly what got detected.

OB is for "overbought", OS is for "oversold", OB+ is for "strongly overbought" and OS+ for "strongly oversold".

快照

DIVERGENCES

Show divergences: add all the detected divergences to the graph. The more divergences are in the same zone, the brighter the colors are. Please note TradingView limits to 500 the number of lines you can display at anytime, so divergences will only be shown for the most recent bars.

快照

BACKGROUNDS

You can show signal, divergence, overbought and oversold strength as a background color.

Show signal background:

快照

Show divergence background:

快照

The more divergences are detected in the same bar, the brighter the color is.

Please note the divergence background only shows confirmed divergences. It requires two bars for a divergence to be confirmed.

Show overbought and oversold background:

快照

The more overbought and oversold conditions are detected in the same bar, the brighter the color is.

You can also combined all of the backgrounds for even more eye pain.

快照

ALERTS

This indicator offers multiple alerts.

  • New trend reversal signal: a new trend reversal signal has been detected. Bar is not yet closed, signal may still be invalidated and disappear. It's the earliest alert you can get but you'll also get many false positives.
  • New bearish trend reversal signal: identical, but with bearish signals only.
  • New bullish trend reversal signal: identical, but with bullish signals only.


  • Confirmed trend reversal signal: a trend reversal signal has been confirmed. The signal bar is closed but the signal may still be invalidated by the current bar. You'll get far less false positives.
  • Confirmed bearish trend reversal signal: identical, but with bearish signals only.
  • Confirmed bullish trend reversal signal: identical, but with bullish signals only.


  • Final trend reversal signal: a trend reversal signal has been confirmed and is now final. The signal bar and the following one are closed. The signal can't change anymore but it will likely be too late to act on some signals, especially bearish ones. Crashes can be brutal whereas bullish trend reversals usually take more time to unfold.
  • Final bearish trend reversal signal: identical, but with bearish signals only.
  • Final bullish trend reversal signal: identical, but with bullish signals only.


I hope you'll enjoy this indicator and I hope it will be as useful to you as it is to me.
Feel free to comment if you experience a bug or if an important feature is missing for you.

If you like this indicator, please note it has been designed to be used it with my R.S.I. with divergences indicator and my M.A.C.D. with divergences indicator.

快照
版本注释
Improved performance by adding a new option to process only the most recent bars.

This indicator is quite resource intensive and may take multiple seconds to load with long series of data. Now, by default only the 1000 most bars are processed to offer better and more consistent performance.

You may decrease this number in the settings if you want even better loading time and increase it, or even completely disable this limit, if you need to process older data.
Alternatively you may use the TradingView replay feature to process older data without touching this parameter.

By processing only the most recent 1000 bars, initial loading went from more than 10 seconds to around 2 seconds on the longest series of data.
版本注释
Added an analytics mode.

快照

When enabled in the settings, it displays a label at the last bar with analytics information about the signals accuracy, completeness and delay.

Signals are compared with large pivots positions. You can define the pivot bar length in the settings (15 by default).

Accuracy = percentage of signals matching a pivot (+- 3 bars).
Completeness = percentage of pivots matched by at least one signal (+- 3 bars).
Trustworthiness = accuracy + completeness / 2.
Delay = how many bars away from the pivot the signal is. (It can be negative in the best case scenarios, when the signals appear before the pivots.)

First two pivots (first low and first high) are ignored in the calculation as it is not possible for a signal to be strong enough to match them so soon in the data series. Signals that in the latest bars, where a pivot can't exist yet, are also ignored.
版本注释
Fixed a bug where analytics labels were not correctly deleted when a new bar is created.
版本注释
  • Added an "Enable hidden divergences" option. When activated, hidden divergences are included in the signal calculation. By default only regular divergences are processed and counted. With this option enabled, hidden and regular divergences are considered the same by the signal algorithm.
    Enabling hidden divergences usually increases completeness (trend reversals matched by a signal) but decreases accuracy (signals matching a trend reversal). It is disabled by default as accuracy is more important to me than completeness.
    It may, however, in certain cases, increases both. For instance on Bitcoin with a weekly timeframe and an "extremely high" signal sensitivity, accuracy increases from 14% to 28% and completeness from 27% to 72%.
    You can use the analytics mode to determine when enabling hidden divergences is the better choice.
  • Added an "extremely slow" (65) and "extremely high" (35) signal sensitivity settings.
  • Removed the first two pivots exemption in the analytics mode. After further tests, first pivots could be matched and should be matched. I have no reason to exclude them.
  • Fixed a bug that caused some signal labels to be invisible under rare circumstances.
  • Fixed a divide by zero bug in the analytics mode.
版本注释
Improved pivot price detection. Price and indicator pivots are not always on the exact same bar, sometimes there is a 1 bar offset. Price is now selected to always be the lowest/highest rather than the one exactly on the indicator pivot bar.
版本注释
Added in the "Show signal indicators" tooltip the meaning of the new abbreviations introduced with the "Use hidden divergences" setting option: RG is for "regular divergence" and HD is for "hidden divergence".
版本注释
Improved "Show signal indicator" label readability.

快照
版本注释
Added a "Show invalid signals" setting option. When a signal is detected, it needs to be confirmed by the next bar to be considered real. If it is not, it is removed from the chart. When this option is enabled, the invalid signals stay visible, within a gray label. Invalid signal background and text colors car be set in the "Colors" setting category.

快照
版本注释
  • Added Bollinger Bands as a signal indicator. When price is lower than a 2.0 standard deviation, it is considered oversold, when lower than a 2.5 deviation, it is strongly oversold, when higher than a 2.0 deviation it is overbought and when higher than a 2.5 deviation it is strongly overbought.
  • Added a "Show duplicated signals" option. When a signal is identical or lower than the previous signal, it is not displayed to improve readability. When this option is enabled, duplicated signals become visible.
  • Improved invalid signals. When a signal is detected, it needs to be confirmed by the next bar to be considered final as the signal strength can still vary until then as some divergences may be invalidated. If a signal strength becomes too low to be shown according to your sensitivity setting, it is removed from the chart. When you enable the "Show invalid signals" option, the signal was still showing the signal value before it's invalidation (when it was higher than the required sensitivity). It now shows the real final signal value (which is lower than the required sensitivity.)
版本注释
Added a Bollinger bands feature that can be enabled in the settings.

Show Bollinger bands

Show two Bollinger bands, an inner Bollinger band with a 2.0 standard deviation (contains 95% of the price action) and an outer Bollinger band with a 3.0 standard deviation (contains 99% of the price action).

快照

Color Bollinger bands basis

快照

Color Bollinger bands backgrounds

快照

You can customize the Bollinger bands source and length, the inner and outer standard deviations and the colors used.

Six new alerts has been added:

  • Price higher than inner Bollinger bands
  • Price higher than outer Bollinger bands
  • Price lower than inner Bollinger bands
  • Price lower than outer Bollinger bands
  • Price crossed inner Bollinger bands
  • Price crossed outer Bollinger bands
版本注释
Improved divergence detection. (I found a few edge cases where my divergence algorithm couldn't detect some divergences, mainly with slow moving indicators, because of malformed pivots. Though these divergences were real, their pivot couldn't be validated and so the divergence didn't appear. So I wrote a new pivot detection algorithm that can handle these pivots.)
版本注释
Increased maximum bars checked for divergences from 100 to 180. Previous setting was missing a major daily divergence on Bitcoin.
版本注释
  • Improved divergence reliability. A divergence won't be detected anymore if a price pivot breaks the divergence line. For instance, when you draw a bullish regular divergence line from price A to price B, if an intermediate price pivot breaks the divergence line (i.e. if the price of the pivot is below the divergence line), the divergence won't show anymore.
  • Improved pivot detection. Some pivots are now better positioned, making divergences more precise / reliable.
  • Fixed a condition where a divergence could be missing when too many pivots were detected.


Before
快照

After
快照
版本注释
Updated chart.
reversaltrendTrend Analysistrendreversal

受保护脚本

该脚本是闭源发布的,您可以自由使用它。您可以收藏它以在图表上使用。您无法查看或修改其源代码。

想在图表上使用此脚本?


更多:

免责声明