//+------------------------------------------------------------------+
//|                                         Candle_Range_in_pips.mq4 |
//|                                                         Zen_Leow |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Zen_Leow"
#property link      ""

#property indicator_chart_window
//#property indicator_buffers 1
//#property indicator_color1  SkyBlue
//#property indicator_width1  3

input color  Text_Color    = DodgerBlue; // Text Color
input int    Text_Size     = 15; // Text Size
input string Text_Font     = "Verdsana"; // Text Type
input ENUM_BASE_CORNER    Corner_       = 2; // Corner
input int    Left_Right    = 10;
input int    Up_Down       = 5;


//double Range_Buffer[];

int x;

int PipFactor = 1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators



    switch(_Digits)
    {
      case 0: x = 1; break;
      case 1: x = 10; break;
      case 2: x = 100; break;
      case 3: x = 1000/10; break;
      case 4: x = 10000; break;
      case 5: x = 100000/10; break;
   }  
      
//---- drawing settings
  // SetIndexStyle(0,DRAW_LINE);
  // SetIndexBuffer(0,Range_Buffer);
  // SetIndexLabel(0,"Range");
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Candle Range");
   IndicatorDigits(1);
   
  
   
   
   // Cater for fractional pips
  // if (Digits == 3 || Digits == 5)
 //  {
      PipFactor = 10;
  // }
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("MRz");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(int i=0; i<limit;i++)
     // Range_Buffer[i]=((High[i]-Low[i])/Point)/PipFactor;
     
      ObjectCreate(0,"MRz",OBJ_LABEL,0,0,0);
   ObjectSetText("MRz", Symbol() + " : " + DoubleToStr(((High[0]-Low[0])*x),1), Text_Size, Text_Font,  Text_Color);
   ObjectSet("MRz", OBJPROP_CORNER, Corner_);
   ObjectSet("MRz", OBJPROP_XDISTANCE, Left_Right);
   ObjectSet("MRz", OBJPROP_YDISTANCE, Up_Down);
   ObjectSet("MRz", OBJPROP_SELECTABLE, 0);
   ObjectSet("MRz", OBJPROP_BACK, 1);
//---- done
   return(0);
  }
//+------------------------------------------------------------------+