Category Oscilators  Published on 07/04/2020

MACD RSI (RSI with MA and FastRSI)

Description

An Evolution of my RSI Cloud indicator.

- indexed to 0

- Added Histogram

- Added fast RSI

Makes it look pretty similar to MACD but with OS/OB Area. Only Based on RSI, no MACD in Calculation!

Can be used like MACD and for spotting divergences.

FastRSI can be used for quick scalps or to prevent placing trades in Trend Direction while OS/OB.

 

Fully Customizable 

 

EURUSD 1H

 

 

 If you like my work, feel free to spend me a Corona Beer :-)

Donate


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

namespace cAlgo.Indicators
{
    [Cloud("OB1", "OB2")]
    [Cloud("OS1", "OS2")]
    [Cloud("RSI", "MA")]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class MACDRSI : Indicator
    {
        /////////////////////////////////////////////////////// PARAMETERS 
        // RSI
        [Parameter("Period", Group = "RSI", DefaultValue = 14, MinValue = 1)]
        public int rsiPeriod { get; set; }
        [Parameter("Smooth Period (1=off)", Group = "RSI", DefaultValue = 4, MinValue = 1)]
        public int SmoothPeriod { get; set; }
        [Parameter("Smooth Type", Group = "RSI", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType SmoothType { get; set; }
        // Fast RSI
        [Parameter("Period", Group = "Fast RSI", DefaultValue = 8, MinValue = 1)]
        public int rsiFastPeriod { get; set; }
        // OS/OB Levels
        [Parameter("OS1 Level", Group = "Levels", DefaultValue = -20)]
        public int OS1_value { get; set; }
        [Parameter("OS2 Level", Group = "Levels", DefaultValue = -30)]
        public int OS2_value { get; set; }
        [Parameter("OB1 Level", Group = "Levels", DefaultValue = 20)]
        public int OB1_value { get; set; }
        [Parameter("OB2 Level", Group = "Levels", DefaultValue = 30)]
        public int OB2_value { get; set; }
        // MA of RSI
        [Parameter("Type", Group = "MA of RSI", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MAType { get; set; }
        [Parameter("Period", Group = "MA of RSI", DefaultValue = 20)]
        public int maPeriod { get; set; }
        // HISTOGRAM
        [Parameter("Show", Group = "Histogram", DefaultValue = true)]
        public bool HistogramShow { get; set; }
        [Parameter("Histogram auto-color", Group = "Histogram", DefaultValue = false)]
        public bool OnAdaptive { get; set; }

        /////////////////////////////////////////////////////// LEVELS 
        [Output("OB1", LineColor = "Red", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OB1_level { get; set; }
        [Output("OB2", LineColor = "Red", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OB2_level { get; set; }
        // ---------------
        [Output("OS1", LineColor = "Green", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OS1_level { get; set; }
        [Output("OS2", LineColor = "Green", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OS2_level { get; set; }

        /////////////////////////////////////////////////////// OUTPUTS 

        [Output("Histogram Positive", PlotType = PlotType.Histogram, LineColor = "FF004D00", Thickness = 3)]
        public IndicatorDataSeries HistogramPositive { get; set; }
        [Output("Histogram Negative", PlotType = PlotType.Histogram, LineColor = "FF760002", Thickness = 3)]
        public IndicatorDataSeries HistogramNegative { get; set; }

        [Output("Mid", LineColor = "Gray", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries midlevel { get; set; }

        [Output("FastRSI", LineColor = "FF7B5E00", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries fastRSIResult { get; set; }

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

        [Output("RSI", LineColor = "Lime", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries RSIResult { get; set; }

        ///////////////////////////////////////////////////////  
        private MovingAverage _ma;
        private RelativeStrengthIndex _rsi, _fastrsi;
        private MovingAverage _rsismooth;
        private IndicatorDataSeries _histogram;
        private DataSeries _ds;
        /////////////////////////////////////////////////////// INITIALIZE 
        protected override void Initialize()
        {
            _ds = Bars.TypicalPrices;
            _rsi = Indicators.RelativeStrengthIndex(_ds, rsiPeriod);
            _fastrsi = Indicators.RelativeStrengthIndex(_ds, rsiFastPeriod);
            _rsismooth = Indicators.MovingAverage(_rsi.Result, SmoothPeriod, SmoothType);
            _ma = Indicators.MovingAverage(_rsi.Result, maPeriod, MAType);
            _histogram = CreateDataSeries();
        }


        /////////////////////////////////////////////////////// CALCULATE 
        public override void Calculate(int index)
        {
            // Levels
            OS1_level[index] = OS1_value;
            OS2_level[index] = OS2_value;
            OB1_level[index] = OB1_value;
            OB2_level[index] = OB2_value;
            midlevel[index] = 0;

            // RSI
            RSIResult[index] = _rsismooth.Result[index] - 50;
            // MA
            MAofRSI[index] = _ma.Result[index] - 50;
            // fastRSI
            fastRSIResult[index] = _fastrsi.Result[index] - 50;

            // Histogram
            if (HistogramShow)
            {
                _histogram[index] = _rsismooth.Result[index] - _ma.Result[index];

                if (OnAdaptive)
                {
                    if (_histogram[index] > _histogram[index - 1])
                        HistogramPositive[index] = _histogram[index];

                    else if (_histogram[index] < _histogram[index - 1])
                        HistogramNegative[index] = _histogram[index];
                }
                else
                {
                    if (_histogram[index] > 0)
                        HistogramPositive[index] = _histogram[index];

                    else if (_histogram[index] < 0)
                        HistogramNegative[index] = _histogram[index];
                }
            }
        }

    }
}


DO
DontMatter

Joined on 15.11.2019

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: MACD RSI.algo
  • Rating: 0
  • Installs: 3589
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
IT
itchiban · 2 months ago

looks great, lets make some pips :D

HA
hazwanofficial · 4 years ago

hi is this indicator repaint? i think its too good