0

Can't find anywhere a Matlab code to plot Equivolume bars, does anybody knows how to? http://www.armsinsider.com/education/armsonthemarket/equiv_chart.asp Thanks, Alberto

Alberto acepsut
  • 1,972
  • 10
  • 41
  • 87

3 Answers3

1

Here is a simple function based on boxplot as suggested by zellus:

function hh = equivolumechart(x,w)
% EQUIVOLUMECHART - simple equivolume chart based on barplot
% x - 2xn high/low values, w - volume (box width)

h = boxplot(x,'width',w);
% make median unvisible
for ii=1:size(h,2)
    set(h(6,ii),'visible','off')
end
if nargout>0, hh = h; end 

end

Example:

a = randi(10,2,10);
w = randi(10,1,10)/10;
equivolumechart(a,w)

The function can be rewritten using patches, but this one works pretty well.

You probably can use CANDLE function from Financial Toolbox setting width to patch objects, but I don't have the toolbox.

Community
  • 1
  • 1
yuk
  • 19,098
  • 13
  • 68
  • 99
0

boxplot might be a starting point to create your own equivplot.

zellus
  • 9,617
  • 5
  • 39
  • 56
0
function [ ] = equivolumechart(highs, lows, volumes)
    % calculate pos of each box
    pos = zeros(length(volumes), 1);    
    for i=2:length(volumes)
        pos(i) = pos(i-1) + (volumes(i-1) + volumes(i))/2;
    end

    h = boxplot([highs'; lows'], 'width', volumes', 'positions', pos);
end

The key is to find the position of each box. Since 'positions' defines the vertical center line of boxes, the distance between two boxes should be (volumes(i-1) + volumes(i))/2

jun.wu
  • 104
  • 3