Search code examples
matlabplotchartsfinancial

Equivolume financial chart in Matlab


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


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.