HLAveragesTFComposite free

by srm_bcn in category Trend at 02/08/2020
Description

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 = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class HLAveragesTFMeanComposite : Indicator
    {
        [Output("Result1", LineColor = "Green")]
        public IndicatorDataSeries Result1 { get; set; }

        [Output("Result2", LineColor = "Red")]
        public IndicatorDataSeries Result2 { get; set; }

        [Output("Result3", LineColor = "Aqua")]
        public IndicatorDataSeries Result3 { get; set; }

        [Output("Result4", LineColor = "Green")]
        public IndicatorDataSeries Result4 { get; set; }

        [Output("Result5", LineColor = "Red")]
        public IndicatorDataSeries Result5 { get; set; }

        [Output("Result6", LineColor = "Aqua")]
        public IndicatorDataSeries Result6 { get; set; }

        [Output("Result7", LineColor = "Green")]
        public IndicatorDataSeries Result7 { get; set; }

        [Output("Result8", LineColor = "Red")]
        public IndicatorDataSeries Result8 { get; set; }

        [Output("Result9", LineColor = "Aqua")]
        public IndicatorDataSeries Result9 { get; set; }

        [Output("Result10", LineColor = "Green")]
        public IndicatorDataSeries Result10 { get; set; }

        [Output("Result11", LineColor = "Red")]
        public IndicatorDataSeries Result11 { get; set; }

        [Output("Result12", LineColor = "Aqua")]
        public IndicatorDataSeries Result12 { get; set; }

        [Output("Result13", LineColor = "Green")]
        public IndicatorDataSeries Result13 { get; set; }

        [Output("Result14", LineColor = "Red")]
        public IndicatorDataSeries Result14 { get; set; }

        [Output("Result15", LineColor = "Aqua")]
        public IndicatorDataSeries Result15 { get; set; }

        private HLAveragesTF hlam1, hlam5, hlam15, hlam30, hlah1;

        private double sellaverage, buyaverage, mean;

        protected override void Initialize()
        {
            hlam1 = Indicators.GetIndicator<HLAveragesTF>(TimeFrame.Minute);
            hlam5 = Indicators.GetIndicator<HLAveragesTF>(TimeFrame.Minute5);
            hlam15 = Indicators.GetIndicator<HLAveragesTF>(TimeFrame.Minute15);
            hlam30 = Indicators.GetIndicator<HLAveragesTF>(TimeFrame.Minute30);
            hlah1 = Indicators.GetIndicator<HLAveragesTF>(TimeFrame.Hour);
        }

        public override void Calculate(int index)
        {
            sellaverage = (hlam1.Result1[index] + hlam5.Result1[index] + hlam15.Result1[index] + hlam30.Result1[index] + hlah1.Result1[index]) / 5;
            buyaverage = (hlam1.Result2[index] + hlam5.Result2[index] + hlam15.Result2[index] + hlam30.Result2[index] + hlah1.Result2[index]) / 5;
            mean = (hlam1.Result3[index] + hlam5.Result3[index] + hlam15.Result3[index] + hlam30.Result3[index] + hlah1.Result3[index]) / 5;

            Result1[index] = sellaverage;
            Result2[index] = buyaverage;
            Result3[index] = mean;

            sellaverage = (hlam1.Result1[index] + hlam5.Result1[index] + hlam15.Result1[index] + hlam30.Result1[index]) / 4;
            buyaverage = (hlam1.Result2[index] + hlam5.Result2[index] + hlam15.Result2[index] + hlam30.Result2[index]) / 4;
            mean = (hlam1.Result3[index] + hlam5.Result3[index] + hlam15.Result3[index] + hlam30.Result3[index]) / 4;

            Result4[index] = sellaverage;
            Result5[index] = buyaverage;
            Result6[index] = mean;

            sellaverage = (hlam1.Result1[index] + hlam5.Result1[index] + hlam15.Result1[index]) / 3;
            buyaverage = (hlam1.Result2[index] + hlam5.Result2[index] + hlam15.Result2[index]) / 3;
            mean = (hlam1.Result3[index] + hlam5.Result3[index] + hlam15.Result3[index]) / 3;

            Result7[index] = sellaverage;
            Result8[index] = buyaverage;
            Result9[index] = mean;

            sellaverage = (hlam1.Result1[index] + hlam5.Result1[index]) / 2;
            buyaverage = (hlam1.Result2[index] + hlam5.Result2[index]) / 2;
            mean = (hlam1.Result3[index] + hlam5.Result3[index]) / 2;

            Result10[index] = sellaverage;
            Result11[index] = buyaverage;
            Result12[index] = mean;

            sellaverage = hlam1.Result1[index];
            buyaverage = hlam1.Result2[index];
            mean = hlam1.Result3[index];

            Result13[index] = sellaverage;
            Result14[index] = buyaverage;
            Result15[index] = mean;
        }
    }
}
Comments
0