Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top