Tow_MACD_In_One free

by MrDeveloper in category Oscilator at 30/09/2022
Description

Using this indicator, you can have two MACDs in one indicator area
Includes a normal MACD and a histogram MACD

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 System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Double_MACD : Indicator
    {

        [Parameter("Long Cycle", DefaultValue = 26)]
        public int LongCycle { get; set; }

        [Parameter("Short Cycle", DefaultValue = 12)]
        public int ShortCycle { get; set; }

        [Parameter("Signal Periods", DefaultValue = 9)]
        public int Periods { get; set; }

        [Parameter()]
        public DataSeries Source { get; set; }

        [Parameter("Long CycleH", DefaultValue = 117)]
        public int LongCycleH { get; set; }

        [Parameter("Short CycleH", DefaultValue = 54)]
        public int ShortCycleH { get; set; }

        [Parameter("Signal PeriodsH", DefaultValue = 41)]
        public int PeriodsH { get; set; }

        private MacdCrossOver _macdCrossOver;
        private MacdHistogram _macdHistogram;

        [Output("MACD", Color = Colors.Blue)]
        public IndicatorDataSeries Macd { get; set; }

        [Output("MACDH", PlotType = PlotType.Histogram, Color = Colors.Green)]
        public IndicatorDataSeries MacdH { get; set; }

        [Output("Signal", LineStyle = LineStyle.Lines, Color = Colors.Red)]
        public IndicatorDataSeries Signal { get; set; }


        [Output("SignalH", LineStyle = LineStyle.Lines, Color = Colors.Yellow)]
        public IndicatorDataSeries SignalH { get; set; }


        protected override void Initialize()
        {
            _macdCrossOver = Indicators.MacdCrossOver(LongCycle, ShortCycle, Periods);
            _macdHistogram = Indicators.MacdHistogram(Source, LongCycleH, ShortCycleH, PeriodsH);

        }

        public override void Calculate(int index)
        {
            Macd[index] = _macdCrossOver.MACD[index];
            MacdH[index] = _macdHistogram.Histogram[index];
            Signal[index] = _macdCrossOver.Signal[index];
            SignalH[index] = _macdHistogram.Signal[index];
        }
    }
}
Comments

leemary13899 - October 03, 2022 @ 10:49

You have given very useful information. Keep it up and keep blogging. I look forward to reading your next post. io games

irmrdeveloper - October 03, 2022 @ 11:29

Thank you for your opinion

irmrdeveloper - October 07, 2022 @ 22:38

When divergence is observed in both indicators (in different proportions), there is a possibility of changing the trend

0