OPEN-SOURCE SCRIPT

Depth Trend Indicator - RSI

Depth Trend Indicator - RSI

This indicator is designed to identify trends and gauge pullback strength by combining the power of RSI and moving averages with a depth-weighted calculation. The script was created by me, Nathan Farmer and is based on a multi-step process to determine trend strength and direction, adjusted by a "depth" factor for more accurate signal analysis.

How It Works

  • Trend Definition Using RSI: The RSI Moving Average (rsiMa) is calculated to assess the current trend, using customizable parameters for the RSI Period and MA Period.

  • Trends are defined as follows:

    Uptrend: RSI MA > Critical RSI Value
    Downtrend: RSI MA < Critical RSI Value

  • Pullback Depth Calculation: To measure pullback strength relative to the current trend, the indicator calculates a Depth Percentage. This is defined as the portion of the gap between the moving average and the price covered by a pullback.

  • Depth-Weighted RSI Calculation: The Depth Percentage is then applied as a weighting factor on the RSI Moving Average, giving us a Weighted RSI line that adjusts to the depth of pullbacks. This line is rather noisy, and as such we take a moving average to smooth out some of the noise.


Key Parameters

  • RSI Period: The period for RSI calculation.

  • MA Period: The moving average period applied to RSI.

  • Price MA Period: Determines the SMA period for price, used to calculate pullback depth.

  • Smoothing Length: Length of smoothing applied to the weighted RSI, creating a more stable signal.

  • RSI Critical Value: The critical value (level) used in determining whether we're in an uptrend or a downtrend.

  • Depth Critical Value: The critical value (level) used in determining whether or not the depth weighted value confirms the state of a trend.


Notes:

As always, backtest this indicator and modify the parameters as needed for your specific asset, over your specific timeframe. I chose these defaults as they worked well on the assets I look at, but it is likely you tend to look at a different group of assets over a different timeframe than what I do.

Large pullbacks can create large downward spikes in the weighted line. This isn't graphically pleasing, but I have tested it with various methods of normalization and smoothing and found the simple smoothing used in the indicator to be best despite this.
depthpullbackRelative Strength Index (RSI)Trend AnalysistrendfollowingtrendindicatortrendtradingVolatilityweighted

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian