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
(2428)
Projekte
3057
66%
Schlichtung
77
48% / 14%
Frist nicht eingehalten
340
11%
Arbeitet
2
Entwickler 2
Bewertung
(298)
Projekte
427
26%
Schlichtung
18
61% / 33%
Frist nicht eingehalten
26
6%
Frei
3
Entwickler 3
Bewertung
(119)
Projekte
169
38%
Schlichtung
9
78% / 22%
Frist nicht eingehalten
15
9%
Frei
4
Entwickler 4
Bewertung
(170)
Projekte
193
11%
Schlichtung
37
38% / 35%
Frist nicht eingehalten
5
3%
Beschäftigt
Ähnliche Aufträge
EA DEJA FABRIQUE ? MODIFIER QUELQUE LIGNE POUR LE RENDRE RENTABLE /////////////////////++++++++++++++++++++++++++++++++++ EA AVEC UN SYTEME SIMPLE ; SEULEMENT A MODIFIER %%%%%%%%%%%%%%%%%% SI PERSONNE SACHANT CODER CORRECTEMENT , CE TRAVAIL EST POUR TOI
Buy an sell symbols and guide showing entry to buy or sell setups and I need it gives and tell me to enter buy or to enter sell by automation nnnnnnnnnn fgggghhuuuiijh hhrddfhuuufffff yygggg hhgt hiidcb hygdfbby gyytdv uttrdd. Httdd hyyydv. Yhygf. Uu juhgff uyttt uuuytdbhy uuuyyy hhhff jjueeiivhgffdgu hyuu7trg yyyyffj yyytd u6tttf uuyrrrhi uytrrfh utterly jyrfgkkttv uhyybhhyy hytfgivuyt utfbh utghjio7t. Uuytg uytru
Utilizing the MQL5 MetaEditor Wizard, I created an Expert Advisor, having the following Signal indicators: I was able to optimize the EA and reached a backtest with the following specifications: I was able to reach a profit level of 30K, as indicated below. However, the Bot is not without faults and following the backtest, I started a forward test with real live data and the results were not so great. The EA took a
Connect from Mt5 via binary deriv account api I have mt5 indicator, need to connect with binary deriv account through api. If anyone can setup via API then contact me. everything control mt5
Hello I am looking for a developer to create an 50% retracement Indicator of the previous candle . So once a candle close the Indicator is supposed to take the full candle size from high to low and make a 61% and 50% level on that candle and I would like the candle to show until the next previous candle is done creating. After this I would look to create an ea with it possibly
Hi, I have 2 indicators which are based on the super trend , the alerts on indicator (1) does not work at all , and on the other indicator the alerts do not come on time on time, which is kind of delayed. see attached file below
Looking for an experienced developer to modify my existing TDI strategy , want to add filter for Buy and Sell Signals, Arrows are displayed on chart and what only to leave high accurate arrows Source code to be provided
I have the mq5 file, I need a buffer adding to the indicator, so it appears in the data window so I can reference it later in an EA. As the below screenshot shows, there is a median ray line from yesterday (the dashed horizontal line) - I want this value in the data window called Median Ray. I want this to be a single value per day, so todays Median Ray would be 17868, and so on each day. So I want all the Developing
I would like to develop my own indicator on metatrader 4 and tradingview. We would start with a basic version that we would improve later. It is an indicator based on several analyses and which would provide several indications. I am looking for someone who can develop on MT4 and Mt5, initially I would like to do it on mt4 and then on mt5. If you have expertise in pinescript it is a plus because I would like to
I urgently require swift assistance to convert a complex indicator into a fully functional scanner, capable of automatically sending real-time data, alerts, and notifications via email, ensuring seamless integration and prompt delivery of critical information to facilitate informed decision-making and timely action

Projektdetails

Budget
30 - 50 USD
MwSt (19%): 5.7 - 9.5 USD
Insgesamt: 35.7 - 59.5 USD
Für die Entwickler
27 - 45 USD
Ausführungsfristen
von 1 bis 5 Tag(e)