//+------------------------------------------------------------------+
//|                                         MA Triple with Price.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_style1 0
#property indicator_color2 Teal
#property indicator_width2 2
#property indicator_style2 0
#property indicator_color3 RoyalBlue
#property indicator_width3 2
#property indicator_style3 0
//---- input parameters
extern string MA1____________________="_____________________________";
extern int   MAPeriod1    = 7;
extern int   MAMode1      = 0;
extern int   MAPrice1     = 0;
extern color Price_color1 = Red;
extern string MA2____________________="_____________________________";
extern int   MAPeriod2    = 34;
extern int   MAMode2      = 0;
extern int   MAPrice2     = 0;
extern color Price_color2 = Teal;
extern string MA3____________________="_____________________________";
extern int   MAPeriod3    = 144;
extern int   MAMode3      = 0;
extern int   MAPrice3     = 0;
extern color Price_color3 = RoyalBlue;
extern string Price__________________="_____________________________";
extern int   Price_Size  = 2;
extern int   Shift_Price = 5;

int triplemagic = 0;
//---- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexDrawBegin(0,MAPeriod1);
   SetIndexBuffer(0,Buffer1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexLabel(0,"");
   
   SetIndexDrawBegin(1,MAPeriod2);
   SetIndexBuffer(1,Buffer2);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexLabel(1,"");
   
   SetIndexDrawBegin(2,MAPeriod3);
   SetIndexBuffer(2,Buffer3);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexLabel(2,"");
 
   return(0);
  }
  
  int deinit()
  {
//----
  ObjectDelete("PRICE1"+triplemagic);
  ObjectDelete("PRICE2"+triplemagic);
  ObjectDelete("PRICE3"+triplemagic);
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| 3 X EMA                                          |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop
   for(int i=0; i<limit; i++)
     {
     
      triplemagic = MAPeriod1+MAPeriod2+MAPeriod3;
    
      Buffer1[i]=iMA(NULL,0,MAPeriod1,0,MAMode1,MAPrice1,i);
      
      Buffer2[i]=iMA(NULL,0,MAPeriod2,0,MAMode2,MAPrice2,i);
      
      Buffer3[i]=iMA(NULL,0,MAPeriod3,0,MAMode3,MAPrice3,i);
       
         if (ObjectFind("PRICE1"+triplemagic) != 0){
          ObjectCreate("PRICE1"+triplemagic,OBJ_ARROW,0,customTime(-Shift_Price),Buffer1[0]);
          ObjectSet("PRICE1"+triplemagic,OBJPROP_ARROWCODE,6);
          ObjectSet("PRICE1"+triplemagic,OBJPROP_COLOR,Price_color1);  
          ObjectSet("PRICE1"+triplemagic,OBJPROP_WIDTH,Price_Size);  
           }   else {
          ObjectMove("PRICE1"+triplemagic,0,customTime(-Shift_Price),Buffer1[0]);
          ObjectSet("PRICE1"+triplemagic,OBJPROP_COLOR,Price_color1); }  
          
         if (ObjectFind("PRICE2"+triplemagic) != 0){
          ObjectCreate("PRICE2"+triplemagic,OBJ_ARROW,0,customTime(-Shift_Price),Buffer2[0]);
          ObjectSet("PRICE2"+triplemagic,OBJPROP_ARROWCODE,6);
          ObjectSet("PRICE2"+triplemagic,OBJPROP_COLOR,Price_color2);  
          ObjectSet("PRICE2"+triplemagic,OBJPROP_WIDTH,Price_Size);  
           }   else {
          ObjectMove("PRICE2"+triplemagic,0,customTime(-Shift_Price),Buffer2[0]);
          ObjectSet("PRICE2"+triplemagic,OBJPROP_COLOR,Price_color2); }  
          
         if (ObjectFind("PRICE3"+triplemagic) != 0){
          ObjectCreate("PRICE3"+triplemagic,OBJ_ARROW,0,customTime(-Shift_Price),Buffer3[0]);
          ObjectSet("PRICE3"+triplemagic,OBJPROP_ARROWCODE,6);
          ObjectSet("PRICE3"+triplemagic,OBJPROP_COLOR,Price_color3);  
          ObjectSet("PRICE3"+triplemagic,OBJPROP_WIDTH,Price_Size);  
           }   else {
          ObjectMove("PRICE3"+triplemagic,0,customTime(-Shift_Price),Buffer3[0]);
          ObjectSet("PRICE3"+triplemagic,OBJPROP_COLOR,Price_color3); }  
        }
//---- done
   return(0);
  }
  
    
  int customTime(int a)
{
if(a<0)
return(Time[0]+Period()*60*MathAbs(a));
else return(Time[a]); 
}
//+------------------------------------------------------------------+

