//Delikatnie przrobiłem - przeklej cały tekst
ChartType = ParamList ( "Chart Type", "CandleVolume,EquiVolume" );
Plot( C, "", 39, styleBar | styleNoDraw );
Maxy = Status( "axismaxy" );
Miny = Status ( "axisminy" );
pxchartheight = Status ( "pxchartheight" );
pxchartbottom = Status( "pxchartbottom" );
pxchartwidth = Status ( "pxchartwidth" );
pxchartleft = Status( "pxchartleft" );
fvb = Status ( "firstvisiblebar" );
Lvb = Status ( "lastvisiblebar" );
function LowestVisibleValue( array )
{
bv = Status("barvisible");
ll = 1e8;
for( i = 0; i < BarCount; i++ )
{
if( bv[ i ] AND array[ i ] < ll ) ll = array[ i ];
}
return ll;
}
function yConvert( Value )
{
return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight / (
Maxy - Miny ) );
}
MinVolume = LowestVisibleValue( Volume );
MinVolume = Max ( Minvolume, 1 );
//printf ( "Min Visibe Bar volume = %.f\n", Minvolume );
sigma = 0 ;
for ( i = BarCount - 1 ; i > fvb - 1 ; i -- )
{
ratio = Volume[i] / MinVolume;
sigma += ratio;
}
GfxSelectPen( colorBlack );
Space = 1; // space between candles
visiblebars = Lvb - fvb + 1;
totalspace = Visiblebars * space;
unitpx = ( pxchartwidth - totalSpace ) / sigma; // pixel
LastbarRatio = Volume [BarCount -1] / MinVolume;
delta = unitpx * Lastbarratio / 2;
start = pxchartleft + ( BarCount - fvb - 1 ) * pxchartwidth / Visiblebars +
delta;
Chg = C - O;
for ( i = BarCount - 1 ; i >= fvb && start > 0 ; i -- )
{
ratio = Volume[i] / MinVolume;
width = unitpx * ratio ;
width = Min ( width , pxchartwidth / 5 ); // limit max bar width in pixel to chartwidh/5
if ( ChartType == "CandleVolume" )
{
x = start - width / 2;
}
y1 = yConvert ( High[i] );
y2 = yConvert ( Low[i] );
if ( ChartType == "CandleVolume" )
{
GfxMoveTo ( x, y1 );
GfxLineTo( x, y2 );
}
x1 = start - width;
x2 = start ;
if ( ChartType == "CandleVolume" )
{
y1 = yConvert ( Open[i] );
y2 = yConvert ( Close[i] );
}
fillcolor = IIf ( Chg [i] > 0 , colorGreen, colorRed );
GfxSelectSolidBrush( fillcolor );
Hgt = y2 - y1;
if ( Hgt == 0 )
Hgt = 1;
y2 = y1 + Hgt;
GfxRectangle( x1, y1, x2, y2 );
start = x1 - Space;
//printf ( "\n%.f\t %.f px" , i, hgt );
}
Title = Charttype;
RequestTimedRefresh( 1 );