Download MetaTrader 5

Please correct Object

To add comments, please log in or register
Daminda
110
Daminda  

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
6778
Carl Schreiber  
Search in the reference for OBJ_LABEL, click on it and you'll find a wonderful example!
whroeder1
15015
whroeder1  
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