//+------------------------------------------------------------------+
//|                                            FXPT_CandleSizev2.mq4 |
//|                                         Developed by fxprotrader |
//|                                     http://www.fxpro-trader.com" |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2013, fxprotrader"
#property link      "http://www.fxpro-trader.com"
//-------- HISTORY----------------
// v1 Initial release(01102013)
// v2 Updated release(01112013)
//--------------------------------

#property indicator_chart_window

extern int TextPosition=10;
extern int TextAngle   =0;//0-90
extern int NumberBars  =100;//0-90
static datetime prevtime = 0;

double Poin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   if (Point==0.00001) Poin=0.0001;
   else {
      if (Point==0.001) Poin=0.01;
      else Poin=Point;
   }

//----
   return(0);
  }
//+------------------------------------------------------------------+
//                                                                   +
//+------------------------------------------------------------------+
int deinit(){
   DeleteObjects();
   return(0);
}
//+------------------------------------------------------------------+
//                                                                   +
//+------------------------------------------------------------------+
void DeleteObjects(){
   int objs = ObjectsTotal();
   string name;
   for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)
   {
      name=ObjectName(cnt);
      if (StringFind(name,"FXPTc_",0)>-1) ObjectDelete(name);
     WindowRedraw();
   }
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){
 
 string text,sObjName;
 double Rng;
 
 if(prevtime == Time[0]) {
	return(0);
 }
 DeleteObjects();
 
 for(int i=0; i<NumberBars; i++){
    Rng= MathAbs(Open[i] - Close[i])/Poin;

text=DoubleToStr(Rng,0);

if(Open[i] < Close[i]){
sObjName="FXPTc_label1"+i;
 ObjectCreate(sObjName, OBJ_TEXT, 0, Time[i], High[i]+TextPosition*Poin);
  ObjectSet(sObjName, OBJPROP_ANGLE, TextAngle);
ObjectSetText(sObjName,text,10, "Corbel", Green);
}
else{
sObjName="FXPTc_label1"+i;
 ObjectCreate(sObjName, OBJ_TEXT, 0, Time[i], Low[i]-TextPosition*Poin);
  ObjectSet(sObjName, OBJPROP_ANGLE, TextAngle);
ObjectSetText(sObjName,text,10, "Corbel", Red);

}
   
   
   }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+