Navigation:Home > Content >

HLO_DIF.mq4

Time: 2015-05-21 | Download file:HLO_DIF.mq4

//+------------------------------------------------------------------+
//|                                                      HLO_DIF.mq4 |
//|                                                          Kalenzo |
//|                                      [email protected] |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "[email protected]"

#property indicator_color1 Magenta
#property indicator_color2 Maroon
#property indicator_color3 Lime
#property indicator_color4 Green

#property indicator_buffers 4
#property indicator_separate_window

double ma1[],ma2[],buff1[],buff2[];
extern int limit = 1500,
           ema1period = 13,
           ema2period = 13,
           ema1mode = MODE_EMA,
           ema2mode = MODE_EMA,
           level1 = 25,
           level2 = 20,
           level3 = 15;
           
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
SetIndexBuffer(0,ma1);
SetIndexBuffer(1,buff1);
SetIndexBuffer(2,ma2);
SetIndexBuffer(3,buff2);

SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);



//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
SetLevelStyle(STYLE_DOT,0,DodgerBlue);
SetLevelValue(0,level1*Point);
SetLevelValue(1,level2*Point);
SetLevelValue(2,level3*Point);
//----
for(int i =limit;i>=0;i--)
{
   double v1 = High[i]-Open[i]; 
   double v2 = Open[i]-Low[i];
   
   if(v1>v2)
   {
      buff1[i] = v1;
      buff2[i] = 0;
   }
   else
   {
      buff1[i] = 0;
      buff2[i] = v2;
   }
   
}  

 for(i=limit;i>=0;i--)ma1[i] = iMAOnArray(buff1,0,ema1period,0,ema1mode,i);
 for(i=limit;i>=0;i--)ma2[i] = iMAOnArray(buff2,0,ema2period,0,ema2mode,i); 
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend