Category Oscilators  Published on 08/09/2022

Relative Momentum Index indicator

Description

Relative Momentum Index indicator script. This indicator was originally developed by Roger Altman (Stocks & Commodities V. 11:2 (57-60)).

Use this indicator as trade zones; for long when indicator value is above level 70; for short when indicator value is below level 30

 



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

namespace cAlgo
{
    [Levels(30, 50, 70)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mRelativeMomentumIndex : Indicator
    {
        [Parameter("RMI Periods (14)", DefaultValue = 7)]
        public int inpPeriodsRMI { get; set; }
        [Parameter("Momentum Periods (10)", DefaultValue = 5)]
        public int inpPeriodMomentum { get; set; }

        [Output("Relative Momentum Index", LineColor = "Black", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outRMI { get; set; }

        private IndicatorDataSeries _bulls, _bears, _rmi;
        private double delta;


        protected override void Initialize()
        {
            _bulls = CreateDataSeries();
            _bears = CreateDataSeries();
            _rmi = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            delta = i > inpPeriodMomentum ? Bars.ClosePrices[i] - Bars.ClosePrices[i - inpPeriodMomentum] : Bars.ClosePrices[i] - Bars.TypicalPrices[i];

            _bulls[i] = ((i > 1 ? _bulls[i - 1] : 50.0) * (inpPeriodsRMI - 1) + (delta > 0.0 ? +delta : 0.0)) / inpPeriodsRMI;
            _bears[i] = ((i > 1 ? _bears[i - 1] : 50.0) * (inpPeriodsRMI - 1) + (delta < 0.0 ? -delta : 0.0)) / inpPeriodsRMI;

            if (_bears[i] != 0.0)
                _rmi[i] = 100.0 - 100.0 / (1 + _bulls[i] / _bears[i]);
            else
                _rmi[i] = 50.0;

            outRMI[i] = _rmi[i];
        }
    }
}


mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mRelativeMomentumIndex.algo
  • Rating: 5
  • Installs: 708
Comments
Log in to add a comment.
GM
gmkenneyy · 1 year ago

"Use this indicator as trade zones; for long when indicator value is above level 70; for short when indicator value is below level 30"

I dont not belive this to be correct according to the screen shot YOU provided - i think you meant <30 go long, > 70 go short