//+------------------------------------------------------------------+ 
//|    _TRO_FILL_IN_MA                                               | 
//|                                                                  | 
//|   Avery T. Horton, Jr. aka TheRumpledOne                         |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|                                                                  |
//|   therumpledone@gmail.com                                        |  
//+------------------------------------------------------------------+ 


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

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1  Green
#property indicator_color2  Maroon
#property indicator_color3  Lime
#property indicator_color4  Red
#property indicator_width1  5
#property indicator_width2  5
#property indicator_width3  2
#property indicator_width4  2


extern string note1 = "----------------------";
extern string note2 = "Fast Moving Average";
extern int FastMA=20;
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=50;
extern string note7 = "0=Simple,1=Exponential";
extern string note8 = "2=Smooth,3=Linear Weighted";
extern int SlowMA_Method=3;

extern int myChartPeriod    = 0 ;

extern color zoneColor      = DarkGray;

string  tChartPeriod ;  


string indNames = "DailyData";
double     ind_Buffer0[];
double     ind_Buffer1[];
double     ind_Buffer2[];
double     ind_Buffer3[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
{

   if(myChartPeriod == 0) { myChartPeriod = Period() ; }    
   tChartPeriod =  TimeFrameToString(myChartPeriod) ;

   SetIndexStyle(0,DRAW_HISTOGRAM,0,5);
   SetIndexDrawBegin(0,ind_Buffer0);
   SetIndexBuffer(0,ind_Buffer0) ;  
      
   SetIndexStyle(1,DRAW_HISTOGRAM,0,5);
   SetIndexDrawBegin(1,ind_Buffer1);   
   SetIndexBuffer(1,ind_Buffer1) ;


   SetIndexStyle(2,DRAW_LINE);
   SetIndexDrawBegin(2,ind_Buffer2);   
   SetIndexBuffer(2,ind_Buffer2) ;
   
   SetIndexStyle(3,DRAW_LINE);
   SetIndexDrawBegin(3,ind_Buffer3);   
   SetIndexBuffer(3,ind_Buffer3) ;      
   
   
  return(0);
}
int deinit()
{

   return(0);
}

//+------------------------------------------------------------------+

int start()
{

DoWork( ) ;
 
   return(0);
  }

//+------------------------------------------------------------------+  
 

void DoWork( )
{
   string name  = indNames+"-1";


   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;
   
   for(int i=0; i<limit; i++)   
   {
   
   ind_Buffer0[i]  = iMA(NULL,0,FastMA,0,FastMA_Method,PRICE_CLOSE,i) ;
   ind_Buffer1[i] = iMA(NULL,0,SlowMA,0,SlowMA_Method,PRICE_CLOSE,i) ;
   ind_Buffer2[i] = ind_Buffer0[i] ;
   ind_Buffer3[i] = ind_Buffer1[i] ;        
   } // for                
}


//+------------------------------------------------------------------+ 

string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN";
   }
   return(tfs);
}