Download MetaTrader 5

Right aligning numeric output

To add comments, please log in or register
phredotaku
22
phredotaku  

Hello,

Not sure why this is so difficult, but I am trying to line up numeric output on a chart use an OBJ_LABEL object.

I want numbers to be vertically displayed and right aligned.  The printf() function doesn't seem to do this

correctly, I have also tried using TextGetSize() and adjusting each string x coordinate (containing a number with 2 decimal

places) within a fixed pixel buffer.   TextOut() may be the answer but I'm stumped trying to get that to work.

If anyone has solved this problem, I would greatly appreciate any assistance.

Thanks,

Phred

Keith Watford
Moderator
10569
Keith Watford  

You can align them to the right, by using a right anchor.

I don't know if there is a font with all characters the same width in pixels, that way they would line up nicely, but maybe look odd? 

rod178
272
rod178  
GumRai:

..... if there is a font with all characters the same width in pixels, that way they would line up nicely, but maybe look odd? 

  Courier New
Keith Watford
Moderator
10569
Keith Watford  
rod178:
  Courier New
Thank you - useful to know :)
honest_knave
Moderator
2328
honest_knave  
phredotaku
22
phredotaku  
phredotaku:

Hello,

Not sure why this is so difficult, but I am trying to line up numeric output on a chart use an OBJ_LABEL object.

I want numbers to be vertically displayed and right aligned.  The printf() function doesn't seem to do this

correctly, I have also tried using TextGetSize() and adjusting each string x coordinate (containing a number with 2 decimal

places) within a fixed pixel buffer.   TextOut() may be the answer but I'm stumped trying to get that to work.

If anyone has solved this problem, I would greatly appreciate any assistance.

Thanks,

Phred

Thanks for the suggestions everyone.  I tried the first one from GumRai and it worked perfectly!!  Thanks for the help.


Phred

To add comments, please log in or register