Gfxdrawtext() format isue

WIN 7 / AB 6.28.0
I use GfxDrawText(() multiple times in program and typically it works fine.

One line does not print correctly

GfxDrawText( Numtostr( LastValue(Close, 1.2 )), 200,800,300,850, TA_Right );

I expect this line to print as xxx.xx (2 decimal places). It prints, no matter what parameter I use for formatting.

Numtostr( LastValue(Close, 1.2 ))
Numtostr( LastValue(Close, 1.0 ))
Numtostr( LastValue(Close, 1.5 ))

All above print as All other lines in program work properly

How would I start troubleshooting this?


You have set brackets at wrong place.

GfxDrawText( Numtostr( LastValue(Close), 1.2), 200,800,300,850, TA_Right );

Same for your other three examples. So if you get confused with brackets then simply create separate variables.

LastPrice = LastValue(Close);
str1 = Numtostr( LastPrice, 1.2 );
str2 = Numtostr( LastPrice, 1.0 );
str3 = Numtostr( LastPrice, 1.5 );
printf( "format1: %s, format2: %s, format3: %s", str1, str2, str3);

Read AFL function reference of NumToStr and LastValue.


How silly of me ... and how wonderful to have an extra pair of eyes