HLC Trend free

by cW22Trader in category Trend at 05/08/2021
Description

Simple indicator which identifies trends based on a comparison of the MA value of close - MA value of high and the MA value of low - MA value of close.

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class HLCTrend : Indicator
    {
        [Parameter("Close Period", DefaultValue = 5, MinValue = 1)]
        public int ClosePeriod { get; set; }

        [Parameter("High Period", DefaultValue = 30, MinValue = 1)]
        public int HighPeriod { get; set; }

        [Parameter("Low Period", DefaultValue = 13, MinValue = 1)]
        public int LowPeriod { get; set; }

        [Parameter("MA Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MaType { get; set; }



        [Output("Close High MA", LineColor = "Green", Thickness = 2)]
        public IndicatorDataSeries CH { get; set; }

        [Output("Low Close MA", LineColor = "Red", Thickness = 2)]
        public IndicatorDataSeries LC { get; set; }



        private MovingAverage maClose, maHigh, maLow;



        protected override void Initialize()
        {
            maClose = Indicators.MovingAverage(Bars.ClosePrices, ClosePeriod, MaType);
            maHigh = Indicators.MovingAverage(Bars.HighPrices, HighPeriod, MaType);
            maLow = Indicators.MovingAverage(Bars.LowPrices, LowPeriod, MaType);
        }

        public override void Calculate(int index)
        {
            CH[index] = maClose.Result[index] - maHigh.Result[index];
            LC[index] = maLow.Result[index] - maClose.Result[index];
        }
    }
}
Comments
0