//+------------------------------------------------------------------+
//|                                                 MA 1H dan 2H.mq4 |
//|                                               Created by Marsya7 |
//|                                          http://kgforexworld.com/|
//+------------------------------------------------------------------+

#property copyright "Created by Marsya7"
#property link      "http://kgforexworld.com/"

#property indicator_chart_window
#property indicator_buffers 2

extern color MA_1H_Color=Red;
extern color MA_2H_Color=DeepSkyBlue;
extern int width = 1;
extern int applied_price=6;
extern int ma_method=0;
extern string ket.applied_price="0=Close,1=Open,2=High,3=Low,4=Median,5=Typical,6=Weighted";
extern string ket.ma_method="0=SMA,1=EMA,2=SMMA,3=LWMA";
//---- buffers
double MA1H[];
double MA2H[];
int    Per1H;
int    Per2H;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,0,width,MA_1H_Color);
   SetIndexBuffer(0,MA1H);
   SetIndexLabel(0,"MA 1H");
   SetIndexStyle(1,DRAW_LINE,0,width,MA_2H_Color);
   SetIndexBuffer(1,MA2H);
   SetIndexLabel(1,"MA 2H");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
     
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int ActivePer=Period();
   Per2H=120/ActivePer;
   Per1H=60/ActivePer;
   
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++;
   for(int i=0; i<limit; i++)
   {  
    MA2H[i]=iMA(NULL,0,Per2H,0,ma_method,applied_price,i);
      MA1H[i]=iMA(NULL,0,Per1H,0,ma_method,applied_price,i);
   }
 
//----
   return(0);
  }
//+------------------------------------------------------------------+