/*
*********************************************************************
                        Rainbow EMA 2-89
                   Copyright © 2006  BlueDream
                   Purpose : Price action on EMA89
*********************************************************************
*/


#property copyright "By BlueDream"

#property indicator_separate_window
#property indicator_buffers 3

#property indicator_color1 Red
#property indicator_color2 RoyalBlue
#property indicator_color3 White

extern int EMA_Slow = 20;
extern int EMA_Fast = 5;
//extern int EMA_3 = 1;
extern int Rainbow_Width = 2;


//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   IndicatorShortName("BDEMA");

//---- indicators
   SetIndexStyle(0,DRAW_LINE,EMPTY,Rainbow_Width);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,EMPTY,Rainbow_Width);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE,EMPTY,Rainbow_Width);
   SetIndexBuffer(2,ExtMapBuffer3);
   


//----
   return(0);
  }

int deinit()
  {
 //::::::::::::::::::::::::::::::::::::::::::::::check this::::::::::::::::::::::::::::::::  
  ObjectDelete("txtMyEMAPrice1");
  ObjectDelete("txtMyEMAPrice2");
  ObjectDelete("txtMyEMAPrice3");
   return(0);
  }
//:::::::::::::::::::::::::::::::::::::::::::::::check this::::::::::::::::::::::::::::: 
int start()
  {
   int i,limit,counted_bars=IndicatorCounted();
   string strEMAPrice1, strEMAPrice2, strEMAPrice3;   
   color ColorText1, ColorText2, ColorText3;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   
 //::::::::::::::::::::::::::::::::::::::::::::check this:::::::::::::::::::::::::::::::::: 
  
   ObjectCreate("txtMyEMAPrice1", OBJ_LABEL, WindowFind("BDEMA"), 0, 0);
   ObjectSet("txtMyEMAPrice1", OBJPROP_CORNER,1);
   ObjectSet("txtMyEMAPrice1", OBJPROP_XDISTANCE, 145);
   ObjectSet("txtMyEMAPrice1", OBJPROP_YDISTANCE, 5);

   ObjectCreate("txtMyEMAPrice2", OBJ_LABEL, WindowFind("BDEMA"), 0, 0);
   ObjectSet("txtMyEMAPrice2", OBJPROP_CORNER,1);
   ObjectSet("txtMyEMAPrice2", OBJPROP_XDISTANCE, 75);
   ObjectSet("txtMyEMAPrice2", OBJPROP_YDISTANCE, 5);

   ObjectCreate("txtMyEMAPrice3", OBJ_LABEL, WindowFind("BDEMA"), 0, 0);
   ObjectSet("txtMyEMAPrice3", OBJPROP_CORNER,1);
   ObjectSet("txtMyEMAPrice3", OBJPROP_XDISTANCE, 5);
   ObjectSet("txtMyEMAPrice3", OBJPROP_YDISTANCE, 5);
   
   
 //:::::::::::::::::::::::::::::::::::::::::::::end check::::::::::::::::::::::::::::::    
   
   
   
   limit=Bars-counted_bars;
   
   for(i=0; i<limit; i++){
//      ExtMapBuffer1[i]=iMA(NULL,0,EMA_1,0,MODE_EMA,PRICE_CLOSE,i);
//      ExtMapBuffer2[i]=iMA(NULL,0,EMA_2,0,MODE_EMA,PRICE_CLOSE,i);
//      ExtMapBuffer3[i]=iMA(NULL,0,EMA_3,0,MODE_EMA,PRICE_CLOSE,i);
      ExtMapBuffer1[i]=iMA(NULL,0,EMA_Slow,0,MODE_EMA,PRICE_CLOSE,i);
      ExtMapBuffer2[i]=iMA(NULL,0,EMA_Fast,0,MODE_EMA,PRICE_CLOSE,i);
      ExtMapBuffer3[i]=iMA(NULL,0,1,0,MODE_EMA,PRICE_CLOSE,i);
      
      if (ExtMapBuffer3[i]>ExtMapBuffer2[i]){strEMAPrice1="L1 : UP"; ColorText1=RoyalBlue;} 
      if (ExtMapBuffer3[i]<ExtMapBuffer2[i]){strEMAPrice1="L1 : DN"; ColorText1=Red;}       
      ObjectSetText("txtMyEMAPrice1",strEMAPrice1, 10, "Arial Bold", ColorText1);

      if (ExtMapBuffer3[i]>ExtMapBuffer1[i]){strEMAPrice2="L2 : UP"; ColorText2=RoyalBlue;} 
      if (ExtMapBuffer3[i]<ExtMapBuffer1[i]){strEMAPrice2="L2 : DN"; ColorText2=Red;}       
      ObjectSetText("txtMyEMAPrice2",strEMAPrice2, 10, "Arial Bold", ColorText2);

      if (ExtMapBuffer2[i]>ExtMapBuffer1[i]){strEMAPrice3="L3 : UP"; ColorText3=RoyalBlue;} 
      if (ExtMapBuffer2[i]<ExtMapBuffer1[i]){strEMAPrice3="L3 : DN"; ColorText3=Red;}       
      ObjectSetText("txtMyEMAPrice3",strEMAPrice3, 10, "Arial Bold", ColorText3);

   }


   
   
   
   
   
   
   return(0);
  }
//+------------------------------------------------------------------+