   //+------------------------------------------------------------------+
//|                                                  ForexTaurus.mqh |
//|                                      Copyright 2015, ForexTaurus |
//|                                  http://forextaurus.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, ForexTaurus"
#property link      "http://forextaurus.blogspot.com"
#include <ForexTaurus.mqh>

#property indicator_chart_window

                           extern string IndicatorName = "FriendlyGrid";        
                           extern int BarsToShiftRight = 10;                             
                           extern int MaximumDividers = 10;
                                       
                           
                           

double PriceMax,PriceMin;

int init()
{
   
 return(0);
 }
int deinit()
{
   DeleteAllObjectsStartingWith(IndicatorName);
   return(0);
}

int start()
{
   DrawPipValues();
   Sleep(3*1000);
   return(0);
}
 
void OnChartEvent(const int id,         // Event identifier  
                  const long& lparam,   // Event parameter of long type
                  const double& dparam, // Event parameter of double type
                  const string& sparam) // Event parameter of string type
  {
//--- the left mouse button has been pressed on the chart
   if(id==CHARTEVENT_CLICK)
     {
      
      
     }
} //ChartClick 

void DrawPipValues()
{ bool Redraw=False;
  if (NormalizeDouble(WindowPriceMax()-50*Point,Digits-2)!=PriceMax) Redraw=True;
  if (NormalizeDouble(WindowPriceMin()+50*Point,Digits-2)!=PriceMin) Redraw=True;
  
  if (Redraw)
  {
      DeleteAllObjectsStartingWith(IndicatorName);
      string objname;
      PriceMax=NormalizeDouble(WindowPriceMax()-50*Point,Digits-2);PriceMin=NormalizeDouble(WindowPriceMin()+50*Point,Digits-2);      
      //ArrowRightPriceCreate(NULL,IndicatorName+PriceMax,0,TimeCurrent()+Period()*10,NormalizeDouble(PriceMax,Digits-2),clrBlack,0,2,false,false,false);
      objname=IndicatorName+PriceMax;
      PrintTextObject(objname,DoubleToStr(PriceMax,Digits-1),TimeCurrent()+Period()*BarsToShiftRight*60,PriceMax,"Arial",clrSilver,10);
      ObjectSet(objname,OBJPROP_SELECTABLE,False);
      
      int x;double tempprice;int Steps=100;
      bool done=false;
      
      while (!done)
      {
      x = (PriceMax-PriceMin)/Point/Steps;
      if (x>MaximumDividers)Steps = Steps+100;else done=true;
      }
      
      for (x = 0;x<(PriceMax-PriceMin)/Point/Steps;x++)
      {
        tempprice=PriceMax-Steps*x*Point;
        objname=IndicatorName+tempprice;       
        PrintTextObject(objname,DoubleToStr(tempprice,Digits-1),TimeCurrent()+Period()*BarsToShiftRight*60,tempprice,"Arial",clrSilver,10);
        ObjectSet(objname,OBJPROP_SELECTABLE,False);
      }
      objname=IndicatorName+PriceMin;
      PrintTextObject(objname,DoubleToStr(PriceMin,Digits-1),TimeCurrent()+Period()*BarsToShiftRight*60,PriceMin,"Arial",clrSilver,10);
      ObjectSet(objname,OBJPROP_SELECTABLE,False);      
      //ArrowRightPriceCreate(NULL,IndicatorName+PriceMin,0,TimeCurrent()+Period()*10,NormalizeDouble(PriceMin,Digits-2),clrBlack,0,2,false,false,false);
  }
  
  

}