_TRO_RANGE_EZ_C





//+------------------------------------------------------------------+ 
//|  _TRO_RANGE_EZ_C                                                 | 
//|                                                                  | 
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|                                                                  |
//|   therumpldone@gmail.com                                         |  
//+------------------------------------------------------------------+ 

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

//---- indicator settings 
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_minimum 0
#property indicator_maximum 1



//---- indicator parameters  
//extern int   Threshold       = 20; 

extern int win = 0;
extern int price.x.offset= 0;//250
extern int price.y.offset= 0;//-160



extern int   MaxBars         = 960;


extern color CurrentBarColor = LightGray ; 
extern color ThresholdColor  = LimeGreen; 


//---- indicator buffers 


double     MaxRange = 0 ; 
double     MinRange = 0 ; 
double     AvgRange = 0 ; 
double     xRange   = 0 ; 
double     tRange   = 0 ; 



//---- buffers

int   Chart_Period    = 0;
double zRANGE = 0;

bool  show.info       = true;
bool  ShowChart       = true; 

//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
      Chart_Period    = Period();
   return(0); 
  } 

int deinit() 
{ 

   
   ObjectDelete("RNG330");
   ObjectDelete("RNG329");
   ObjectDelete("RNG329B");
   ObjectDelete("RNG331");
   ObjectDelete("RNG332");
   ObjectDelete("RNG334");   
}  

//+------------------------------------------------------------------+ 
//| Range                                                            | 
//+------------------------------------------------------------------+ 
int start() 
  { 

    MaxRange = 0 ; 
    MinRange = 999999 ; 

   double HighVal,LowVal; 
   int limit; 
   int counted_bars=IndicatorCounted(); 
    
//---- last counted bar will be recounted 
   if(counted_bars>0) counted_bars--; 
   if(counted_bars<0) return(-1); 
   

  
   limit = MaxBars ;  

//---- RANGE counted in the 1-st buffer 


		double buf_tmp = 0 ;
		int z = 0 ;

   for(int i=0; i<limit; i++) 
   { 

     HighVal  = iHigh(NULL,Chart_Period,i);        
     LowVal   = iLow(NULL,Chart_Period,i); 

     xRange   = HighVal - LowVal ; // range

     tRange = xRange / Point; // range
     
     buf_tmp =  buf_tmp + xRange ;
 
     
     if( tRange > MaxRange ) {MaxRange = tRange  ; }
     if( tRange < MinRange ) {MinRange = tRange  ; }  
    
    
   } 

   AvgRange = buf_tmp / MaxBars /Point ; // average range 

 
 
   
 
   
    zRANGE = (iHigh(NULL,Chart_Period,0)-iLow(NULL,Chart_Period,0))/Point ;
   

//} 
 
//+------------------------------------------------------------------+ 
   
//void DoShowInfo()

//{

string tPeriod = " "+TimeFrameToString( Chart_Period ) ;

if ( zRANGE > AvgRange ) { color RangeColor = ThresholdColor ; } else { RangeColor = CurrentBarColor   ; }

   ObjectCreate("RNG330", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("RNG330","RANGE", 30, "Arial Bold", Gray);
   ObjectSet("RNG330", OBJPROP_CORNER, 0);
   ObjectSet("RNG330", OBJPROP_XDISTANCE, 150+price.x.offset);
   ObjectSet("RNG330", OBJPROP_YDISTANCE, 14+price.y.offset);
 
   ObjectCreate("RNG329", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("RNG329",DoubleToStr(MaxRange,0), 15, "Arial Bold", Lime);
   ObjectSet("RNG329", OBJPROP_CORNER, 0);
   ObjectSet("RNG329", OBJPROP_XDISTANCE, 150+price.x.offset);
   ObjectSet("RNG329", OBJPROP_YDISTANCE, 51+price.y.offset);
   
   ObjectCreate("RNG329b", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("RNG329b",DoubleToStr( MinRange ,0), 15, "Arial Bold", Crimson);
   ObjectSet("RNG329b", OBJPROP_CORNER, 0);
   ObjectSet("RNG329b", OBJPROP_XDISTANCE, 150+price.x.offset);
   ObjectSet("RNG329b", OBJPROP_YDISTANCE, 110+price.y.offset);                 
                     
   ObjectCreate("RNG331", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("RNG331",DoubleToStr(zRANGE,0)+tPeriod, 40, "Arial Bold", RangeColor );
   ObjectSet("RNG331", OBJPROP_CORNER, 0);
   ObjectSet("RNG331", OBJPROP_XDISTANCE, 150+price.x.offset); // 765
   ObjectSet("RNG331", OBJPROP_YDISTANCE, 61+price.y.offset); 
           
 
   ObjectCreate("RNG332", OBJ_LABEL, win, 0, 0);   // 
   ObjectSetText("RNG332",DoubleToStr( AvgRange ,2), 15, "Arial Bold", Orange); // RANGEBuffer2[0] buf0[0]
   ObjectSet("RNG332", OBJPROP_CORNER, 0);
   ObjectSet("RNG332", OBJPROP_XDISTANCE, 240+price.x.offset);
   ObjectSet("RNG332", OBJPROP_YDISTANCE, 51+price.y.offset);
                 
   ObjectCreate("RNG334", OBJ_LABEL, win, 0, 0);
   ObjectSetText("RNG334",DoubleToStr( MaxBars ,0), 15, "Arial Bold", Silver);
   ObjectSet("RNG334", OBJPROP_CORNER, 0);
   ObjectSet("RNG334", OBJPROP_XDISTANCE, 250+price.x.offset);
   ObjectSet("RNG334", OBJPROP_YDISTANCE, 110+price.y.offset);    
    

   WindowRedraw();    
 
//} 

   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="MN1";
   }
   return(tfs);
}
 
//+------------------------------------------------------------------+



Sample



image not available


Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: