Did you have any success with it? I think that this will be a great indicator. Anyone can help?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I try to programer a MACD HULL to see if it is interessant.
I am not strong in programming but I began.
Somebody could he(it) help me has to finish him(it)?
Thank you
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Green
#property indicator_color3 Green
//---- input parameters
extern int period=20;
extern int method=3; // MODE_SMA
extern int price=0; // PRICE_CLOSE
extern int period2=30;
extern int method2=3; // MODE_SMA
extern int price2=0; // PRICE_CLOSE
//---- buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];
double FL[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexBuffer(0, ExtMapBuffer);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(2, FL);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
IndicatorShortName("Hull Moving Average("+period+")");
return(0);
}
double WMA(int x, int p)
{
return(iMA(NULL, 0, p, 0, method, price, x));
}
double WMAd(int xd, int pd)
{
return(iMA(NULL, 0, pd, 0, method2, price2, xd));
}
//+------------------------------------------------------------------+
//| 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[];
if(e > Bars)
e = Bars;
ArrayResize(vect, e);
ArraySetAsSeries(vect, 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);
}
int xd = 0;
int pd = MathSqrt(period2);
int ed = Bars - counted_bars + period2 + 1;
double vectd[];
if(ed > Bars)
ed = Bars;
ArrayResize(vectd, ed);
ArraySetAsSeries(vectd, true);
for(xd = 0; xd < ed; xd++)
{
vectd[xd] = 2*WMAd(xd, period2/2) - WMAd(xd, period2);
}
for(xd = 0; xd < ed-period2; xd++)
{
ExtMapBuffer2[xd] = iMAOnArray(vectd, 0, pd, 0, method2, xd);
}
int limit;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
for(int i=0; i<limit; i++)
{
FL = ExtMapBuffer2-ExtMapBuffer/10000;
}
return(0);
}
//+------------------------------------------------------------------+