Category Trend  Published on 29/08/2022

Two 34HMA Cross

Description

Note: if you are the owner of the original indicator and would like me to remove this port, please feel free to message me and I will be happy to do so.

Another port of an existing indicator - this one is by PP Signal. All credit goes to the owner. The original indicator I ported can be found here

I have only included the calculations of the two 34-period Hull Moving Averages along with a basic trend cloud. I cannot be bothered to add on the buy and sell signal labels, but if anybody would like to, please feel free to build upon this script.

This technical works very well in trending markets, but not so well in ranging and consolidating markets (as expected with one based on the Hull Moving Average).

Chartshots:

EURUSD, H1 - good example of a trending market here, the indicator works reasonably well.

 

GBPCHF, M15 - a ranging market. You can see that, due to the reliance upon candle closes for calculations, the indicator is very unresponsive to this type of market. Be very cautious when using this indicator.

 


using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Cloud("HMA", "Offset HMA", FirstColor = "Green", Opacity = 0.8, SecondColor = "Red")]

    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class Two34HMACross : Indicator
    {
        private WeightedMovingAverage _wma;
        private WeightedMovingAverage _wma2;
        private WeightedMovingAverage _wma3;
        private WeightedMovingAverage _wma4;
        private IndicatorDataSeries _iSeries;
        private IndicatorDataSeries _oSeries;

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

        [Parameter(DefaultValue = 20, MinValue = 1)]
        public int Period { get; set; }


        [Output("HMA", Color = Colors.Green)]
        public IndicatorDataSeries HMAResult { get; set; }
        
        [Output("Offset HMA", Color = Colors.Red)]
        public IndicatorDataSeries OffsetResult { get; set; }

        protected override void Initialize()
        {
        
            _iSeries = CreateDataSeries();
            _oSeries = CreateDataSeries();
            _wma = Indicators.WeightedMovingAverage(Source, Period / 2);
            _wma2 = Indicators.WeightedMovingAverage(Source, Period);
            _wma3 = Indicators.WeightedMovingAverage(_iSeries, (int) Math.Sqrt(Period));
            _wma4 = Indicators.WeightedMovingAverage(_oSeries, (int) Math.Sqrt(Period));
            
        }
        public override void Calculate(int index)
        {
            double price = Source[index];

            if (index < Period)
            {
                HMAResult[index] = price;
                return;
            }

            _iSeries[index] = 2 * _wma.Result[index] - _wma2.Result[index];
            if (index != 0)
            {
                _oSeries[index] = _iSeries[index - 1];
            }
            else 
            {
                _oSeries[index] = _iSeries[index];
            }
            HMAResult[index] = _wma3.Result[index];
            OffsetResult[index] = _wma4.Result[index];
            
            

        }
    }
}


o6h58zs's avatar
o6h58zs

Joined on 17.07.2022 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Two 34HMA Cross.algo
  • Rating: 0
  • Installs: 854
  • Modified: 28/08/2022 17:31
Comments
Log in to add a comment.
LI
liomrgn · 2 years ago

Only the two 34-period Hull Moving Average computations and a simple trend cloud have been included. I can't be bothered to add the labels for the buy and sell signals, but if anyone is interested, feel free to get in touch with web design slash to expand upon script.

JO
joyeuxnye · 2 years ago

The information you have posted is very useful. cuphead