Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 520

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 535

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 542

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 578

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/forex/public_html/wp-settings.php on line 18
H :forex decode

H Archives

Hull-MA.mq4

//+------------------------------------------------------------------+
//|                                                          HMA.mq4 |
//|                      Copyright ? 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright ? 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 1
#property  indicator_color1  Yellow

//---- indicator parameters
extern int HMA_Period=4;
extern int MAshift=0;
//---- indicator buffers
double     ind_buffer0[];
double     ind_buffer1[];

int        draw_begin0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   IndicatorBuffers(2);
   if(!SetIndexBuffer(0,ind_buffer0) && !SetIndexBuffer(1,ind_buffer1))
      Print("cannot set indicator buffers!");
//   ArraySetAsSeries(ind_buffer1,true);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   draw_begin0=HMA_Period+MathFloor(MathSqrt(HMA_Period));
   SetIndexDrawBegin(0,draw_begin0);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("HMA("+HMA_Period+")");
   SetIndexLabel(0,"Hull Moving Average");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<1)
     {
      for(i=1;i<=draw_begin0;i++) ind_buffer0[Bars-i]=0;
      for(i=1;i<=HMA_Period;i++) ind_buffer1[Bars-i]=0;
     }
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- MA difference counted in the 1-st buffer
   for(i=0; i<limit; i++)
      ind_buffer1[i]=iMA(NULL,0,MathFloor(HMA_Period/2),MAshift,MODE_LWMA,PRICE_OPEN,i)*2-
                     iMA(NULL,0,HMA_Period,MAshift,MODE_LWMA,PRICE_OPEN,i);
//---- HMA counted in the 0-th buffer
   for(i=0; i<limit; i++)
      ind_buffer0[i]=iMAOnArray(ind_buffer1,0,MathFloor(MathSqrt(HMA_Period)),0,MODE_LWMA,i);
//---- done
   return(0);
  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Hull Trend1.mq4

//+------------------------------------------------------------------+
//|                                                   Hull Trend.mq4 |
//|                                     Copyright ? 2005, adoleh2000 |
//|                                             adoleh2000@yahoo.com |
//+------------------------------------------------------------------+
#property  copyright "Copyright ? 2005, adoleh2000."
#property  link      "adoleh2000@yahoo.com"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 4
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  EMPTY
#property  indicator_color4  EMPTY

//---- indicator parameters
extern int HMA_Period=20;
extern double Price=PRICE_OPEN;
extern double Displacement=0;
//---- indicator buffers
double ind_buffer0[];
double ind_buffer1[];
double HighBuffer[];
double LowBuffer[];

int        draw_begin0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   //IndicatorBuffers(4);
//   ArraySetAsSeries(ind_buffer1,true);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);

   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);
   SetIndexBuffer(2,ind_buffer0);
   SetIndexBuffer(3,ind_buffer1);

   draw_begin0=HMA_Period+MathFloor(MathSqrt(HMA_Period));

   SetIndexDrawBegin(0,draw_begin0);
   SetIndexDrawBegin(1,draw_begin0);
   SetIndexDrawBegin(2,draw_begin0);
   SetIndexDrawBegin(3,draw_begin0);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("HMA("+HMA_Period+")");
   SetIndexLabel(0,"Hull Moving Average");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i,shift;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<1)
     {
      for(i=1;i<=draw_begin0;i++) ind_buffer0[Bars-i]=0;
      for(i=1;i<=HMA_Period;i++) ind_buffer1[Bars-i]=0;
     }
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- MA difference counted in the 1-st buffer
   for(i=0; i<limit; i++)
      ind_buffer1[i]=iMA(NULL,0,MathFloor(HMA_Period/2),0,MODE_LWMA,Price,i)*2-iMA(NULL,0,HMA_Period,0,MODE_LWMA,Price,i);
//---- HMA counted in the 0-th buffer
   for(i=0; i<limit; i++)
      ind_buffer0[i]=iMAOnArray(ind_buffer1,0,MathFloor(MathSqrt(HMA_Period)),0,MODE_LWMA,i+Displacement);

      //Comment ("MA=",ind_buffer1[i],"; ","HMA=",ind_buffer0[i]);

for (shift=i; shift>=0;shift--)
{
      if (ind_buffer1[shift] > ind_buffer0[shift])
   {
      HighBuffer[shift]=High[shift];
      LowBuffer[shift]=Low[shift];
   }

   else

if (ind_buffer1[shift]<  ind_buffer0[shift])
   {
      LowBuffer[shift]=High[shift];
      HighBuffer[shift]=Low[shift];
    }
}
//---- done
   return(0);
  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Hull Trend.mq4

