Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Hull_Moving_Average
//+------------------------------------------------------------------+
//| Hull_Moving_Average.mq4 |
//| Copyright © 2007 , transport_david , David W Honeywell |
//| hellonwheels.trans@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007 , transport_david , David W Honeywell"
#property link "hellonwheels.trans@gmail.com"
// The formula used can be found at http://www.linnsoft.com/tour/techind/movAvg.htm
// HMA = WMA(2*WMA(PRICE, n) - WMA(PRICE, n/2), sqrt(n))
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DeepSkyBlue
extern int HUll_Periods = 6, Applied_Price = 0, ShowBars = 10500;
double Hull[];
double Calc[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexEmptyValue(0,0.0);
SetIndexBuffer(0,Hull);
SetIndexEmptyValue(1,0.0);
SetIndexBuffer(1,Calc);
SetIndexLabel(0,"Hull_Moving_Average ( "+HUll_Periods+" )");
IndicatorShortName(" Hull_Moving_Average ( "+HUll_Periods+" )");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int shift = ShowBars;
if (ShowBars > Bars) ShowBars = Bars;
// HMA = WMA(2*WMA(PRICE, n) - WMA(PRICE, n/2), sqrt(n))
for ( shift = ShowBars; shift >= 0; shift-- )
{
double Exp = 2;
double firstwma = iMA(NULL,0,HUll_Periods,0,MODE_LWMA,Applied_Price,shift);
double secondwma = iMA(NULL,0,MathFloor(HUll_Periods/2),0,MODE_LWMA,Applied_Price,shift);
Calc[shift] = (Exp*firstwma)-secondwma;
}
for ( shift = ShowBars; shift >= 0; shift-- )
{
Hull[shift] = iMAOnArray(Calc,0,MathFloor(MathSqrt(HUll_Periods)),0,MODE_LWMA,shift);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---