Category Oscilators  Published on 18/04/2021

Stochastic RSI

Description

Stochastic RSI Indicator based on TradingView approach

 



using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class StochasticRSI : Indicator
    {
        [Parameter("Source", Group = "Base Settings", DefaultValue = "Close")]
        public DataSeries Source { get; set; }

        [Parameter("Oversold Level", DefaultValue = 20, MinValue = 1, Step = 1)]
        public int Oversold { get; set; }

        [Parameter("Overbought Level", DefaultValue = 80, MinValue = 1, Step = 1)]
        public int Overbought { get; set; }

        [Parameter("RSI Periods", DefaultValue = 14, MinValue = 2)]
        public int RSIPeriod { get; set; }

        [Parameter("Stochastic K%", DefaultValue = 3, Step = 1, MinValue = 2)]
        public int StochK { get; set; }

        [Parameter("Stochastic D%", DefaultValue = 3, Step = 1, MinValue = 2)]
        public int StochD { get; set; }

        [Parameter("Stochastic Periods", DefaultValue = 14, Step = 1, MinValue = 2)]
        public int StochPeriods { get; set; }

        [Output("Smoothed K", LineColor = "Turquoise")]
        public IndicatorDataSeries SmoothedK { get; set; }

        [Output("Smoothed D", LineColor = "Red")]
        public IndicatorDataSeries SmoothedD { get; set; }

        [Output("Oversold", LineColor = "Turquoise")]
        public IndicatorDataSeries oversold { get; set; }

        [Output("Overbought", LineColor = "Red")]
        public IndicatorDataSeries overbought { get; set; }

        private RelativeStrengthIndex rsi;

        private IndicatorDataSeries StochKSeries { get; set; }
        private IndicatorDataSeries StochDSeries { get; set; }

        protected override void Initialize()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, RSIPeriod);
            StochKSeries = CreateDataSeries();
            StochDSeries = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            overbought[index] = Overbought;
            oversold[index] = Oversold;

            double LRSI = rsi.Result.Minimum(StochPeriods);
            double HRSI = rsi.Result.Maximum(StochPeriods);

            double K = 100 * ((rsi.Result.LastValue - LRSI) / (HRSI - LRSI));
            StochKSeries[index] = K;

            double d = 100 * (rsi.Result.Maximum(StochD) / rsi.Result.Minimum(StochD));
            StochDSeries[index] = d;

            SimpleMovingAverage ksma = Indicators.SimpleMovingAverage(StochKSeries, StochK);
            SimpleMovingAverage dsma = Indicators.SimpleMovingAverage(ksma.Result, StochD);

            SmoothedK[index] = ksma.Result.LastValue;
            SmoothedD[index] = dsma.Result.LastValue;
        }
    }
}


TP
tperalta82

Joined on 07.07.2020

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: StochasticRSI.algo
  • Rating: 5
  • Installs: 3159
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
CH
charliejone0214 · 1 year ago

I often use the Stochastic RSI indicator in conjunction with other analysis growdle tools: While the Stochastic RSI indicator can be helpful in identifying potential buy and sell signals, it's important to use it in conjunction with other analysis tools such as price action, volume, and trend analysis. This io games can help to confirm signals and minimize false signals.

CA
carverhardy7150067 · 2 years ago

This indication is fantastic, however it no longer works with the latest update. If it could be rectified as soon as possible, it would be fantastic

 

 

Slope 2

JA
jamesthedaytrader · 2 years ago

I absolutely love this indicator but it’s not working with the new update. If it could be fixed asap that would be great :)