Hull Moving Average Indicator in MQL5 - Trend Change marked by a Buffer/ Output

MQL5 Indikatoren

Auftrag beendet

Ausführungszeit 44 Minuten
Bewertung des Kunden
Simple. Good Work.
Bewertung des Entwicklers
Thanks so much!!!!!

Spezifikation

Dear coders,

we need a Hull Moving Average Indicator (HMA) in MQL5.

The following buffers with certain outputs are needed:

  • A trend change - marked by the HMA - needs to be detectable by an output/ buffer of the required indicator.

    For instance a switch from a positive slope to a negative slope of the HMA is marked with a "-1" as output.

    A switch from a negative slope to a positive slope of the HMA is marked with a "+1" as output.

  • An uptrend - marked by the HMA - is marked with "+1"

  • A downtrend - marked by the HMA - is marked with "-1"


An alternative would be:

  • For instance a switch from a positive slope to a negative slope of the HMA is marked by buffer 1.

    A switch from a negative slope to a positive slope of the HMA is marked by buffer 2.

  • An uptrend - marked by the HMA - is marked by buffer 3.

  • A downtrend - marked by the HMA - is marked by buffer 4.

Introduction to the idea behind the HMA

The Hull Moving Average (HMA) attempts to minimize the lag of a traditional moving average while retaining the smoothness of the moving average line. The HMA can be interpreted in a similar way to traditional moving averages, but it responds more quickly. Like other moving averages, it can be used to confirm a trend or spot a change in the trend.


Calculation of the HMA

The formula for the Hull Moving Average uses two different weighted moving averages (WMAs) of price, plus a third WMA to smooth the raw moving average. There are three parts to the calculation. In the formulas listed below, “n” indicates the number of periods specified by the chartist.


First, calculate two WMAs: one with the specified number of periods and one with half the specified number of periods.

WMA1 = WMA(n/2) of price

WMA2 = WMA(n) of price


Second, calculate the raw (non-smoothed) Hull Moving Average.

Raw HMA = (2 * WMA1) - WMA2


Third, smooth the raw HMA with another WMA, this one with the square root of the specified number of periods.

HMA = WMA(sqrt(n)) of Raw HMA


Of course, when you divide a whole number by two or calculate its square root, you don't always end up with a whole number as a result. In that case, we round the result to the nearest whole number, so we can use that as the number of periods when calculating weighted moving averages.

For example, when calculating an 11-day HMA, we end up with non-whole numbers for two of our WMAs. For calculating the n/2 WMA, 11/2 is 5.5, so we would round that up to 6 for the WMA calculation. For the sqrt(n) WMA, the square root of 11 is 3.317, so we would round that down to 3 for the number of WMA periods in the final smoothing calculation.

You can find an exemplary HMA in MQL4 down below (CAUTIOUS: This MQL4 version does not have a buffer, which marks a trend change. BUT we need that in the MQL5 version). However, there you see how the HMA is calculated:

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//---- input parameters 
extern int       period=15;
extern int       method=3;                        
extern int       price=0;                           
//---- buffers 
double Uptrend[];
double Dntrend[];
double ExtMapBuffer[];
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init()
  {
   IndicatorBuffers(3);
   SetIndexBuffer(0, Uptrend);
   //ArraySetAsSeries(Uptrend, true); 
   SetIndexBuffer(1, Dntrend);
   //ArraySetAsSeries(Dntrend, true); 
   SetIndexBuffer(2, ExtMapBuffer);
   ArraySetAsSeries(ExtMapBuffer, true);
//----
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
//----
   IndicatorShortName("Signal Line("+period+")");
   return(0);
  }
//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit()
  { 
   return(0);
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double WMA(int x, int p)
  {
   return(iMA(NULL, 0, p, 0, method, price, x));
  }
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start()
  {
   int counted_bars=IndicatorCounted();
   if(counted_bars < 0)
      return(-1);
//----
   int x=0;
   int p=MathSqrt(period);
   int e=Bars - counted_bars + period + 1;
//----
   double vect[], trend[];
//----
   if(e > Bars)
      e=Bars;
//----
   ArrayResize(vect, e);
   ArraySetAsSeries(vect, true);
   ArrayResize(trend, e);
   ArraySetAsSeries(trend, true);
//----
   for(x=0; x < e; x++)
     {
      vect[x]=2*WMA(x, period/2) - WMA(x, period);
      }
   for(x=0; x < e-period; x++)
//----
      ExtMapBuffer[x]=iMAOnArray(vect, 0, p, 0, method, x);
   for(x=e-period; x>=0; x--)
     {
      trend[x]=trend[x+1];
      if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1;
      if (ExtMapBuffer[x]< ExtMapBuffer[x+1]) trend[x] =-1;
      if (trend[x]>0)
        { 
         Uptrend[x]=ExtMapBuffer[x];
         if (trend[x+1]<0) Uptrend[x+1]=ExtMapBuffer[x+1];
         Dntrend[x]=EMPTY_VALUE;
        }
      else
         if (trend[x]<0)
           {
            Dntrend[x]=ExtMapBuffer[x];
            if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1];
            Uptrend[x]=EMPTY_VALUE;
           }
      }
   return(0);
  }
