Download MetaTrader 5
To add comments, please log in or register
Sell your CPU capacity and earn money!
Daminda
51
Daminda 2015.02.06 12:02 

I add following code to display Spread in chart. but it show spread as whole number not as decimal. (ex: it show 0.2 spread as 2.0) how to correct this code?

 

    
   {
   ObjectCreate("Spread", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Spread", OBJPROP_CORNER, 3);
   ObjectSet("Spread", OBJPROP_XDISTANCE, 10);
   ObjectSet("Spread", OBJPROP_YDISTANCE, 10);
   ObjectSetText("Spread", "Spread: "+ DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD),1), 16, "Tahoma", Yellow);
   WindowRedraw();
   return(0);
  }
Carl Schreiber
5932
Carl Schreiber 2015.02.06 12:07  
Search in the reference for OBJ_LABEL, click on it and you'll find a wonderful example!
whroeder1
13596
whroeder1 2015.02.06 13:10  
daminda1989: but it show spread as whole number not as decimal. (ex: it show 0.2 spread as 2.0) how to correct this code?
DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD)
  1. Of course it does. Spread returns the number of points the spread is. It is ALWAYS a whole number. Perhaps you mean the spread in pips. Spread/pips2points
  2. Why are you using a function call? Why not just spread = (Ask-Bid)/pips2dbl?
/
To add comments, please log in or register