在MATLAB命令行窗口输入help candle,查看该函数的使用格式,具体如下:
>> help candle
candle Candlestick chart.
candle(HI, LO, CL, OP)
candle(HI, LO, CL, OP, COLOR, DATES, DATEFORM)
Optional Inputs: COLOR, DATES, DATEFORM
Inputs:
HI - Column vector of high prices of a security.
LO - Column vector of low prices of a security.
CL - Column vector of closing prices of a security.
OP - Column vector of opening prices of a security.
Optional Inputs:
COLOR - Three element color vector, [R G B], or a string specifying the
color name. MATLAB supplies a default color if none is specified
or if it is empty. The default color differs depending on the
background color of the figure window. See COLORSPEC in the
MATLAB Reference Guide for color names.
DATES - Column vector of dates for user specified X-axis tick
labels.
DATEFORM - A scalar dictating the format of the date string tick labels.
See DATEAXIS for details on the date string formats.
See also bolling, highlow, movavg, pointfig.
candle 的参考页
名为 candle 的其他函数
candle函数使用有两种形式,具体如下:
(1)candle(HighPrices, LowPrices, ClosePrices, OpenPrices)
(2)candle(HighPrices, LowPrices, ClosePrices, OpenPrices,Color, Dates, Dateform)
candle函数使用主要输入介绍:第一个参数为输入数据的最高价;第二个参数为输入数据的最低价;第三个参数输入数据的收盘价;第四个参数输入数据的开盘价;第五个参数为绘图的颜色设置;第六个输入参数为绘图x轴的日期,第七个输入参数为输入日期的形式设置。
具体的candle函数使用如下:
clc,clear,close all % 清理命令区、清理工作区、关闭显示图形
warning off % 消除警告
feature jit off % 加速代码运行
load('data000001.mat')
openprice = data000001(1:40,1); % 开盘价
highprice = data000001(1:40,2); % 最高价
lowprice = data000001(1:40,3); % 最低价
closeprice = data000001(1:40,4); % 收盘价
Color = 'blue'; % 颜色
figure(1)
candle(highprice, lowprice, closeprice, openprice, Color);
grid on
axis tight
运行程序输出结果如图1-12所示。
sfd .jpg
(23.3 KB, 下载次数: 1)
2016-9-10 20:14 上传