//+------------------------------------------------------------------+
//|                                                   Hull Trend.mq4 |
//|                                     Copyright ? 2005, adoleh2000 |
//|                                             adoleh2000@yahoo.com |
//+------------------------------------------------------------------+
#property  copyright "Copyright ? 2005, adoleh2000."
#property  link      "adoleh2000@yahoo.com"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 4
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  EMPTY
#property  indicator_color4  EMPTY

//---- indicator parameters
extern int HMA_Period=20;
extern double Price=PRICE_CLOSE;
extern double Displacement=0;
//---- indicator buffers
double ind_buffer0[];
double ind_buffer1[];
double HighBuffer[];
double LowBuffer[];

int        draw_begin0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   //IndicatorBuffers(4);
//   ArraySetAsSeries(ind_buffer1,true);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);

   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);
   SetIndexBuffer(2,ind_buffer0);
   SetIndexBuffer(3,ind_buffer1);

   draw_begin0=HMA_Period+MathFloor(MathSqrt(HMA_Period));

   SetIndexDrawBegin(0,draw_begin0);
   SetIndexDrawBegin(1,draw_begin0);
   SetIndexDrawBegin(2,draw_begin0);
   SetIndexDrawBegin(3,draw_begin0);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("HMA("+HMA_Period+")");
   SetIndexLabel(0,"Hull Moving Average");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i,shift;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<1)
     {
      for(i=1;i<=draw_begin0;i++) ind_buffer0[Bars-i]=0;
      for(i=1;i<=HMA_Period;i++) ind_buffer1[Bars-i]=0;
     }
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- MA difference counted in the 1-st buffer
   for(i=0; i<limit; i++)
      ind_buffer1[i]=iMA(NULL,0,MathFloor(HMA_Period/2),0,MODE_LWMA,Price,i)*2-iMA(NULL,0,HMA_Period,0,MODE_LWMA,Price,i);
//---- HMA counted in the 0-th buffer
   for(i=0; i<limit; i++)
      ind_buffer0[i]=iMAOnArray(ind_buffer1,0,MathFloor(MathSqrt(HMA_Period)),0,MODE_LWMA,i+Displacement);

      //Comment ("MA=",ind_buffer1[i],"; ","HMA=",ind_buffer0[i]);

for (shift=i; shift>=0;shift--)
{
      if (ind_buffer1[shift] > ind_buffer0[shift])
   {
      HighBuffer[shift]=High[shift];
      LowBuffer[shift]=Low[shift];
   }

   else

if (ind_buffer1[shift]<  ind_buffer0[shift])
   {
      LowBuffer[shift]=High[shift];
      HighBuffer[shift]=Low[shift];
    }
}
//---- done
   return(0);
  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

HMAlower.mq4

//+------------------------------------------------------------------+
//|                                                          HMA.mq4 |
//|                      Copyright ? 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright ? 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 1
#property  indicator_color1  Blue

//---- indicator parameters
extern int HMA_Period=20;
//---- indicator buffers
double     ind_buffer0[];
double     ind_buffer1[];

int        draw_begin0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   IndicatorBuffers(2);
   if(!SetIndexBuffer(0,ind_buffer0) && !SetIndexBuffer(1,ind_buffer1))
      Print("cannot set indicator buffers!");
//   ArraySetAsSeries(ind_buffer1,true);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
   draw_begin0=HMA_Period+MathFloor(MathSqrt(HMA_Period));
   SetIndexDrawBegin(0,draw_begin0);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("HMA("+HMA_Period+")");
   SetIndexLabel(0,"Hull Moving Average");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<1)
     {
      for(i=1;i<=draw_begin0;i++) ind_buffer0[Bars-i]=0;
      for(i=1;i<=HMA_Period;i++) ind_buffer1[Bars-i]=0;
     }
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- MA difference counted in the 1-st buffer
   for(i=0; i<limit; i++)
      ind_buffer1[i]=iMA(NULL,0,MathFloor(HMA_Period/2),0,MODE_LWMA,PRICE_OPEN,i)*2-
                     iMA(NULL,0,HMA_Period,0,MODE_LWMA,PRICE_OPEN,i)-Point*40;
