Category Oscilators  Published on 15/09/2022

RVI Force indicator

Description

This indicator is a custom indicator as a product of detrending the original RVI (Relative Vigor Index) indicator, also deriving the bands from the half detrending size.

The propose of indicator is to identify the market sentiment. 

Bullish sentiment when black line is above the bands; Bearish sentiment when black line is below the bands. In case of black line make V shape that mean price action will create HL (higher low) or LH (Lower high). The HL is created when black line is above the red line, the LH is created when black line is below the red line.



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

namespace cAlgo.Indicators
{
    [Levels(0)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mRVIforce : Indicator
    {
        [Parameter(DefaultValue = 14)]
        public int inpPeriodSmooth { get; set; }
        [Parameter(DefaultValue = 10)]
        public int inpPeriodRVI { get; set; }
        [Parameter("Stoch Smooth Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType inpSmoothType { get; set; }

        [Output("BandMid", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries BandMid { get; set; }
        [Output("BandUp", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries BandUp { get; set; }
        [Output("BandDn", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries BandDn { get; set; }

        private IndicatorDataSeries _openclose, _highlow, _rvi;
        private MovingAverage _ma;


        protected override void Initialize()
        {
            _openclose = CreateDataSeries();
            _highlow = CreateDataSeries();
            _rvi = CreateDataSeries();
            _ma = Indicators.MovingAverage(_rvi, inpPeriodSmooth, inpSmoothType);
        }

        public override void Calculate(int i)
        {
            _openclose[i] = ((Bars.ClosePrices[i] - Bars.OpenPrices[i]) + 2 * (Bars.ClosePrices[i - 1] - Bars.OpenPrices[i - 1]) + 2 * (Bars.ClosePrices[i - 2] - Bars.OpenPrices[i - 2]) + (Bars.ClosePrices[i - 3] - Bars.OpenPrices[i - 3])) / 6;
            _highlow[i] = ((Bars.HighPrices[i] - Bars.LowPrices[i]) + 2 * (Bars.HighPrices[i - 1] - Bars.LowPrices[i - 1]) + 2 * (Bars.HighPrices[i - 2] - Bars.LowPrices[i - 2]) + (Bars.HighPrices[i - 3] - Bars.LowPrices[i - 3])) / 6;

            double num = 0;
            double denum = 0;
            for (int j = 0; j < inpPeriodRVI; j++)
            {
                num += _openclose[i - j];
                denum += _highlow[i - j];
            }
            _rvi[i] = num / denum;

            BandMid[i] = (_rvi[i] - _ma.Result[i]) * 50;
            BandUp[i] = (_rvi[i] - BandMid[i] + _ma.Result[i]) / 2;
            BandDn[i] = (_rvi[i] + BandMid[i] + _ma.Result[i]) / 2;
        }
    }
}


mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mRVIforce.algo
  • Rating: 5
  • Installs: 816
Comments
Log in to add a comment.
EX
exporthubsite60 · 1 year ago

ExportHub connects you to the Packaging & Printing Manufacturers, leading suppliers, and exporters. Sign up today!