OsHMA





//+------------------------------------------------------------------+
//|                                                        OsHMA.mq4 |
//|                           Copyright © 2009, Meta Quotes & sealdo |
//|                                         sealdo@yandex.ru         |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2009, Meta Quotes & sealdo"
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
//#property  indicator_chart_window
#property  indicator_buffers 1
#property  indicator_color1  DarkOrchid
#property  indicator_width1  2
//---- indicator parameters
extern int FastHMA = 12; 
extern int SlowHMA = 26; 
//---- indicator buffers
double	OsmaBuffer[];
double	PreHMA1[]; 
double	PreHMA2[]; 

//+------------------------------------------------------------------+
int pF, pS; 

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 4 additional buffers are used for counting.
   IndicatorBuffers(3);
   
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   //SetIndexDrawBegin(0,SignalSMA);
   IndicatorDigits(Digits+2);
   
//---- 5 indicator buffers mapping
   SetIndexBuffer(0,OsmaBuffer);
   SetIndexBuffer(1,PreHMA1);
   SetIndexBuffer(2,PreHMA2);
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("OsHMA("+FastHMA+","+SlowHMA+")");
   
	pF = MathSqrt(FastHMA); 
	pS = MathSqrt(SlowHMA); 
	
//---- initialization done
   return(0);
  }

  
//+------------------------------------------------------------------+
double WMA(int x, int p) { 
	return(iMA(NULL, 0, p, 0, MODE_LWMA, PRICE_CLOSE, x)); 
} 


//+------------------------------------------------------------------+
//| Moving Average of Oscillator                                     |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
//---- preparing the HMA
   for(int i=0; i<limit; i++) {
   	PreHMA1[i] = 2*WMA(i, FastHMA/2) - WMA(i, FastHMA); 
   	PreHMA2[i] = 2*WMA(i, SlowHMA/2) - WMA(i, SlowHMA); 
   }

//---- macd counted in the 1-st additional buffer
   for(i=0; i<limit; i++)
   	OsmaBuffer[i]= iMAOnArray(PreHMA1, 0, pF, 0, MODE_LWMA, i) - iMAOnArray(PreHMA2, 0, pS, 0, MODE_LWMA, i);
      
//---- done
   return(0);
  }
//+------------------------------------------------------------------+





Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_HISTOGRAM


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: