Description
DiNapoli MACD indicator is a zone and trigger trading oscillator, developed based on tradition MACD.
In this version you should trade when the cross happen above the zero level for long trades (macd[0]>signal[0] & macd[1]<signal[1] & signal[0]>0), and when the cross happen below the zero level for short trades (macd[0]<signal[0] & macd[1]>signal[1] & signal[0]<0)
In upper timeframes the same signal conditions you can use as a trade zone.
The following picture shows two cases of buying and selling triggers
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Levels(0)]
[Cloud("MACD", "Signal", FirstColor = "Green", SecondColor = "Red", Opacity = 0.1)]
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mMACDdinapoli : Indicator
{
[Parameter("Long Cycle", DefaultValue = 17.5185)]
public double inpLongCycle { get; set; }
[Parameter("Short Cycle", DefaultValue = 8.3896)]
public double inpShortCycle { get; set; }
[Parameter("Signal Length", DefaultValue = 9.0503)]
public double inpSignalLength { get; set; }
[Output("MACD", LineColor = "Black", LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outMACD { get; set; }
[Output("Signal", LineColor = "Red", LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outSignal { get; set; }
[Output("Histogram", LineColor = "Gray", PlotType = PlotType.Histogram, Thickness = 3)]
public IndicatorDataSeries outHist { get; set; }
private IndicatorDataSeries _fastcomponent, _slowcomponent, _macd, _signal, _histogram;
protected override void Initialize()
{
_fastcomponent = CreateDataSeries();
_slowcomponent = CreateDataSeries();
_macd = CreateDataSeries();
_signal = CreateDataSeries();
_histogram = CreateDataSeries();
}
public override void Calculate(int i)
{
_fastcomponent[i] = i>1 ? _fastcomponent[i-1] + 2.0 / (1.0 + inpShortCycle) * (Bars.ClosePrices[i] - _fastcomponent[i-1]) : Bars.ClosePrices[i] - Bars.TypicalPrices[i];
_slowcomponent[i] = i>1 ? _slowcomponent[i-1] + 2.0 / (1.0 + inpLongCycle) * (Bars.ClosePrices[i] - _slowcomponent[i-1]) : Bars.ClosePrices[i] - Bars.TypicalPrices[i];
_macd[i] = _fastcomponent[i] - _slowcomponent[i];
_signal[i] = i>1 ? _signal[i-1] + 2.0 / (1 + inpSignalLength) * (_macd[i] - _signal[i-1]) : _fastcomponent[i]+_macd[i];
_histogram[i] = i > 5 ? _macd[i] - _signal[i] : 0;
outMACD[i] = _macd[i];
outSignal[i] = _signal[i];
outHist[i] = _histogram[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mMACDdinapoli.algo
- Rating: 5
- Installs: 1488
- Modified: 26/10/2022 21:06
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.