//+------------------------------------------------------------------+ 


This screenshot shows the HMA with a inputPeriod of 50. The aimed indicator should look like this at the end and mark those switches from green to red/ red to green.

Please let me know if anything remains unclear!





Bewerbungen

1
Entwickler 1
Bewertung
(2662)
Projekte
3384
68%
Schlichtung
77
48% / 14%
Frist nicht eingehalten
342
10%
Frei
Veröffentlicht: 1 Beispiel
2
Entwickler 2
Bewertung
(298)
Projekte
427
26%
Schlichtung
18
61% / 33%
Frist nicht eingehalten
26
6%
Frei
Veröffentlicht: 8 Beispiele
3
Entwickler 3
Bewertung
(119)
Projekte
169
38%
Schlichtung
9
78% / 22%
Frist nicht eingehalten
15
9%
Frei
4
Entwickler 4
Bewertung
(174)
Projekte
199
12%
Schlichtung
38
37% / 34%
Frist nicht eingehalten
5
3%
Arbeitet
Veröffentlicht: 2 Beispiele
Ähnliche Aufträge
This robot is going to help me to assist my parents about their needs, it also going help me build a house and purchase my own car. Additionally, it is going to play an essential role upon my life as I will not struggle with the foods and transport for taking the trips
I am looking for a serious marketer with experience in promoting trading tools or Expert Advisors for MetaTrader 5. The product is an automated MT5 trading EA focused on Gold trading, with risk-management tools and trading filters designed to improve trade quality. For credibility, I will provide: An Investor Account for a live/demo account where the EA has been running for a while Backtest reports for the EA Clear
Gold Precision Pro 30 - 100 USD
I want the indicator to be built professionally and carefully because the strategy is strong, but it requires advanced and clean programming. The indicator should work mainly on XAUUSD M15 and should generate more than 2 high-quality signals per day, ideally around 2 to 4 signals maximum, without flooding the chart. The logic must not be random. Each signal must be based on: HTF Bias from H1/H4, Liquidity Sweep
Good day, I would like to have an expert advisor for my MT4 indicator (Major key alert) that can scan and provide push notification messages for entry opportunities across different time frames when a when a signal is identified
Modify an existing EA 30 - 50 USD
This is to modify my Semi Auto EA -Looking for developer modify my existing EA to Pending Order EA (BS/BL/SL/SS). Relevent with Heiken Ashi Smooth ,Moving Average , Acceleration. Concept MAster and Slave. Ready to give previous soucre code as guide. Work to do - 1)To modify this EA to Pending Order. 2) to add new feature - Risk Management/moneymanagement 3) To modify 4 slave to 7 slave will give the previous to
I have a indicator working good but have some bug for arrow placement . budget is fixed 30 used . only experience developer apply. i want to arrow get put on just above the candle high and candle low
I am looking to get this Indicator but i don't know which indicator is it , if anyone know about it let me know , images are attached , this is used for Binary Pairs
Pip Scalper Bot 60+ USD
i want a trading bot that is aleast 98% sure,and cam also do scalping 99% correct using smart money concept, ICT, ALL technical analysis on it and also put risk management on it
Greetings I need MT5 developer that has expertise in developing a custom indicator for mt5 boom and crash based on my exact details and requirements which would be discuss later. Kindly bid for this project if it is something you can handle for me
Hello, I have a Ctrader indicator with the source code, I was wondering if this possible to convert it to Quantower. Hello, I have a Ctrader indicator with the source code, I was wondering if tis possible to convert it to Quantower., i need an expert who can convert it perfectly

Projektdetails

Budget
30 - 50 USD
Ausführungsfristen
von 1 bis 5 Tag(e)