Description
Using this indicator, you can have two MACDs in one indicator area
Includes a normal MACD and a histogram MACD
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];
}
}
}
MR
MrDeveloper
Joined on 30.09.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Tow_MACD.algo
- Rating: 0
- Installs: 620
- Modified: 30/09/2022 11:05
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.