//+------------------------------------------------------------------+
//|   TRO_TREND_MAP                                                  |
//|                                                                  |
//|   Copyright © 2008, 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


extern int        myChartY    = 100 ;
extern int        myBars      = 0 ; 
extern int        mySkip      = 0 ; 
 
 
extern color myColorUp = Lime ;
extern color myColorDn = Red ;

int ChartPeriod ;
int    digits;

 
color ColorTrend = Yellow ;

   double CL, pCL;
   int    i , skip, xBars ;
    
 
string dLabel, xLabel ;
string symbol, tChartPeriod, sX02 ;  


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
   ChartPeriod = Period();


      

   tChartPeriod =  TimeFrameToString(ChartPeriod) ;
   symbol       =  Symbol() ;
   digits       =  Digits ;   
   dLabel       =  "TMAP" + symbol + tChartPeriod ;

       
 
    
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll(0);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{

    if( myBars == 0 ) { xBars = WindowBarsPerChart() ; } else { xBars = myBars ; }

    CL = iClose(NULL,ChartPeriod ,0) ; 
 
  
  
  for( i = 1 ; i <= xBars ; i++ )
  {
    skip = i+mySkip ;
    
    pCL  = iClose(NULL,ChartPeriod , skip ) ;     
 
    xLabel = dLabel + i ;
    
    if( CL > pCL ) { ColorTrend = myColorUp ; } else  { ColorTrend = myColorDn ; } 
    
    
    ObjectDelete(xLabel) ;

    ObjectCreate(xLabel,OBJ_TREND,0,0,0,0,0);
    ObjectSet(xLabel,OBJPROP_COLOR,ColorTrend); 
    ObjectSet(xLabel,OBJPROP_RAY,false);    
    ObjectSet(xLabel,OBJPROP_WIDTH,2); 
 
    ObjectMove(xLabel,0,Time[skip],pCL);
    ObjectMove(xLabel,1,Time[0],CL);
  }
  

     
        
return(0);
}

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

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);
}
//+------------------------------------------------------------------+ 


/*

 
 
 high = -1 ;
 low = 999999999 ;
  
 
 D0 = TimeDay( Time[0] ) ; 
 
 CL = iClose(NULL,ChartPeriod ,0) ; 
   
 for( i=0; i<=1440; i++)
 {
 if( TimeDay( Time[i] ) != D0 ) { break ; }
 
 xHigh = iHigh(NULL,ChartPeriod,i) ;
 xLow = iLow(NULL,ChartPeriod,i) ;
 
 if ( xHigh > high ) { high  = xHigh ; rt1 = i ; }
 if ( xLow < low  ) { low   = xLow ; st1 = i ; }  
 
 } // for(i=0...
  
  
*/