//---- HMA counted in the 0-th buffer
   for(i=0; i<limit; i++)
      ind_buffer0[i]=iMAOnArray(ind_buffer1,0,MathFloor(MathSqrt(HMA_Period)),0,MODE_LWMA,i);
//---- done
   return(0);
  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

HMAhigher.mq4

//+------------------------------------------------------------------+
//|                                                          HMA.mq4 |
//|                      Copyright ? 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright ? 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 1
#property  indicator_color1  Blue

//---- indicator parameters
extern int HMA_Period=20;
//---- indicator buffers
double     ind_buffer0[];
double     ind_buffer1[];

int        draw_begin0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   IndicatorBuffers(2);
   if(!SetIndexBuffer(0,ind_buffer0) && !SetIndexBuffer(1,ind_buffer1))
      Print("cannot set indicator buffers!");
//   ArraySetAsSeries(ind_buffer1,true);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
   draw_begin0=HMA_Period+MathFloor(MathSqrt(HMA_Period));
   SetIndexDrawBegin(0,draw_begin0);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("HMA("+HMA_Period+")");
   SetIndexLabel(0,"Hull Moving Average");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<1)
     {
      for(i=1;i<=draw_begin0;i++) ind_buffer0[Bars-i]=0;
      for(i=1;i<=HMA_Period;i++) ind_buffer1[Bars-i]=0;
     }
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- MA difference counted in the 1-st buffer
   for(i=0; i<limit; i++)
      ind_buffer1[i]=iMA(NULL,0,MathFloor(HMA_Period/2),0,MODE_LWMA,PRICE_OPEN,i)*2-
                     iMA(NULL,0,HMA_Period,0,MODE_LWMA,PRICE_OPEN,i)+Point*40;
//---- HMA counted in the 0-th buffer
   for(i=0; i<limit; i++)
      ind_buffer0[i]=iMAOnArray(ind_buffer1,0,MathFloor(MathSqrt(HMA_Period)),0,MODE_LWMA,i);
//---- done
   return(0);
  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

HMAenv.mq4

//+------------------------------------------------------------------+
//|                                                 HMA envelope.mq4 |
//|                                  Nick Bilak, beluck[AT]gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2006, Nick Bilak"
#property link      "http://www.mql4.info"

#property indicator_chart_window
#property indicator_buffers 2

#property indicator_color1 Red
#property indicator_color2 Red

//---- External parameters
extern int _maPeriod=20;
extern double deviation = 0.1;
extern int price1 = PRICE_OPEN;
int price1shift = 0;
int price2shift = 0;
extern int price2 = PRICE_OPEN;
/*
PRICE_CLOSE 0 Close price.
PRICE_OPEN 1 Open price.
PRICE_HIGH 2 High price.
PRICE_LOW 3 Low price.
PRICE_MEDIAN 4 Median price, (high+low)/2.
PRICE_TYPICAL 5 Typical price, (high+low+close)/3.
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.
*/

//---- indicator buffers
double _hma[],_wma[],hma[],wma[],b1[],b2[];

//----
int ExtCountedBars=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
   if (price1!=PRICE_OPEN) price1shift = 1;
   if (price2!=PRICE_OPEN) price2shift = 1;

	int    draw_begin;
	string short_name;
	IndicatorBuffers(6);

	//---- indicator buffers mapping
	SetIndexBuffer(0, b1);
	SetIndexStyle(0, DRAW_LINE);
	SetIndexEmptyValue(0, 0.0);
	SetIndexBuffer(1, b2);
	SetIndexStyle(1, DRAW_LINE);
	SetIndexEmptyValue(1, 0.0);
	SetIndexBuffer(2, _hma);
	SetIndexEmptyValue(2, 0.0);
	SetIndexBuffer(3, _wma);
	SetIndexEmptyValue(3, 0.0);
	SetIndexBuffer(4, hma);
	SetIndexEmptyValue(4, 0.0);
	SetIndexBuffer(5, wma);
	SetIndexEmptyValue(5, 0.0);

	IndicatorDigits(Digits);

	//---- initialization done
	return(0);
}

