Australian (ASX) Stock Market Forum

AmiBroker EquiVolume code

Joined
20 October 2006
Posts
9
Reactions
0
Hi,

I am an AmiBroker user. Refer to the attachment. I am confused and I hope I don't confuse you. I have the coding for the above chart. Unfortunately I am unable to obtain the code for the bottom chart. I would appreciate it very much if anyone can forward the below chart code to me. The coding for the above chart can be obtained from the AB web site. The EquiVolume indicator was written by a Mr.Aron Pipa.

Thank you for reading,
Ian
 

Attachments

  • 04 EquiVolume.png
    04 EquiVolume.png
    26.5 KB · Views: 143
Hi,

I am an AmiBroker user. Refer to the attachment. I am confused and I hope I don't confuse you. I have the coding for the above chart. Unfortunately I am unable to obtain the code for the bottom chart. I would appreciate it very much if anyone can forward the below chart code to me. The coding for the above chart can be obtained from the AB web site. The EquiVolume indicator was written by a Mr.Aron Pipa.

Thank you for reading,
Ian

Check your last post, from yesterday...rnr replied with the link to the code.
 
Hi,

Thanks for that. I am aware that I was unable to clarify what I was after. I already have the code to the top chart. I have tried unsuccessfully to replicate the above chart, hoping that it would just display Volume, which is displayed in the bottom pane of my attachment.

Also the top pane is made up of "OHLC & Volume." The lower pane excludes the OHLC which only displays the volume with the appropriate widths.

Can someone have a go, I guess by using the top coding and extracting just the volume.

Thanks,
Ian
 

Attachments

  • ANZ.jpg
    ANZ.jpg
    167.4 KB · Views: 26
Hi,

Thanks for that. I am aware that I was unable to clarify what I was after. I already have the code to the top chart. I have tried unsuccessfully to replicate the above chart, hoping that it would just display Volume, which is displayed in the bottom pane of my attachment.

Also the top pane is made up of "OHLC & Volume." The lower pane excludes the OHLC which only displays the volume with the appropriate widths.

Can someone have a go, I guess by using the top coding and extracting just the volume.

Thanks,
Ian

Hey guys still no response, waiting anxiously.
Ian
 
Hey guys still no response, waiting anxiously.
Ian

Hi Ian, I'm no coder but i've been an Amibroker user for nearly ten years and for the life of me can't figure out why you would want a variable width volume histogram only....or have i got this wrong?
 
Hi Ian, I'm no coder but i've been an Amibroker user for nearly ten years and for the life of me can't figure out why you would want a variable width volume histogram only....or have i got this wrong?

He wants his chart to look the same as the picture he attached. The posted link to the equivolume formula only gives you the variable width price chart. So now he's looking to make the volume histogram widths match the price chart widths so that they line up properly.
 
He wants his chart to look the same as the picture he attached. The posted link to the equivolume formula only gives you the variable width price chart. So now he's looking to make the volume histogram widths match the price chart widths so that they line up properly.

Oh sorry, i thought rnr provided that in the first thread he posted in...
 
He wants his chart to look the same as the picture he attached. The posted link to the equivolume formula only gives you the variable width price chart. So now he's looking to make the volume histogram widths match the price chart widths so that they line up properly.

Thanks buddy, your comment has cleared up what is required. I am posting the code used to generate the Equivolume chart, hope some one can extract just the Volume and not the other elements such as, OHLC.

Code:
// Aron Pipa
// January 2014
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 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( colorWhite );

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 , colorWhite, 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 );
 

Attachments

  • 04 EquiVolume.png
    04 EquiVolume.png
    26.5 KB · Views: 108
  • ANZ.jpg
    ANZ.jpg
    167.4 KB · Views: 24
You know there is an AB yahoo group full of techie propeller heads just waiting for questions like this.

It's referenced on the AB home page.

Go on make their day.

And then there is the AB support channel, they provide fantastic, and I mean fantastic, service.

Here, there may be a few people who could answer, but it's not the best place to throw your AB fishing line.
 
this bit of code draws the vertical line....

y1 = yConvert ( High );
y2 = yConvert ( Low );
if ( ChartType == "CandleVolume" )
{
GfxMoveTo ( x, y1 );
GfxLineTo( x, y2 );
}

the code below draws the rectangle between the open and close....

x1 = start - width;
x2 = start ;

if ( ChartType == "CandleVolume" )
{
y1 = yConvert ( Open );
y2 = yConvert ( Close );
}

fillcolor = IIf ( Chg > 0 , colorWhite, colorRed );
GfxSelectSolidBrush( fillcolor );
Hgt = y2 - y1;
if ( Hgt == 0 )
Hgt = 1;

y2 = y1 + Hgt;
GfxRectangle( x1, y1, x2, y2 );

the only real difference between a price bar a volume is 4 distinct values vs 1 value.

Or the volume bar (visually, in price terms) is when Open = Low, and Close = High.

And if the open is 0 (zero), and High is Volume then you have your chart. So you could just replaces references to Open and Low with 0 and Close and High with Volume????
 
this bit of code draws the vertical line....

y1 = yConvert ( High );
y2 = yConvert ( Low );
if ( ChartType == "CandleVolume" )
{
GfxMoveTo ( x, y1 );
GfxLineTo( x, y2 );
}

the code below draws the rectangle between the open and close....

x1 = start - width;
x2 = start ;

if ( ChartType == "CandleVolume" )
{
y1 = yConvert ( Open );
y2 = yConvert ( Close );
}

fillcolor = IIf ( Chg > 0 , colorWhite, colorRed );
GfxSelectSolidBrush( fillcolor );
Hgt = y2 - y1;
if ( Hgt == 0 )
Hgt = 1;

