Matlab 中的 Equivolume 财务图表

发布于 2024-09-25 05:34:27 字数 240 浏览 3 评论 0原文

找不到任何地方可以绘制 Equivolume 条形图的 Matlab 代码,有人知道如何做吗? http://www.armsinsider.com/education/armsonthemarket/equiv_chart.asp 谢谢,阿尔贝托

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痴情 2024-10-02 05:34:27

这是一个基于箱线图的简单函数,如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 函数来修补对象,但我没有工具箱。

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.

烟织青萝梦 2024-10-02 05:34:27

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

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

别再吹冷风 2024-10-02 05:34:27
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

关键是找到每个盒子的位置。由于“位置”定义了盒子的垂直中心线,因此两个盒子之间的距离应该是(体积(i-1)+体积(i))/ 2

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文