GfxSetCoordsMode
- set low-level graphics co-ordinate mode

Low-level graphics
(AFL 2.80)


SYNTAX GfxSetCoordsMode( mode )
RETURNS NOTHING
FUNCTION The function allows to switch co-ordinate system for low-level gfx functions from sceen pixel (mode = 0) - the default, to bar / price mode (mode = 1 ) where X is expressed in bar index and Y is expressed in price. This new mode allows way easier overlays on top of existing charts without need to do conversion between bars/price pixels and without any extra refresh normally required in old versions when Y scale changed. The function 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.
EXAMPLE // The sample shows how using GfxSetCoordsMode( 1 )
// results in
// a) easier coding of overlay charts that plot on top of built-in charts (no need to convert from bar/price to pixels)
// b) perfect matching between built-in Plot() and Gfx positioning
Plot( C, "Price", colorDefault, styleLine );
GfxSetOverlayMode( 1 );
GfxSetCoordsMode( 1 ); // bar/price mode (instead of pixel)

GfxSelectSolidBrush( colorRed );
GfxSelectPen( colorRed );

boxheight = 0.01 * ( HighestVisibleValue( C ) - LowestVisibleValue( C ) );

bi = BarIndex();

start = FirstVisibleValue( bi );
end = LastVisibleValue( bi );

for ( i = start; i <= end; i++ )
{
     Cl = Close[ i ];
     Op = Open[ i ];

     Color = IIf( Cl > Op, colorGreen, colorRed );
     GfxSelectPen( Color );
     GfxSelectSolidBrush( Color );

     bodyup = Max( Op, Cl );
     bodydn = Min( Op, Cl );

     GfxEllipse( i - 0.4, bodyup, i + 0.4, bodydn );

     GfxMoveTo( i, H[ i ] );
     GfxLineTo( i, bodyup );
     GfxMoveTo( i, bodydn );
     GfxLineTo( i, L[ i ] );
}
SEE ALSO

References:

The GfxSetCoordsMode function is used in the following formulas in AFL on-line library:

More information:

Updated on-line reference