Herman,
Perhaps if you make 4 params, 2 for x axis, and 2
for y axis for -- scaling m + offset b: mx+b.
Then adjust the parameters visually in real time
until they align. Then look at the values and see if it dawns what
the issue is.
Best regards,
Dennis
On Mar 1, 2008, at 5:37 PM, Herman
wrote:
I just can't manage to line up pixel plots with
price charts. I copy my testing code below. I need is to line up
horizontal and vertical lines produced with normal charting techniques,
with lines produced using GFX functions. Any help would be much
appreciated!!!
Herman
function GetPixelY(
value )
{
global MinY, MaxY;
return Status( "pxheight" ) * ( value - MinY
) / ( MaxY - MinY );
}
function GetPixelX(
value )
{
global MinX, MaxX;
return Status( "pxwidth" ) * ( value - MinX
) / ( MaxX - MinX );
}
function gfxPlotHLine( YPixels, Color )
{
global pxwidth;
GfxSelectPen( Color ) ;
GfxMoveTo( 0, YPixels
);
GfxLineTo( pxwidth, YPixels
);
}
function gfxPlotVLine( VPixels, Color )
{
global pxheight;
GfxSelectPen( Color ) ;
GfxMoveTo( 0, VPixels
);
GfxLineTo( pxHeight, VPixels
);
}
GraphXSpace =
0;
Plot( C, "", 1, 128 );
GfxSetOverlayMode( 1
);
GfxSetBkMode( 1
);
pxwidth = Status( "pxwidth" );
pxheight = Status( "pxheight" );
Miny = Status( "axisminy" );
Maxy = Status( "axismaxy" );
// Plot selected Low in price and in
pixels
Lowprice = SelectedValue( Low );
Plot(
Lowprice, "", 2,
1 );
LowPixels = GetPixelY( Lowprice );
gfxPlotHLine( LowPixels, colorRed );
// plot vertical line on selected bar in
GFX
CumBar = Cum( Status( "barVisible" ) );
NumBarsVisible = LastValue( CumBar );
PixelsPerbar = pxWidth / SelectedValue( NumBarsVisible
);
BarPixels = SelectedValue( NumBarsVisible ) *
PixelsPerbar;
gfxPlotVLine( BarPixels, colorBrightGreen );
Title = "\n" +
" LowPixels: " + NumToStr( LowPixels, 1.0, False ) + "\n" +
"Pixels/Bar: " + NumToStr( PixelsPerbar, 1.0, False ) + "\n" +
" BarPixels: " + NumToStr( BarPixels, 1.0, False );
|