y2 = y1 + Hgt;
GfxRectangle( x1, y1, x2, y2 );

the only real difference between a price bar a volume is 4 distinct values vs 1 value.

Or the volume bar (visually, in price terms) is when Open = Low, and Close = High.

And if the open is 0 (zero), and High is Volume then you have your chart. So you could just replaces references to Open and Low with 0 and Close and High with Volume????


Thanks for the advise, I am aware that this will be easy for you, but guess what, I tried this and look what I got. She's upside down and nothing like what I would like. If possible, can you reconstruct the code and attach it.

Sorry to be a nuisance,
Ian
 

Attachments

  • Volume.png
    Volume.png
    33.1 KB · Views: 23
Thanks for the advise, I am aware that this will be easy for you, but guess what, I tried this and look what I got. She's upside down and nothing like what I would like. If possible, can you reconstruct the code and attach it.

Sorry to be a nuisance,
Ian

OK. Without seeing the corresponding chart, bit hard to know whether it was just upside down or worse. Also, I am unsure exactly what changes you made. I know what I had said.

Also note that I am a software dev. full time, so the Amibroker code is relatively simple for me to read to work out. Otherwise I do not use Amibroker. But I will help - just check your private mail box.
 
OK. Without seeing the corresponding chart, bit hard to know whether it was just upside down or worse. Also, I am unsure exactly what changes you made. I know what I had said.

Also note that I am a software dev. full time, so the Amibroker code is relatively simple for me to read to work out. Otherwise I do not use Amibroker. But I will help - just check your private mail box.

Hi there,
Hello,

would appreciate if someone can code shapes and text above selected boxes. I am enclosing a sample chart and the respective code for the main chart,

Thanks in advance,
IB

Code:
_SECTION_BEGIN("Start");

	ChartType	=ParamToggle("Chart Type"," EquiVolume | CandleVolume",1);
	UpColor		=ParamColor("Up Close",colorLightGrey);
	DnColor		=ParamColor("Dn Close",colorGrey50);

	Plot(Close,"",39,styleBar|styleNoDraw);

	MinVolume	=LowestVisibleValue( Volume );
	MaxVolume	=HighestVisibleValue( Volume );
	Chg		= C > Ref(Close,-1);

_SECTION_END();



	Maxy			=Status( "axismaxy" );
	Miny			=Status ( "axisminy" );
	pxchartheight	=Status ( "pxchartheight" );
	pxchartbottom	=Status( "pxchartbottom" );
	pxchartwidth	=Status ( "pxchartwidth" );
	pxchartleft	=Status( "pxchartleft" );

	fvb				=Status ( "firstvisiblebar" );
	Lvb				=Status ( "lastvisiblebar" );
	Space			= Param("Bar-Spsce",1,-10,5,1);

function yConvert( Value )
{
    return  pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight / (Maxy - Miny ) );
}
	MinVolume	=LowestVisibleValue( Volume );
	MinVolume	=Max ( Minvolume, 1 );

	sigma		=0 ;

for ( i = BarCount - 1 ; i > fvb - 1  ; i -- )
{
    ratio		=Volume[i] /  MinVolume;
    sigma		+=ratio;
}


	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;

//--------------------------------------------------------------------------------------------

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 == 0 )
    {
	x	=start - (width / 2);
    }

    y1	=yConvert ( High[i] );
    y2	=yConvert ( Low[i] );

if ( ChartType == 0 )
    {
        GfxMoveTo(x,y1);
        GfxLineTo(x,y2);
    }

    x1	=start - width;
    x2	=start ;

if ( ChartType == 0 )
    {
	y1	=yConvert ( Open[i] );
	y2	=yConvert ( Close[i] );
    }
//--------------------------------------------------------------------------------------------

	PenColor		=IIf(Chg[i] > 0,UpColor,DnColor);
	GfxSelectPen( colorBlack,1 );
	GfxSelectSolidBrush( PenColor);

//--------------------------------------------------------------------------------------------
	Hgt	=(y2 - y1);
	if(Hgt == 0)
	Hgt			=1;

    y2	=(y1 + Hgt);
	GfxRoundRect(x1,y1,x2,y2,3,3);

    start	=x1 - Space;
}

RequestTimedRefresh( 1 );


_SECTION_BEGIN("HEading");

	Change = Close-Ref(Close,-1);

	BrushCol	=ParamColor("BrushColor",colorDarkGrey);
	TxtCol		=ParamColor("TxtColor",colorWhite);

	YC = TimeFrameGetPrice( "C", inDaily, -1 );
	DD = Prec( C - YC, 2 );
	xx = Prec( ( DD / YC ) * 100, 2 );

	GfxSelectSolidBrush( BrushCol );
	GfxRectangle(1,25,1640,1);

	GfxSetTextAlign(6);
	GfxSetBkMode(0);
	GfxSetTextColor(TxtCol);
	GfxSelectFont( "Futura",8,700,False );

	GfxTextOut(
	Name()+" ..... "+
	Interval(2)+
	" ..... Date: "+Date()+
	" ..... Open:  "+WriteVal(Open,5.2)+
	" ..... Hi:  "+WriteVal(High,5.2)+
	" ..... Lo:  "+WriteVal(Low,5.2)+   
	" ..... Close:  "+WriteVal(Close,2.2)+
	" ..... Change:  " + WriteVal(DD,5.2)+
	" ..... " + xx + "%",Status("pxwidth")/2,Status("pxheight")/125);

_SECTION_END();
 

Attachments

  • ICICIBANK.jpg
    ICICIBANK.jpg
    101.3 KB · Views: 41
Top