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

4

3 回答 3

1

这是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

例子:

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

该函数可以使用补丁重写,但是这个工作得很好。

您可能可以使用Financial Toolbox 设置宽度中的CANDLE函数来修补对象,但我没有工具箱。

于 2010-09-24T00:09:03.683 回答
0

boxplot可能是创建自己的equivplot的起点。

于 2010-09-23T20:24:49.927 回答
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

关键是找到每个盒子的位置。由于 'positions' 定义了盒子的垂直中心线,所以两个盒子之间的距离应该是 (volumes(i-1) + volumes(i))/2

于 2016-08-24T08:12:28.010 回答