//+------------------------------------------------------------------+
//|                                                                  |
//|                        Sonic Dragon.mq4                          |
//|                                                                  |
//+------------------------------------------------------------------+ 
#property  copyright "TRO_Tunnel_dragon, Copyright © 2008"
//  Avery T. Horton, Jr. aka TRO, PO BOX 43575, TUCSON, AZ 85733,
//  therumpledone@gmail.com " 
/*---------------------------------------------------------------------
Sonic Dragon:

This indicator is based on code in the referenced copyright indicator.
Some code was removed, some added.  Additions enhance the indicator by
making it "preserve" user choices of colors and linestyles.  Deletions
enhance the indicator by removing selections not required.
                                                        - Traderathome
----------------------------------------------------------------------*/
#property indicator_chart_window

#property indicator_buffers  4
#property indicator_color1   DodgerBlue 
#property indicator_color2   Red
#property indicator_color3   DodgerBlue
#property indicator_color4   CLR_NONE
#property indicator_width1   1
#property indicator_width2   1
#property indicator_width3   1
#property indicator_style1   STYLE_SOLID
#property indicator_style2   STYLE_SOLID
#property indicator_style3   STYLE_SOLID

//global external inputs
extern bool    Indicator_On   = true;
extern int     MAperiod         = 34;
extern string  SetMAtype_to     = "0=SMA, 1=EMA";
extern int     MAtype           = 1;
extern string  SetCenterline_to = "0=CLOSE, 4=MEDIAN";
extern int     Centerline       = 0;
//extern bool    Show.PriceBox  = false;

//global buffers and variables
double P0Buffer[];
double P1Buffer[];
double P2Buffer[];

string tP0Buf = "drma_01" ;
string tP1Buf = "drma_02" ;
string tP2Buf = "drma_03" ;

int  myPeriod = 0 ;
int  myShift  = 0 ;
//+------------------------------------------------------------------+
//| Initialize                                                       |
//+------------------------------------------------------------------+
int init()
   {
/*   
   //name for indicator window
   string short_name="Sonic Dragon";
   IndicatorShortName(short_name);
*/   
   //initiate buffers
   SetIndexBuffer(0, P0Buffer);
   SetIndexBuffer(1, P1Buffer);
   SetIndexBuffer(2, P2Buffer);
 
   //initiate styles for drawing bufffer values
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);   
   SetIndexStyle(2, DRAW_LINE);
/*
   //initiate for values visible on the chart
   SetIndexEmptyValue(0,0); 
   SetIndexEmptyValue(1,0);
   SetIndexEmptyValue(2,0); 
*/   
   return(0);
   }
//+------------------------------------------------------------------+
//| Deinitialize                                                     |
//+------------------------------------------------------------------+
int deinit()
   {
   ObjectDelete(tP0Buf);
   ObjectDelete(tP1Buf);
   ObjectDelete(tP2Buf);         
   return(0);
   }
//+------------------------------------------------------------------+
//| Start Program                                                    |
//+------------------------------------------------------------------+
int start()
   {
   deinit(); if (Indicator_On == false){return(0);}
   datetime TimeArray[];
   int i, dayi, 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--;  
   int limit = Bars - counted_bars; 
   for(i = limit - 1; i >= 0; i--)   //---- Tricolor indicator code 
     {
     int BarShift = iBarShift(NULL,myPeriod,Time[i+myShift],true);         
     P0Buffer[i] = iMA(NULL,myPeriod,MAperiod,0,MAtype,PRICE_HIGH,BarShift);       
     P1Buffer[i] = iMA(NULL,myPeriod,MAperiod,0,MAtype,Centerline,BarShift); 
     P2Buffer[i] = iMA(NULL,myPeriod,MAperiod ,0,MAtype,PRICE_LOW,BarShift);       
     }	 
/*
   if(Show.PriceBox) 
     { 
     if (ObjectFind(tP0Buf) != 0){              
         ObjectCreate(tP0Buf,OBJ_ARROW,0,Time[0],P0Buffer[0]);
         ObjectSet(tP0Buf,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
         ObjectSet(tP0Buf,OBJPROP_COLOR,indicator_color1);} 
     else{
         ObjectMove(tP0Buf,0,Time[0],P0Buffer[0]);}
    
     if (ObjectFind(tP1Buf) != 0){
       ObjectCreate(tP1Buf,OBJ_ARROW,0,Time[0],P1Buffer[0]);
       ObjectSet(tP1Buf,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
       ObjectSet(tP1Buf,OBJPROP_COLOR,indicator_color2);} 
     else{
         ObjectMove(tP1Buf,0,Time[0],P1Buffer[0]);}

     if (ObjectFind(tP2Buf) != 0){
         ObjectCreate(tP2Buf,OBJ_ARROW,0,Time[0],P2Buffer[0]);
         ObjectSet(tP2Buf,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
         ObjectSet(tP2Buf,OBJPROP_COLOR,indicator_color3);} 
     else{
         ObjectMove(tP2Buf,0,Time[0],P2Buffer[0]);}
     }     
*/     	
   return(0);
   }
//+------------------------------------------------------------------+
//| End Program                                                      |
//+------------------------------------------------------------------+