Need a small help with this piece of code.

#1
I am looking at printing some values on the screen.

In this example I am printing the range of the selected bar.

What I need help with is, changing the font and the size of the font of the values printed.


Here is the code. Please take a look and thanks in advance.

PHP:
_SECTION_BEGIN("Price");

SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat(" {{NAME}} -     {{INTERVAL}}      {{DATE}}                             Open %g,     Hi %g,     Lo %g,     Close %g (%.1f%%)      Vol " +WriteVal( V, 1.0 ) +"  \n\nRange  "+WriteVal((H-L),1.2)+ "     {{VALUES}}", O, H, L, C,  SelectedValue( ROC( C, 1 )) ));

Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
 ToolTip=StrFormat("Open: %g\nHigh:  %g\nLow:   %g\nClose:  %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));

}

_SECTION_END();
 
#2
I am looking at printing some values on the screen.

In this example I am printing the range of the selected bar.

What I need help with is, changing the font and the size of the font of the values printed.


Here is the code. Please take a look and thanks in advance.

PHP:
_SECTION_BEGIN("Price");

SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat(" {{NAME}} -     {{INTERVAL}}      {{DATE}}                             Open %g,     Hi %g,     Lo %g,     Close %g (%.1f%%)      Vol " +WriteVal( V, 1.0 ) +"  \n\nRange  "+WriteVal((H-L),1.2)+ "     {{VALUES}}", O, H, L, C,  SelectedValue( ROC( C, 1 )) ));

Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
 ToolTip=StrFormat("Open: %g\nHigh:  %g\nLow:   %g\nClose:  %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));

}

_SECTION_END();
Hello,

You will have to use low level graphics to control font and its size. You can use the function GfxSelectFont( ''facename'', pointsize, weight = fontNormal, italic = False, underline = False, orientation = 0 ) for this purpose.

Please read the User Guide to know more about Low Level Graphics.

I hope this helps.

Best regards,

AmiBroker-India
 
#4
Hi,
I did take a look at it, and tried to make some changes, but I am not sure as to where to add that line of code.

Please help.
Hello,

You can add this code anywhere because it plots using pixel data i.e. each pixel as a co-ordinate. Do remember that top left of your computer screen is (0,0) and as you progress towards right (X-axis), co-ordinate increases and so when you come down (Y-axis).

A sample program with comments is given below for understanding.

//Select the font and its attributes first.
GfxSelectFont("Arial", 12, 600, True,True );

//Now we are setting transparent background for the text (actually same background as that of our screen).
GfxSetBkMode(1);

//Define text colour
GfxSetTextColor(colorBlue);

// Now output the text on screen. 2nd and 3rd argument are X,Y co-ordinates.
GfxTextOut("www.tradinganalysis.co.in", 10, 20);

// Just changing the formatting (removing italics and underline)
GfxSelectFont("Arial", 12, 600);

// Define new text colour
GfxSetTextColor(colorLightBlue);

// Output another text on the screen at another location.
GfxTextOut("Official AmiBroker Distributor for India", 10, 40);

I hope this helps.

Best regards,

AmiBroker-India
 

Similar threads