@ara, when you post some code, you should use the code button (the one with the </> symbol to properly display it.
Moreover, when you post some code, you should try to provide a "ready to run" snippet that will show your issue. Otherwise, it will be difficult for us to provide you any help.
I assure you that the GfxDrawText *works as expected also when used in loops in a recent version of AmiBroker (I tested it in version 6.10 32 bits and 6.27.1 Beta 64 bits).
So probably, there is something else in your code that is generating the issue (maybe some miscalculation, inverted order parameters or passing invalid values).
For instance in the line of your code:
GfxDrawText( "IBM",x1, y2 + ((3)*y_inc), x1 + textblock, y2 + ((4)*y_inc) , TA_Center );
I see that you call the function with this coordinates:
x1, y2 + ((3)*y_inc), x1 + textblock, y2 + ((4)*y_inc)
Is the first y2 the correct value?
I'm asking, because in general, for the "Left/Top" coordinates in many code samples you'll more commonly see the use of x1,y1 variable names, while the x2,y2 names are assigned to the "Right, Bottom" ones.
From GfxDrawText() documentation:
left - x-coordinate of upper left corner of the clipping rectangle
top - y-coordinate of upper left corner of the clipping rectangle
right - x-coordinate of lower right corner of the clipping rectangle
bottom - y-coordinate of lower right corner of the clipping rectangle
In any case, are you using the "_TRACE()" function to log and inspect the values/coordinates passed to the function?
Are they in the valid range of the chart/paned dimension?
To get the chart dimension see the Status() function doc passing to it , as appropriate per your code, the following "statuscodes"
"pxwidth" - returns pixel width of chart window pane (indicators only, low-level gfx) (AmiBroker 4.94 or higher)
"pxheight" - returns pixel height of chart window pane (indicators only, low-level gfx) (AmiBroker 4.94 or higher)
"pxchartleft" - returns x-coordinate of top-left corner of chart area
"pxcharttop" - returns y-coordinate of top-left corner of chart area
"pxchartright" - returns x-coordinate of bottom-right corner of chart area
"pxchartbottom" - returns y-coordinate of bottom-right corner of chart area
"pxchartwidth" - returns width chart area (right-left)
"pxchartheight" - returns width chart area (bottom-top)
Moreover, what is the value of the TA_Center parameter?
This variable needs to be a valid NUMERIC value as stated in this note:
Note: DT_ constants come from Windows API and are provided here for reference only. They are not defined in AmiBroker, therefore, you should use numerical values instead.
So to display a text-centered both horizontally and vertically on a single line in the text box, you need to pass the following NUMERIC VALUES, combining them with the binary operator | :
1 | 4 | 32
(corresponding to DT_CENTER | DT_VCENTER | DT_SINGLELINE)
For a left, bottom aligned, text you'll use:
0 | 8
(corresponding to DT_LEFT | DT_BOTTOM)
and so on.