Description
The Hull Moving Average (HMA) is one more alternative of an ideal MA that enables smoothing price movements with the help of weighted averages. The indicator was created by Alan Hull.
HMA(n) = WMA(2*WMA(n/2) – WMA(n)),sqrt(n))
Thanks to Paul and Click Algo which develop it for me. I want to give you also this nice Indicator.
using cAlgo.API;
using cAlgo.API.Internals;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class HMAMTF : Indicator
{
[Parameter("TimeFrame")]
public TimeFrame CustomTimeFrame { get; set; }
[Parameter("Price")]
public HMA.PriceType Price { get; set; }
[Parameter("Period", DefaultValue = 14, MinValue = 1)]
public int Period { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Weighted)]
public MovingAverageType MaType { get; set; }
[Output("UpTrend", PlotType = PlotType.DiscontinuousLine, LineColor = "#00FFFF", Thickness = 3)]
public IndicatorDataSeries UpTrend { get; set; }
[Output("DownTrend", PlotType = PlotType.DiscontinuousLine, LineColor = "#DC143C", Thickness = 3)]
public IndicatorDataSeries DownTrend { get; set; }
public IndicatorDataSeries Result { get; private set; }
private MarketSeries _marketSeries;
private HMA _hma;
protected override void Initialize()
{
Result = CreateDataSeries();
_marketSeries = MarketData.GetSeries(CustomTimeFrame);
_hma = Indicators.GetIndicator<HMA>(_marketSeries, Price, Period, MaType);
}
public override void Calculate(int index)
{
var barIndex = _marketSeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);
if (barIndex < 0)
return;
var result = _hma.Result[barIndex];
var trend = _hma.Trend[barIndex];
for (var i = index; i >= MarketSeries.OpenTime.GetIndexByTime(_marketSeries.OpenTime[barIndex]); i--)
{
Result[i] = result;
if (trend > 0)
{
UpTrend[i] = result;
UpTrend[i - 1] = Result[i - 1];
DownTrend[i] = double.NaN;
}
else if (trend < 0)
{
DownTrend[i] = result;
DownTrend[i - 1] = Result[i - 1];
UpTrend[i] = double.NaN;
}
}
}
}
}
IA
IandelMar
Joined on 15.07.2018
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: HMA MTF.algo
- Rating: 5
- Installs: 4491
- Modified: 13/10/2021 09:54
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.
Good one brother. if i want to use this on cBot how can i initialized this indicator
SD
thank you very much, looks excellent. I've been testing on the m15 and its very responsive
I am getting an error on HMA Hull Moving Average Multi Time Frame in cTrader 4.1.
HMA is automatically deleted with warning.
Previous versions of cTrader worked fine for me.
This is an excellent indicator, please update it!