int start() {
	int i, shift, countedBars=IndicatorCounted();
	int maxBars=_maPeriod*2;
	int period=_maPeriod;
	double sqrtPeriod = MathSqrt(period*1.00);
	int halfPeriod=period/2;

	if(Bars<_maPeriod) return(-1);
   if(countedBars == 0) countedBars = maxBars;
	int limit=Bars-countedBars+maxBars;
	//---- moving average
	double wma1,_wma1;
	double wma2,_wma2;
	for(i=limit; i>=0; i--) {
	  _wma1 = iMA(Symbol(), 0, period, 0, MODE_LWMA, price1, i+price1shift);
	  _wma2 = iMA(Symbol(), 0, halfPeriod, 0, MODE_LWMA, price1, i+price1shift);
	  _wma[i] = 2.0*_wma2-_wma1;
	  wma1 = iMA(Symbol(), 0, period, 0, MODE_LWMA, price2, i+price2shift);
	  wma2 = iMA(Symbol(), 0, halfPeriod, 0, MODE_LWMA, price2, i+price2shift);
	  wma[i] = 2.0*wma2-wma1;
	}

	for(i=limit; i>=0; i--) {
	  _hma[i]=iMAOnArray(_wma, 0, sqrtPeriod, 0, MODE_LWMA, i);
	  hma[i]=iMAOnArray(wma, 0, sqrtPeriod, 0, MODE_LWMA, i);
	  b1[i]=_hma[i]+_hma[i]*deviation/100.0;
	  b2[i]=hma[i]-hma[i]*deviation/100.0;
	}

	return(0);
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

HMAb.mq4

/*+------------------------------------------------------------------+
 | FileName: i_Hull_MA.mq4
 | Description: This indicator calculates the Hull Moving Average
 |
 | Original equation is:
 | ---------------------
 | waverage(2*waverage(close,period/2)-waverage(close,period), SquareRoot(Period)
	 Implementation below is more efficient with lengthy Weighted Moving Averages.
	 In addition, the length needs to be converted to an integer value after it is halved and
	 its square root is obtained in order for this to work with Weighted Moving Averaging

 | Version: 000 20050903 17:06 GMT
 +------------------------------------------------------------------------------------------+*/
#property link      "http://www.justdata.com.au/Journals/AlanHull/hull_ma.htm"

#property indicator_chart_window
#property indicator_buffers 1

#property indicator_color1 Silver

//---- External parameters
extern int _maPeriod=120;

//---- indicator buffers
double _hma[];
double _wma[];

//----
int ExtCountedBars=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
	int    draw_begin;
	string short_name;
	IndicatorBuffers(2);

	//---- indicator buffers mapping
	SetIndexBuffer(0, _hma);
	SetIndexEmptyValue(0, 0.0);
	SetIndexStyle(0, DRAW_LINE);

	SetIndexBuffer(1, _wma);
	SetIndexEmptyValue(1, 0.0);

	IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));

	//---- initialization done
	return(0);
}

//+------------------------------------------------------------------+
//| CalculateIndicators                                                                 |
//+------------------------------------------------------------------+
void calculateIndicators(int i) {
	int period=_maPeriod;
	double sqrtPeriod = MathSqrt(period*1.00);
	int halfPeriod=period/2;

	double wma1 = iMA(Symbol(), 0, period, 0, MODE_LWMA, PRICE_CLOSE, i);
	double wma2 = iMA(Symbol(), 0, halfPeriod, 0, MODE_LWMA, PRICE_CLOSE, i);
	_wma[i] = 2*wma2-wma1;

}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start() {
	int i, shift, countedBars=IndicatorCounted();
	int maxBars=_maPeriod*2;

	if(Bars<_maPeriod) return(-1);
  if(countedBars == 0) countedBars = maxBars;
	int limit=Bars-countedBars+maxBars;

	//---- moving average
	for(i=limit; i>=0; i--) {
		calculateIndicators(i);
	}

	for(i=limit; i>=0; i--) {
	_hma[i]=iMAOnArray(_wma, 0, sqrtPeriod, 0, MODE_LWMA, i);
	}

	return(0);
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

HMA_v07.mq4

//-----------------------
// HMA modified by Ron
//-----------------------

#property link      "http://www.justdata.com.au/Journals/AlanHull/hull_ma.htm"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red

//---- External parameters
extern int _maPeriod=14;

//---- indicator buffers
double _hmaW[];
double _hmaR[];
double _wma[];

int init()
  {
   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 158 little dot
   // 168 open square
   // 120 box with X

	//---- indicator buffers memory
	IndicatorBuffers(3);

	//---- indicator buffers mapping
	SetIndexBuffer(0, _hmaW);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID,2);
   //SetIndexArrow(0,159);

	SetIndexBuffer(1, _hmaR);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID,2);
   //SetIndexArrow(1,159);

	SetIndexBuffer(2, _wma);
  }

int deinit()
  {
  }

