GfxTextOut position dynamic offset

Hi everyone,

i have a simple question , on how to position , text box on a chart pane
currenlty i am printing the text , using the following code

//print text on top of the volume
	x = mid-width;
	y = myTotal[i] + statBarTxtOffSet; // <<< the y-postio is an issue
	change = 100 * myTotal[i]/myTotal[i-1];
	buyUp = myBuy[i] > mySell[i];   	
	BkColor = IIf(change > 50 AND buyUp ,colorGreen,colorRed);
	GfxSetBkColor( BkColor );
	myStr = NumToStr( myTotal[i]/Billion,1.0);
	myStr = myStr + "," + NumToStr( BuyValPcnt[i], 1.0);
	myStr = myStr + "," + NumtoStr( SellValPcnt[i], 1.0 );
	myStr = NumToStr(change,1.0);
	GfxTextOut( myStr, x, y );

however using the above codes i need to readjust statBarTxtOffSet variable from parameter window (see below images) .

my question is how do I set/code the dynamically position of the text to stay above the yelow line, regardless of zoom?

thank you

e.g
zoom 1
zoom1
zoom 2
zoom2

@fourier which GfxSetCoordsMode( mode ) are you using to get your x and y pos?

GfxSetCoordsMode

I think you'll have to experiment a little with all the modes to fully understand how they work.

The old mode 0 (zero) is the one that will allow you to do simple pixel-based calculations for your offsets but to works correctly it requires a refresh each time you change the scale. See this example:

How to convert from bar-value to pixel co-ordinates

Form the documentation:

Note that the function GfxSetCoordsMode can be called to switch back and forth from pixel -> bar/price mode and vice versa a number of times allowing to mix different modes in the same chart.
When co-ordinate mode 1 is selected (bar/price), co-ordinates can be fractional. For example if x is 2.5 it means half way between bar 2 and 3.

sorry forgot to include GfxSetCoordsMode( 1 ); i think the simplest one
using bar/price, i though it would have anchored to the price level + offset
but it did not . will experiment thanks