//+------------------------------------------------------------------+
//|                                         _TRO_IcYcLoUd            |
//|   Copyright � 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|                                                                  |
//|   therumpledone@gmail.com                                        |  
//+------------------------------------------------------------------+ 
// idea found here: http://forums.babypips.com/free-forex-trading-systems/8433-icycloud-trading-system.html

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

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Gold    
#property indicator_color2 Gold         
#property indicator_color3 Gold      
#property indicator_color4 Maroon    
#property indicator_color5 Red        
   

//---- parameters
 
extern string myPair    = "";


//---- buffers

   double     ExtBuffer0[];   
   double     ExtBuffer1[];
   double     ExtBuffer2[];
   

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

int myPeriod = PERIOD_H4 ;

bool use.pMid = false ;


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

string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_MN1: tfs="MN"; break;
      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;
   }
   return(tfs);
} 

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

int init()
{
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
 
 
   
   SetIndexStyle(0,DRAW_ARROW, EMPTY, 2, indicator_color1);
   SetIndexStyle(1,DRAW_LINE, EMPTY, 2, indicator_color2);
   SetIndexStyle(2,DRAW_LINE, EMPTY, 2, indicator_color3);
 
if (myPair == "") myPair = Symbol();
   
string tPeriod = TimeFrameToString(PERIOD_H4) ;

IndicatorShortName("IcYcLoUd "+myPair+"("+tPeriod+")" );
    
return(0);
}

//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
  
//+------------------------------------------------------------------+
int start()
  {
  
  
if ( Period() != PERIOD_H4 ) {Alert("ERROR: CHART PERIOD SHOULD BE H4 !!" ); }
  
   int counted_bars=IndicatorCounted();
   
   if(counted_bars<0) return(-1);
   
   if(counted_bars>0) counted_bars--;
   
   int bars=Bars-counted_bars;


//---- main calculation loop
/*

Requirment for LONG Entry

When the 1st Probalic SAR (PS) dot appears BELOW the bollienger Bends, 
its time for a long entry.

Requirment for SHORT Entry

When the 1st PS dot appears ABOVE the bollienger Bends, 
its time for a short entry.

*/


while(bars>=0)
{          

      ExtBuffer0[bars] = iSAR(NULL,myPeriod, 0.02,0.2,bars)  ;       
      
      ExtBuffer1[bars] = iBands(NULL,myPeriod,20,2,0,PRICE_CLOSE,MODE_LOWER,bars) ;
      ExtBuffer2[bars] = iBands(NULL,myPeriod,20,2,0,PRICE_CLOSE,MODE_UPPER,bars) ;      
      
 

 
       
bars--; }
 
 
 
return(0);

}

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

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