Description
Follow my cTrader Telegram group at https://t.me/cTraderCommunity; it's a new community but it will grow fast, plus everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp
This is Dan Valcu's HADelta, a very good trend indicator and a FANTASTIC divergence revelaer.
Because of its calculation similar to a signed-ATR based on HA candles (even though i calculates the range on the body of the candle) it can spot real divergences, unlike the classical RSI or MACD which half of the time (or more) form divergences because of the inertia of their formulas.
When this indicator diverge, it means that the chart is both having more candle of the opposite color AND smaller candles (meaning less volatility), this makes the divergence real and not implied by his math's inertia.
For any bug report or suggestion, feel free to contact me by joing the group linked above or by commenting below
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class HADelta : Indicator
{
[Parameter("SMA Periods", DefaultValue = 3)]
public int per { get; set; }
[Parameter("MA Type")]
public MovingAverageType maType { get; set; }
[Parameter("Show HAD", DefaultValue = true)]
public bool showHAD { get; set; }
[Output("Main", LineColor = "Red")]
public IndicatorDataSeries Result { get; set; }
[Output("HAD", LineColor = "RoyalBlue")]
public IndicatorDataSeries HAD { get; set; }
private IndicatorDataSeries haOpen, haClose, diff;
private SimpleMovingAverage sma;
private ExponentialMovingAverage ema;
private TimeSeriesMovingAverage ts;
private WeightedMovingAverage wma;
private Vidya vid;
private TriangularMovingAverage trn;
private WellesWilderSmoothing wds;
protected override void Initialize()
{
haOpen = CreateDataSeries();
haClose = CreateDataSeries();
diff = CreateDataSeries();
IndicatorArea.DrawHorizontalLine("0", 0, Color.Gray);
if (maType == MovingAverageType.Simple)
sma = Indicators.SimpleMovingAverage(diff, per);
else if (maType == MovingAverageType.Exponential)
ema = Indicators.ExponentialMovingAverage(diff, per);
else if (maType == MovingAverageType.TimeSeries)
ts = Indicators.TimeSeriesMovingAverage(diff, per);
else if (maType == MovingAverageType.Weighted)
wma = Indicators.WeightedMovingAverage(diff, per);
else if (maType == MovingAverageType.VIDYA)
vid = Indicators.Vidya(diff, per, 0.65);
else if (maType == MovingAverageType.Triangular)
trn = Indicators.TriangularMovingAverage(diff, per);
else if (maType == MovingAverageType.WilderSmoothing)
wds = Indicators.WellesWilderSmoothing(diff, per);
}
public override void Calculate(int index)
{
var open = MarketSeries.Open[index];
var high = MarketSeries.High[index];
var low = MarketSeries.Low[index];
var close = MarketSeries.Close[index];
haClose[index] = (open + high + low + close) / 4;
if (index > -1 && !double.IsNaN(haOpen[index - 1]))
haOpen[index] = (haOpen[index - 1] + haClose[index - 1]) / 2;
else
haOpen[index] = (open + close) / 2;
diff[index] = haClose[index] - haOpen[index];
if (maType == MovingAverageType.Simple)
Result[index] = sma.Result[index];
else if (maType == MovingAverageType.Exponential)
Result[index] = ema.Result[index];
else if (maType == MovingAverageType.TimeSeries)
Result[index] = ts.Result[index];
else if (maType == MovingAverageType.Weighted)
Result[index] = wma.Result[index];
else if (maType == MovingAverageType.VIDYA)
Result[index] = vid.Result[index];
else if (maType == MovingAverageType.Triangular)
Result[index] = trn.Result[index];
else if (maType == MovingAverageType.WilderSmoothing)
Result[index] = wds.Result[index];
if (showHAD)
HAD[index] = diff[index];
}
}
}
cysecsbin.01
Joined on 10.11.2018 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: HADelta.algo
- Rating: 5
- Installs: 1784
- Modified: 13/10/2021 09:54
This is indeed a fantastic indicator. Let us all join his Discord Server were friendly traders meet.