FUNCTION |
The function allows to switch co-ordinate system for low-level gfx functions:
- mode = 0 - the default screen pixel mode, where both X and Y are expressed in pixels
- mode = 1 - bar / price mode 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.
- mode = 2 - X coordinate is pixel, Y coordinate is price (new in 6.20)
- mode = 3 - X coordinate is bar index, Y is pixel (new in 6.20)
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 ] );
} |