OPEN-SOURCE SCRIPT

Cyclic Smoothed RSI with Motive-Corrective Wave Indicator

Atualizado

This indicator uses the cyclic smoothed Relative Strength Index (cRSI) instead of the traditional Relative Strength Index (RSI). See below for more info on the benefits to the cRSI.

My key contributions
1) A Weighted Moving Average (WMA) to track the general trend of the cRSI signal. This is very helpful in determining when the equity switches from bullish to bearish, which can be used to determine buy/sell points. This is then is used to color the region between the upper and lower cRSI bands (green above, red below).
2) An attempt to detect the motive (impulse) and corrective and waves. Corrective waves are indicated A, B, C, D, E, F, G. F and G waves are not technically Elliot Waves, but the way I detect waves it is really hard to always get it right. Once and a while you could actually see G and F a second time. Motive waves are identified as s (strong) and w (weak). Strong waves have a peak above the cRSI upper band and weak waves have a peak below the upper band.
3) My own divergence indicator for bull, hidden bull, bear, and hidden bear. I was not able to replicate the TradingView style of drawing a line from peak to peak, but for this indicator I think in the end it makes the chart cleaner.

There is a latency issue with an indicator that is based on moving averages. That means they tend to trigger right after key events. Perfect timing is not possible strictly with these indicators, but they do work very well "on average." However, my implementation has minimal latency as peaks (tops/bottoms) only require one bar to detect.

As a bit of an Easter Egg, this code can be tweaked and run as a strategy to get buy/sell signals. I use this code for both my indicator and for trading strategy. Just copy and past it into a new strategy script and just change it from study to a strategy, something like this:
strategy("cRSI + Waves Strategy with VWMA overlay", overlay=overlay)
The buy/sell code is at the end and just needs to be uncommented. I make no promises or guarantees about how good it is as a strategy, but it gives you some code and ideas to work with.

Tuning
1) Volume Weighted Moving Average (VWMA): This is a “hidden strategy” feature implemented that will display the high-low bands of the VWMA on the price chart if run the code using “overlay = true”.
- [Use Volume for VWMA] If the equity does not have volume, then the VWMA will not show up. Uncheck this box and it will use the regular WMA (no volume).
- [VWMA Length] defines how far back the WMA averages price.

2) cRSI (Black line in the indicator)
- [CRSI Dominate Cycle Length] Increase to length that amount of time a band (upper/lower) stays high/low after a peak. Reduce the value to shorten the time. Just increment it up/down to see the effect.
- [CRSI Moving Average Length] defines how far back the SMA averages the cRSI. This affects the purple line in the indicator.
- [CRSI Top/Bottom Detector Lookback] defines how many bars back the peak detector looks to determine if a peak has occurred. For example, a top is detected like this: current-bar down relative to the 1-bar-back, 1-bar-back up relative to 2-bars-back (look back = 1), c) 2-bars-back up relative to 3-bars-back (lookback = 2), and d) 3-bars-back up relative to 4-bars-back (lookback = 3). I hope that makes sense. There are only 2 options for this setting: 2 or 3 bars. 2 bars will be able to detect small peaks but create more “false” peaks that may not be meaningful. 3 bars will be more robust but can miss short duration peaks.

3) Waves
- The check boxes are self explanatory for which labels they turn on and off on the plot.

4) Divergence Indicators
- The check boxes are self explanatory for which labels they turn on and off on the plot.

Hints
- The most common parameter to change is the [CRSI Top/Bottom Detector Lookback]. Different stocks will have different levels of strength in their peaks. A setting of 2 may generate too many corrective waves.
- Different times scales will give you different wave counts. This is to be expected. A counter impulse wave inside a corrective wave may actually go above the cRSI WMA on a smaller time frame. You may need to increase it one or two levels to see large waves.
- Just because you see divergence (bear or hidden bear) does not mean a price is going to go down. Often price continues to rise through bears, so take note and that is normal. Bulls are usually pretty good indicators especially if you see them on C,E,G waves.


----------------------------------------------------------------------------------------------------------------------------
cyclic smoothed RSI (cRSI) indicator
----------------------------------------------------------------------------------------------------------------------------
The “core” code for the cyclic smoothed RSI (cRSI) indicator was written by Lars von Theinen and is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/. Copyright (C) 2017 CC BY, whentotrade / Lars von Thienen. For more details on the cRSI Indicator:
RSI cyclic smoothed v2


The cyclic smoothed RSI indicator is an enhancement of the classic RSI, adding
1) additional smoothing according to the market vibration,
2) adaptive upper and lower bands according to the cyclic memory and
3) using the current dominant cycle length as input for the indicator.
It is much more responsive to market moves than the basic RSI. The indicator uses the dominant cycle as input to optimize signal, smoothing, and cyclic memory. To get more in-depth information on the cyclic-smoothed RSI indicator, please read Decoding The Hidden Market Rhythm - Part 1: Dynamic Cycles (2017), Chapter 4: "Fine-tuning technical indicators." You need to derive the dominant cycle as input parameter for the cycle length as described in chapter 4.



Hope this helps and good luck.
Notas de Lançamento
I have also added "alert conditions" for most of the key events. I have not tested this very much, so it is a work in progress.

--> Select the equity you want (such as: SPX) and the desired timeframe (such as: D).
--> Go to the TradingView "Alerts" tab (click the alarm clock icon)
--> Create Alert (alarm clock with a +)
--> Change the first condition drop down to "Cyclic Smoothed RSI with Motive-Corrective Wave Indicator"
--> in the drop down below that select the alert that you want (such as: Bull - cRSI Above WMA).

You will want to give the alert a good name that includes the ticker name and time frame, for example "SPX 1D: Bull - cRSI above WMA"
Notas de Lançamento
"Fixed" a bug that would calculate a cRSI of less than 1 and would cause a large value in the bands.
Notas de Lançamento
Another attempt to fix a bug in the cRSI. The previous fix cause some waves to be misses, then new fix seems to work and not missed waves.
Notas de Lançamento
As of 11/18/21 a change to how pine seems to work occurred which caused this script to have an out of bounds error. The fix was to add max_bars_back=300 to the study declaration.
correctioncorrectivecrsiDivergencemotiveMoving AveragesOscillatorsRelative Strength Index (RSI)Trend Analysis

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal