Three MACD in One Area with Custom Shift free

by irmrdeveloper in category Oscilator at 20/11/2022
Description

By using this indicator, we can observe faster and slower divergences at the same time as the MACD default value and make better decisions.
Also, move the coordinates of each forward and backward on the x-axis as desired
Smaller MACD provides faster signals and larger MACD provides reliable signals
Be sure to Backtest before use and don't use signal lines
Wishing everyone success

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 TripleMACD : Indicator
    {

        [Parameter("Long Cycle", DefaultValue = 27)]
        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("Shift", DefaultValue = 0)]
        public int Shift { get; set; }

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

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

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

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

        [Parameter("Long CycleL", DefaultValue = 12)]
        public int LongCycleL { get; set; }

        [Parameter("Short CycleL", DefaultValue = 4)]
        public int ShortCycleL { get; set; }

        [Parameter("Signal PeriodsL", DefaultValue = 3)]
        public int PeriodsL { get; set; }
        
        [Parameter("ShiftL", DefaultValue = 0)]
        public int ShiftL { get; set; }

        private MacdCrossOver _macdCrossOver;
        private MacdCrossOver __macdCrossOver;
        private MacdHistogram _macdHistogram;

        [Output("MACD", LineColor = "D6359CDA")]
        public IndicatorDataSeries Macd { get; set; }
        
        [Output("MACDL", LineColor = "D3BF9100")]
        public IndicatorDataSeries MacdL { get; set; }

        [Output("MACDH", PlotType = PlotType.Histogram, LineColor = "7000796B")]
        public IndicatorDataSeries MacdH { get; set; }

        [Output("Signal", LineStyle = LineStyle.Lines, LineColor = "15008000")]
        public IndicatorDataSeries Signal { get; set; }

        [Output("SignalH", LineStyle = LineStyle.Lines, LineColor = "15008000")]
        public IndicatorDataSeries SignalH { get; set; }
        
        [Output("SignalL", LineStyle = LineStyle.Lines, LineColor = "15008000")]
        public IndicatorDataSeries SignalL { get; set; }


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

        }

        public override void Calculate(int index)
        {
            
            Macd[index + Shift] = _macdCrossOver.MACD[index];
            MacdL[index + ShiftL] = __macdCrossOver.MACD[index];
            MacdH[index + ShiftH] = _macdHistogram.Histogram[index];
            Signal[index + Shift] = _macdCrossOver.Signal[index];
            SignalL[index + ShiftL] = __macdCrossOver.Signal[index]; 
            SignalH[index + ShiftH] = _macdHistogram.Signal[index];
        }
    }
}
Comments

alicejenny313 - November 23, 2022 @ 03:28

What a very nice post! Thank you so much and I am really looking forward to reading more and more articles from you. 

five nights at freddy's

0