Please correct Object

Back to topics list To post a new topic, please log in or register
avatar
9
daminda1989 2015.02.06 13: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);
  }

 

avatar
2017
gooly 2015.02.06 13:07 #
 
Search in the reference for OBJ_LABEL, click on it and you'll find a wonderful example!
avatar
13004
WHRoeder 2015.02.06 14: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?
Back to topics list  

To add comments, please log in or register