problem with precision on OBJPROP_PRICE

 
 
  string name1;
  double normprice;
  for(int i=0;i<ObjectsTotal();i++)
    {
     name1=ObjectName(i);
     normprice=ObjectGet(ObjectName(i),NormalizeDouble(OBJPROP_PRICE1,4));
     Print("Object #"+i+" name is "+"\""+name1+"\" and price is "+normprice);
What's wrong with the code above? It's not printing just 4 digits as expected but rather all digits.
 
normprice=NormalizeDouble(ObjectGet(ObjectName(i),OBJPROP_PRICE1),4);
 
stringo wrote:
normprice=NormalizeDouble(ObjectGet(ObjectName(i),OBJPROP_PRICE1),4);

Okay. That has no effect. Same result as before which is there is no control over the precision. Please see the attached screen shot.

 
     Print("Object #",i," name is ","\"",name1,"\" and price is ",normprice);
commas instead of concatenation. feel the difference
 
stringo wrote:
     Print("Object #",i," name is ","\"",name1,"\" and price is ",normprice);
commas instead of concatenation. feel the difference

Got it. Thanks. Although it's odd that using "+" affected precision.. .
 
there is another rule. rule of string concatenation, not print rule.

If You need to control strings then use conversion functions, in your case - DoubleToStr
 
Got it. Yes, I just need to adjust precision for display as a string here so DoubleToStr is better. Thanks for the help.
 
stringo wrote:
     Print("Object #",i," name is ","\"",name1,"\" and price is ",normprice);
commas instead of concatenation. feel the difference

Actually, feel the docs on this one too.

Plus sign "+" is used in the code example for ObjectsTotal() as follows within Print():

Print(i,"Object name for object #",i," is " + name);

If the preferred and accurate method is to exclusively use commas, the docs should follow suit.
 
See function StringConcatenate https://docs.mql4.com/strings/StringConcatenate
 
stringo wrote:
See function StringConcatenate https://docs.mql4.com/strings/StringConcatenate

Yes, I see that. Do you see my point about the doc example being inaccurate for ObjectsTotal? Its very difficult for newcomers to learn the right method to code when the docs provide wrong or non-preferred examples.