EquiVolume

This example implements an EquiVolume plot on a chart.  It not intended to update in real-time or to be persistent by redrawing itself when a chart repaints.  It will draw an EquiVolume image on a chart when the #9 button on the script editor is clicked.

Cut the script from this page and paste it into the ESPL Script editor.  Click on the #9 button on the script editor form to execute.

procedure EquiVolume;
var
  i,xPos,iVolRange,iBarIndex: integer;
  OO,HH,LL,CC,x,cl: integer;
begin
  if FindWindow(eChart)>0 then 
  begin
    i:=BarEnd;
    xPos:=IndexToX(BarEnd);
    iVolRange:=Highest(eVolume,BarEnd,BarEnd,iBarIndex,1,0);
    while (i>1) and (xPos>0) do
    begin
      OO:=PriceToY(Open(i));
      HH:=PriceToY(High(i));
      LL:=PriceToY(Low(i));
      CC:=PriceToY(Last(i));
      if (OO < CC) then cl:=clRed else cl:=clLime;
      SetPen(cl);
      SetBrush(cl);
      x:=20*Volume(i) div iVolRange; if x=0 then x:=1;
      Rectangle(xPos-x,HH,xPos,LL);
      SetPen(clBlack);
      MoveToLineTo(xPos-x div 2,CC,xPos,CC); {close}
      MoveToLineTo(xPos-x,OO,xPos-x div 2,OO); {open}
      xPos:=xPos-x-2;
      dec(i);
    end;
  end;
end; 

{**********Main Program**********}
begin
  if who=9 then EquiVolume;
end;

Notes:  i is the index for the bar records and initialize to start at the last bar on the chart.
xPos
is the horizontal plotting position.
iVolRange
is the largest volume for the bars in the chart's data set.
The while statement will loop until we run out of bars or until the plot reaches the left edge of the chart.
OO, HH, LL, CC
are the vertical plot positions on the chart for the prices from bar( i ).
Depending on the open vs. close relationship, choose a color for the bar.
x
will be the width of the bar up to a maximum of 20 pixels.
The Rectangle function draws the bar for height and width and colors the interior of the rectangle.
MoveToLineTo
draws a line in black for the close and open tick hashes.
Step the plot position to the left and decrement the index i.