int start()
  {
   int pos;

	int fullPeriod =                    _maPeriod;
	int halfPeriod =                    _maPeriod/2;
	int sqrtPeriod = MathFloor(MathSqrt(_maPeriod*1.00));

   double fullMA;
   double halfMA;

   double pastMA;
   double prevMA;
   double currMA;

   /*
   MetaStock Formula
   period:=Input("Period",1,200,20) ;
   sqrtperiod:=Input("Square Root of Period",1,20,4);
   Mov(2*(Mov(C,period/2,W))-Mov(C,period,W),sqrtperiod,W);

   SuperCharts Formula
   Input: period (Default value 20)
   waverage(2*waverage(close,period/2)-waverage(close,period), SquareRoot(Period))
   */

   for(pos=200; pos>=0; pos--)
     {
      fullMA=iMA(Symbol(), 0, fullPeriod, 0, MODE_LWMA, PRICE_OPEN, pos);
      halfMA=iMA(Symbol(), 0, halfPeriod, 0, MODE_LWMA, PRICE_OPEN, pos);
      _wma[pos]=(2*halfMA)-fullMA;
     }
   for(pos=200; pos>=0; pos--)
     {
      prevMA=iMAOnArray(_wma,0,sqrtPeriod,0,MODE_LWMA,pos+2);
      prevMA=iMAOnArray(_wma,0,sqrtPeriod,0,MODE_LWMA,pos+1);
      currMA=iMAOnArray(_wma,0,sqrtPeriod,0,MODE_LWMA,pos);
      if(prevMA<currMA)
        {
         _hmaW[pos]=currMA;
        }
       else
        {
         _hmaR[pos]=currMA;
        }

      if(pastMA>prevMA<currMA)
        {
         _hmaR[pos+1]=prevMA;
        }
      if(pastMA<prevMA>currMA)
        {
         _hmaW[pos+1]=prevMA;
        }

     }

  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

HMA_v06.mq4

//-----------------------
// HMA modified by Ron
//-----------------------

#property link      "http://www.justdata.com.au/Journals/AlanHull/hull_ma.htm"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red

//---- External parameters
extern int _maPeriod=14;

//---- indicator buffers
double _hmaW[];
double _hmaR[];
double _wma[];

int init()
  {
   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 158 little dot
   // 168 open square
   // 120 box with X

	//---- indicator buffers memory
	IndicatorBuffers(3);

	//---- indicator buffers mapping
	SetIndexBuffer(0, _hmaW);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0,159);

	SetIndexBuffer(1, _hmaR);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1,159);

	SetIndexBuffer(2, _wma);
  }

int deinit()
  {
  }

int start()
  {
   int pos;

	int fullPeriod = _maPeriod;
	int halfPeriod = _maPeriod/2;
	int sqrtPeriod = MathFloor(MathSqrt(fullPeriod*1.00));

   double fullMA;
   double halfMA;
   double sqrtMA0;
   double sqrtMA1;

   /*
   MetaStock Formula
   period:=Input("Period",1,200,20) ;
   sqrtperiod:=Input("Square Root of Period",1,20,4);
   Mov(2*(Mov(C,period/2,W))-Mov(C,period,W),sqrtperiod,W);

   SuperCharts Formula
   Input: period (Default value 20)
   waverage(2*waverage(close,period/2)-waverage(close,period), SquareRoot(Period))
   */

   for(pos=fullPeriod; pos>=0; pos--)
     {
      fullMA=iMA(Symbol(), 0, fullPeriod, 0, MODE_LWMA, PRICE_OPEN, pos);
      halfMA=iMA(Symbol(), 0, halfPeriod, 0, MODE_LWMA, PRICE_OPEN, pos);
      _wma[pos]=(2*halfMA)-fullMA;
     }

      sqrtMA0=iMAOnArray(_wma,0,sqrtPeriod,0,MODE_LWMA,0);
      sqrtMA1=iMAOnArray(_wma,0,sqrtPeriod,0,MODE_LWMA,1);

      // the = state is neglected
      if(sqrtMA1 >  sqrtMA0) _hmaR[0]=Low[0];
      if(sqrtMA1 <  sqrtMA0) _hmaW[0]=High[0];

  }

