Category Trend  Published on 21/09/2023

HighLow Rate of Change indicator

An update for this algorithm is currently pending moderation. Please revisit this page shortly to access the algorithm's latest version.
Description

This custom indicator, known as the 'High-Low Rate of Change,' is designed to measure the rate of change between the highest highs and lowest lows in the market.

The indicator calculates the difference between the current highest high and the previous highest high, as well as the difference between the current lowest low and the previous lowest low. It then identifies the maximum value for the higher high and the minimum value for the lower low, applying some filtering to refine these values.

Additionally, there is an option to apply smoothing to the indicator output values using an Exponential Moving Average (EMA).

The primary purpose of this indicator is to interpret market sentiment with optimized lag and high sensitivity reaction. When the indicator's output values are above the zero level, it suggests a bullish sentiment, while values below the zero level indicate a bearish sentiment.

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 = Indicators.MovingAverage(_hlroc, inpPeriodSmooth, MovingAverageType.Exponential);
        }

        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: 381
Comments
Log in to add a comment.
No comments found.