Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Hull_HAMA
//+------------------------------------------------------------------+
//| Hull_O_H_L_C.mq4 HA |
//| Copyright © 2007, None |
//|Hull_HAMA Planet.Earth.Redistribution |
//+------------------------------------------------------------------+
//mod 2008 fxtsd ki
#property copyright "Copyright © 2007, None"
#property link "Planet.Earth.Redistribution"
//----
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 OrangeRed
#property indicator_color2 RoyalBlue
#property indicator_color3 Red
#property indicator_color4 DodgerBlue
//---- parameters
extern int MaMethod =3; //0-3
extern int MaPeriod =14;
extern int DrawType =2; //0-2
extern int OpCl_Width= 2;
extern int ShowBars =1200;
extern string notes_ = "MaMethod: SMA0 EMA1 SMMA2 LWMA3; DrawType: 0line 1section 2Histo";
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double maOpen, maClose, maLow, maHigh;
double haOpen, haHigh, haLow, haClose;
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
//---- indicators
IndicatorBuffers(4);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,EMPTY_VALUE);
// SetIndexDrawBegin(0,MaPeriod);
SetIndexStyle(0,DrawType,STYLE_SOLID,1);
SetIndexLabel(0,"Hull_HA("+MaPeriod+")Hi ");
//
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,EMPTY_VALUE);
// SetIndexDrawBegin(1,MaPeriod);
SetIndexStyle(1,DrawType,STYLE_SOLID,1);
SetIndexLabel(1,"Hull_HA("+MaPeriod+")Lo");
//
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexEmptyValue(2,EMPTY_VALUE);
// SetIndexDrawBegin(2,MaPeriod);
SetIndexStyle(2,DrawType,STYLE_SOLID,OpCl_Width);
SetIndexLabel(2,"Hull_HA("+MaPeriod+")OpCl");
//
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexEmptyValue(3,EMPTY_VALUE);
// SetIndexDrawBegin(3,MaPeriod);
SetIndexStyle(3,DrawType,STYLE_SOLID,OpCl_Width);
SetIndexLabel(3,"Hull_HA("+MaPeriod+")ClOp");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// if(Bars<=10) return(0);
if(Bars<=MathPow(MaPeriod,2)) return(0);
int CountedBars=IndicatorCounted();
//---- check for possible errors
if (CountedBars<0) return(-1);
//---- last counted bar will be recounted
if (CountedBars>0) CountedBars--;
//int pos=Bars-ExtCountedBars-2;
int pos,limit;
//if (pos>=(Bars-ExtCountedBars-2)) pos=Bars-ExtCountedBars-2;
limit=Bars-CountedBars;
limit = MathMin(limit, ShowBars+MathPow(MaPeriod,2));
for (pos=limit;pos>=0;pos--)
{
//while(pos>=0)
maOpen =iMA(Symbol(),0,MathFloor(MaPeriod/2),0,MaMethod,PRICE_OPEN ,pos)*2-iMA(Symbol(),0,MaPeriod,0,MaMethod,PRICE_OPEN ,pos);
maClose=iMA(Symbol(),0,MathFloor(MaPeriod/2),0,MaMethod,PRICE_CLOSE,pos)*2-iMA(Symbol(),0,MaPeriod,0,MaMethod,PRICE_CLOSE,pos);
maLow =iMA(Symbol(),0,MathFloor(MaPeriod/2),0,MaMethod,PRICE_LOW ,pos)*2-iMA(Symbol(),0,MaPeriod,0,MaMethod,PRICE_LOW ,pos);
maHigh =iMA(Symbol(),0,MathFloor(MaPeriod/2),0,MaMethod,PRICE_HIGH ,pos)*2-iMA(Symbol(),0,MaPeriod,0,MaMethod,PRICE_HIGH ,pos);
//----
haHigh=MathMax(maHigh, MathMax(haOpen, haClose));
haLow=MathMin(maLow, MathMin(haOpen, haClose));
if (haOpen<haClose)
{
ExtMapBuffer1[pos]=haLow;
ExtMapBuffer2[pos]=haHigh;
}
else
{
ExtMapBuffer1[pos]=haHigh;
ExtMapBuffer2[pos]=haLow;
}
haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
ExtMapBuffer3[pos]=haOpen;
haClose=(maOpen+maHigh+maLow+maClose)/4;
ExtMapBuffer4[pos]=haClose;
// pos--;
}
//----
for (int i=0;i<indicator_buffers;i++) SetIndexDrawBegin(i,Bars-ShowBars);
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
---