开发者

Equivolume financial chart in Matlab

Can't find anywhere a Matlab code to plot Equivolume bars, does anybody knows how to? http://www.armsinside开发者_如何学Pythonr.com/education/armsonthemarket/equiv_chart.asp Thanks, Alberto


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