Dear AFL Experts!
I am currently learning AFL (AmiBroker Formula Language) and have successfully integrated Gemini into AmiBroker. That is absolutely wonderful!
I am trying to write a code to create a "top panel" to display essential market information. My biggest hurdle is the alignment of text.
I would be very grateful if you could help me with the following layout requirements:
- "Left Alignment" : Align the basic price and volume information to the left, including of Open Price, Low Price, High Price, Close Price, and Volume.
- Right Alignment: Align the Moving Average indicators (such as MA20, MA50, MA100, etc.) to the right.
I would be highly appreciative if someone could review and assist me with the code correction.
Wishing you all a happy weekend with your families.
(My code as bellow)
_SECTION_BEGIN("Top Panel");
GfxSetZOrder(5);
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
PanelHeight = pxheight / 5;
GfxGradientRect(0, 0, pxwidth, PanelHeight, ColorRGB( 40, 40, 40 ), ColorRGB( 10, 10, 10 ));
GfxSetTextColor( ColorRGB( 25, 225, 2 ) );
GfxSelectFont("UVN But Long 1", PanelHeight / 8, 700 );
GfxSetTextAlign( 6 );
GfxTextOut( "SECURITIES INVESTMENT SYSTEM - " + Name() + " (" + Interval( 1 ) + ")", pxwidth / 2, PanelHeight / 20 );
GfxSetTextColor( colorWhite );
GfxSelectFont("Arial", 10, 400 );
GfxSetBkMode( 1 );
LeftMargin = 15;
RowSpacing = PanelHeight / 5;
CurrentY = PanelHeight / 4;
GfxSetTextAlign( 1 );
GfxTextOut( "OPEN:", LeftMargin, CurrentY );
GfxSetTextColor( ColorRGB( 100, 255, 100 ) );
GfxTextOut( WriteVal( O, 1.2 ), LeftMargin + 70, CurrentY );
CurrentY = CurrentY + RowSpacing;
GfxSetTextColor( colorWhite );
GfxTextOut( "HIGH:", LeftMargin, CurrentY );
GfxSetTextColor( ColorRGB( 100, 255, 100 ) );
GfxTextOut( WriteVal( H, 1.2 ), LeftMargin + 70, CurrentY );
CurrentY = CurrentY + RowSpacing;
GfxSetTextColor( colorWhite );
GfxTextOut( "LOW:", LeftMargin, CurrentY );
GfxSetTextColor( ColorRGB( 255, 100, 100 ) );
GfxTextOut( WriteVal( L, 1.2 ), LeftMargin + 70, CurrentY );
CurrentY = CurrentY + RowSpacing;
PercentChange = ( C / Ref( C, -1 ) - 1 ) * 100;
ColorChange = IIf( PercentChange >= 0, ColorRGB( 100, 255, 100 ), ColorRGB( 255, 100, 100 ) );
GfxSetTextColor( colorWhite );
GfxTextOut( "CLOSE:", LeftMargin, CurrentY );
GfxSetTextColor( LastValue( ColorChange ) );
GfxTextOut( WriteVal( C, 1.2 ) + " (" + WriteVal( PercentChange, 1.2 ) + "%)", LeftMargin + 70, CurrentY );
GfxSetTextColor( colorWhite );
//GEMINI CREAT RIGHT Alig
RightMargin = pxwidth - 15;
CurrentY = PanelHeight / 4;
GapFromRight = 150;
MA_Periods[ 0 ] = 10;
MA_Periods[ 1 ] = 20;
MA_Periods[ 2 ] = 50;
MA_Periods[ 3 ] = 100;
MA_Periods[ 4 ] = 200;
for ( i = 0; i < 5; i = i + 1 )
{
CurrentMA = MA( C, MA_Periods[ i ] );
label_str = "";
switch( i )
{
case 0: label_str = "MA 10"; break;
case 1: label_str = "MA 20"; break;
case 2: label_str = "MA 50"; break;
case 3: label_str = "MA 100"; break;
case 4: label_str = "MA 200"; break;
}
MASignal = IIf( C > CurrentMA, 1, 0 );
GfxSetTextAlign( 3 );
GfxTextOut( "Bull", RightMargin, CurrentY );
GfxSetTextColor( colorWhite );
GfxTextOut( label_str + ": " + WriteVal( CurrentMA, 1.2 ), RightMargin - GapFromRight, CurrentY );
CurrentY = CurrentY + RowSpacing;
}
_SECTION_END();