Category Trend  Published on 15/01/2023

High-Low ROC (Rate Of Change)

Description

The High-Low ROC is a custom indicator based on the Rate of Change (ROC) technical analysis factor. Use this indicator for a long zone when the values are above the zero level. Also, use this indicator for a short zone when the values are below the zero level.

For more information about short-term and long-term price momentum pressure, this indicator is used in five periods (for example, 10, 20, 50, 100, 200). Confluence in all different periods shows the exact direction of price movement in the near future.

 

 


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

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mHighLowROC : Indicator
    {
        [Parameter("Main Period (7)", DefaultValue = 7)]
        public int inpPeriod { get; set; }
        [Parameter("Smooth Period (3)", DefaultValue = 3)]
        public int inpPeriodSmooth { get; set; }
        [Parameter("Use Smooth (yes)", DefaultValue = true)]
        public bool inpUseSmooth { get; set; }

        [Output("High~Low ROC", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outHLROC { get; set; }

        private IndicatorDataSeries _hlroc, _hh, _ll, _deltahh, _deltall, _hmember, _lmember;
        private MovingAverage _smooth;

        protected override void Initialize()
        {
            _hlroc = CreateDataSeries();
            _hh = CreateDataSeries();
            _ll = CreateDataSeries();
            _deltahh = CreateDataSeries();
            _deltall = CreateDataSeries();
            _hmember = CreateDataSeries();
            _lmember = CreateDataSeries();
            _smooth = inpUseSmooth == true ? Indicators.MovingAverage(_hlroc, inpPeriodSmooth, MovingAverageType.Exponential) : null;
        }

        public override void Calculate(int i)
        {
            _hh[i] = i>inpPeriod ? Bars.HighPrices.Maximum(inpPeriod) : Bars.HighPrices[i];
            _ll[i] = i>inpPeriod ? Bars.LowPrices.Minimum(inpPeriod) : Bars.LowPrices[i];
            _deltahh[i] = i>1 ? _hh[i] - _hh[i-1] : _hh[i] - Bars.MedianPrices[i]; 
            _deltall[i] = i>1 ? _ll[i] - _ll[i-1] : _ll[i] - Bars.MedianPrices[i];
            _hmember[i] = i>1 && _deltahh[i] > _deltahh[i-1] ? _deltahh.Maximum(inpPeriod) : 0;
            _lmember[i] = i>1 && _deltall[i] < _deltall[i-1] ? _deltall.Minimum(inpPeriod) : 0;
            _hlroc[i] = _hmember.Sum(inpPeriod) + _lmember.Sum(inpPeriod);
            
            outHLROC[i] = inpUseSmooth == true ? _smooth.Result[i] / Symbol.PipSize : _hlroc[i] / Symbol.PipSize;
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mHighLowROC.algo
  • Rating: 5
  • Installs: 172
Comments
Log in to add a comment.
No comments found.