//+------------------------------------------------------------------+
//|       TRO MACD DIFF                                              |
//|                                                                  |
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND CONTRIBUTIONS ACCEPTED                               | 
//|                                                                  |
//|   therumpledone@gmail.com                                        |  
//+------------------------------------------------------------------+ 

#property  copyright "Copyright © 2008, Avery T. Horton, Jr. aka TRO" 
#property  link      "http://www.therumpledone.com/" 
 
#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Lime
 

#property indicator_width1 3
 



//---- indicator parameters
 

string note1 = "----------------------";
string note2 = "Fast Moving Average";
int FastMA=6;
string note3 = "0=Simple,1=Exponential";
string note4 = "2=Smooth,3=Linear Weighted";
int FastMA_Method=1;
string note5 = "----------------------";
string note6 = "Slow Moving Average";
int SlowMA=240;
string note7 = "0=Simple,1=Exponential";
string note8 = "2=Smooth,3=Linear Weighted";
int SlowMA_Method=3;
string note9 = "----------------------";
string note10 = "Signal Moving Average";
int SignalMA=0;
string note11 = "0=Simple,1=Exponential";
string note12 = "2=Smooth,3=Linear Weighted";
int SignalMA_Method=1;

 


//---- indicator buffers
double     ind_buffer0[];
 
 
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  string FastMAname, SlowMAname, SignalMAname;
//---- 2 additional buffers are used for counting.
//   IndicatorBuffers(8);
//---- drawing settings

   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexDrawBegin(0,ind_buffer0); 
   

    SetIndexBuffer(0,ind_buffer0) ;
   
 
     
//---- name for DataWindow and indicator subwindow label

   switch(FastMA_Method)
     {
      case 1 : FastMAname="EMA";  break;
      case 2 : FastMAname="SMMA"; break;
      case 3 : FastMAname="LWMA"; break;
      default :
         FastMA_Method=0;
         FastMAname="SMA";
     }
   switch(SlowMA_Method)
     {
      case 1 : SlowMAname="EMA";  break;
      case 2 : SlowMAname="SMMA"; break;
      case 3 : SlowMAname="LWMA"; break;
      default :
         SlowMA_Method=0;
         SlowMAname="SMA";
     }
   switch(SignalMA_Method)
     {
      case 1 : SignalMAname="EMA";  break;
      case 2 : SignalMAname="SMMA"; break;
      case 3 : SignalMAname="LWMA"; break;
      default :
         SignalMAname=0;
         SignalMAname="SMA";
     }

   
         
   return(0);
  }

//+------------------------------------------------------------------+  
int deinit()
  {

   return(0);
  }  
  
//+------------------------------------------------------------------+

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;
   
//---- macd counted in the 1-st additional buffer

   for(int i=0; i<limit; i++)
   {
      ind_buffer0[i]=iMA(NULL,0,FastMA,0,FastMA_Method,PRICE_CLOSE,i)
                        -iMA(NULL,0,SlowMA,0,SlowMA_Method,PRICE_CLOSE,i);
        
   }   
   
return(0);
}

/*

extern string note1 = "----------------------";
extern string note2 = "Fast Moving Average";
extern int FastMA=6;
extern string note3 = "0=Simple,1=Exponential";
extern string note4 = "2=Smooth,3=Linear Weighted";
extern int FastMA_Method=1;
extern string note5 = "----------------------";
extern string note6 = "Slow Moving Average";
extern int SlowMA=240;
extern string note7 = "0=Simple,1=Exponential";
extern string note8 = "2=Smooth,3=Linear Weighted";
extern int SlowMA_Method=3;
extern string note9 = "----------------------";
extern string note10 = "Signal Moving Average";
extern int SignalMA=0;
extern string note11 = "0=Simple,1=Exponential";
extern string note12 = "2=Smooth,3=Linear Weighted";
extern int SignalMA_Method=1;


*/