Category Oscilators  Published on 06/04/2023

RSI Oscillator indicator

Description

The RSI Oscillator displays the smoothed difference between two different-period RSIs. This is an analogy of the Wyckoff system.

Use the green shadow zone for long positions when the indicator's main component value is above the signal component and the indicator zero value. Use the red shadow zone for short positions when the indicator's main component value is below the signal component and the indicator zero value.

For major market conditions, use the Elder Triple Screen Trading System. For example, indicator periods could be (10, 25, 5), (40, 100, 5), (160, 400, 5).


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

namespace cAlgo.Indicators
{
    [Levels(0)]
    [Cloud("Zone", "Zone0", FirstColor = "Green", SecondColor = "Red", Opacity = 0.2)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mRSIosc : Indicator
    {
        [Parameter("Period Fast (10)", DefaultValue = 7, MinValue = 2)]
        public int inpPeriodFast { get; set; }
        [Parameter("Period Slow (25)", DefaultValue = 25, MinValue = 2)]
        public int inpPeriodSlow { get; set; }
        [Parameter("Period Smooth (5)", DefaultValue = 5, MinValue = 1)]
        public int inpPeriodSmooth { get; set; }
        [Parameter("Show Zones (no)", DefaultValue = false)]
        public bool inpShowZones { get; set; }
        
        [Output("RSI Osc", LineColor = "Black", Thickness = 1)]
        public IndicatorDataSeries ourRSIosc { get; set; }
        [Output("RSI Signal", LineColor = "Silver", Thickness = 1)]
        public IndicatorDataSeries ourRSIsignal { get; set; }
        [Output("Zone", LineColor = "Transparent", Thickness = 1)]
        public IndicatorDataSeries outZone { get; set; }
        [Output("Zone0", LineColor = "Transparent", Thickness = 1)]
        public IndicatorDataSeries outZone0 { get; set; }

        private RelativeStrengthIndex _rsif, _rsis;
        private IndicatorDataSeries _raw;
        private MovingAverage _smoothrsi;


        protected override void Initialize()
        {
            _rsif = Indicators.RelativeStrengthIndex(Bars.ClosePrices, inpPeriodFast);
            _rsis = Indicators.RelativeStrengthIndex(Bars.ClosePrices, inpPeriodSlow>inpPeriodFast ? inpPeriodSlow : inpPeriodFast+1);
            _raw = CreateDataSeries();
            _smoothrsi = Indicators.MovingAverage(_raw, inpPeriodSmooth, MovingAverageType.Simple);
        }

        public override void Calculate(int i)
        {
            _raw[i] = _rsif.Result[i] - _rsis.Result[i];
            
            ourRSIosc[i] = _raw[i];
            ourRSIsignal[i] = _smoothrsi.Result[i];

            outZone[i] = 0;
            outZone0[i] = 0;
            if (inpShowZones == true && _raw[i-1] > 0 && _raw[i] > 0 && _raw[i] > _smoothrsi.Result[i])
            {
                outZone[i] = _raw[i];
                outZone0[i] =  _smoothrsi.Result[i];
            }
            if (inpShowZones == true && _raw[i-1] < 0 && _raw[i] < 0 && _raw[i] < _smoothrsi.Result[i])
            {
                outZone[i] = _raw[i];
                outZone0[i] =  _smoothrsi.Result[i];
            }
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mRSIosc.algo
  • Rating: 5
  • Installs: 874
  • Modified: 06/04/2023 10:48
Comments
Log in to add a comment.
No comments found.