/*  Testing...

      // weighted MA
      _hma[pos]=((_wma[pos]*4)+(_wma[pos+1]*3)+(_wma[pos+2]*2)+(_wma[pos+3]*1))/10;

      // simple MA
      _hma[pos]=_wma[pos]+_wma[pos+1]+_wma[pos+2]+_wma[pos+3])/4;

      // lwma
      for(i=1;i<=MA_Period;i++,pos--)
        {
         price=Volume[pos];
         sum+=price*i;
         lsum+=price;
         weight+=i;
        }

      Linear Weighted Moving Average (LWMA)
      In the case of weighted moving average, the latest data is of
      more value than more early data. Weighted moving average is
      calculated by multiplying each one of the closing prices within
      the considered series, by a certain weight coefficient.

      LWMA = SUM(Close(i)*i, N)/SUM(i, N)
      Where:
      SUM(i, N) ? is the total sum of weight coefficients.

      // lwma
      k=pos;
      for(i=1;i<=period;i++,k--)
        {
         price=_wma[k];
         sum+=price*i;
         lsum+=price;
         weight+=i;
        }

//+------------------------------------------------------------------+
//| Linear Weighted Moving Average                                   |
//+------------------------------------------------------------------+
void lwma()
  {
   double sum=0.0,lsum=0.0;
   double price;
   int    i,weight=0,pos=Bars-ExtCountedBars-1;

//---- initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<=MA_Period;i++,pos--)
     {
      price=Volume[pos];
      sum+=price*i;
      lsum+=price;
      weight+=i;
     }
//---- main calculation loop
   pos++;
   i=pos+MA_Period;
   while(pos>=0)
     {
      VolBuffer3[pos]=sum/weight;
      if(pos==0) break;
      pos--;
      i--;
      price=Volume[pos];
      sum=sum-lsum+price*MA_Period;
      lsum-=Volume[i];
      lsum+=price;
     }
//---- zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++) VolBuffer3[Bars-i]=0;
  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

HMA_v05.mq4

//-----------------------
// HMA modified by Ron
//-----------------------

#property link      "http://www.justdata.com.au/Journals/AlanHull/hull_ma.htm"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

//---- External parameters
extern int _maPeriod=14;
extern int BarsToDraw=200;

//---- indicator buffers
double _hmaG[];
double _hmaR[];
double _wma[];

int init()
  {

   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 158 little dot
   // 168 open square
   // 120 box with X

	//---- indicator buffers memory
	IndicatorBuffers(3);

	//---- indicator buffers mapping
	SetIndexBuffer(0, _hmaG);
   SetIndexEmptyValue(0, 0.0);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0,233);

	SetIndexBuffer(1, _hmaR);
   SetIndexEmptyValue(1, 0.0);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1,234);

	SetIndexBuffer(2, _wma);
  }

int deinit()
  {
  }

int start()
  {
   int pos;

	int     period = _maPeriod;
	int halfPeriod = _maPeriod/2;
	int sqrtPeriod = MathFloor(MathSqrt(period*1.00));

   double halfMA;
   double fullMA;

   double GorR;
   double prevGorR;

   /*
   MetaStock Formula
   period:=Input("Period",1,200,20) ;
   sqrtperiod:=Input("Square Root of Period",1,20,4);
   Mov(2*(Mov(C,period/2,W))-Mov(C,period,W),sqrtperiod,W);

   SuperCharts Formula
   Input: period (Default value 20)
   waverage(2*waverage(close,period/2)-waverage(close,period), SquareRoot(Period))
   */

   for(pos=BarsToDraw; pos>=0; pos--)
     {
      fullMA=iMA(Symbol(), 0,     period, 0, MODE_LWMA, PRICE_CLOSE, pos);
      halfMA=iMA(Symbol(), 0, halfPeriod, 0, MODE_LWMA, PRICE_CLOSE, pos);
      _wma[pos]=(2*halfMA)-fullMA;
     }

   prevGorR=iMAOnArray(_wma,0,sqrtPeriod,0,MODE_LWMA,1);
   GorR=iMAOnArray(_wma,0,sqrtPeriod,0,MODE_LWMA,0);

   if (prevGorR<GorR)
     {
      Print("UP_ARROW ",prevGorR," ",GorR);
      _hmaG[pos]=GorR;
      _hmaR[pos]=EMPTY_VALUE;
     }
    else
     {
      Print("DN_ARROW ",prevGorR," ",GorR);
      _hmaG[pos]=EMPTY_VALUE;
      _hmaR[pos]=GorR;
     }

  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

 Page 1 of 5  1  2  3  4  5 »

Tweet This Post links powered by Tweet This v1.3.9, a WordPress plugin for Twitter.