//+------------------------------------------------------------------+
//|                                                                  |
//|                         SpreadIndicator.mq4                      |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""

#property indicator_chart_window

extern int          DistanceHB   = 110;
extern int          Distance1DG  = 20;
extern int          Distance2DG  = 10;
extern int          Dimension1   = 9;
extern int          Dimension2   = 9;
extern int          corner       = 1;
extern color        Color1       = White;
extern color        Color2       = White;

int Spread;
double ExtMapBuffer1[];

//-----------------------------------------------------------------------------

int start()
  {
        Spread=NormalizeDouble((Ask-Bid)/Point,0);
        ObjectSetText( "Spread1", "Spread :", Dimension1, "Arial", Color1 );
        ObjectSetText( "Spread2", DoubleToStr(Spread ,0), Dimension2, "Arial", Color2 );

   return(0);
  }

//-----------------------------------------------------------------------------

void ObjectMakeLabel( string n, int xdistance, int ydistance ) 
   {
   ObjectCreate( n, OBJ_LABEL, 0, 0, 0 );
   ObjectSet( n, OBJPROP_CORNER, corner );
   ObjectSet( n, OBJPROP_XDISTANCE, xdistance );
   ObjectSet( n, OBJPROP_YDISTANCE, ydistance );
   ObjectSet( n, OBJPROP_BACK, true );
   }

//-----------------------------------------------------------------------------

int init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   int Dist1 = DistanceHB;

   ObjectMakeLabel( "Spread1", Distance1DG, Dist1-105 );   
   ObjectMakeLabel( "Spread2", Distance2DG, Dist1-105 );   
   
   return(0);
  }

//-----------------------------------------------------------------------------

int deinit()
  {
   ObjectDelete( "Spread1" );   
   ObjectDelete( "Spread2" );       

   return(0);
  }

