This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Charting Financial Data


The following toolbox financial charting functions plot financial data and produce presentation-quality figures quickly and easily.


Bollinger band chart


Time series Bollinger band


Candlestick chart


Time series candle plot


Point and figure chart


High, low, open, close chart


Time series High-Low plot


Leading and lagging moving averages chart

These functions work with standard MATLAB® functions that draw axes, control appearance, and add labels and titles. The toolbox also provides a comprehensive set of charting functions that work with financial time series objects, see Chart Technical Indicators.

Here are two plotting examples: a high-low-close chart of sample IBM® stock price data, and a Bollinger band chart of the same data. These examples load data from an external file (ibm.dat), then call the functions using subsets of the data. The MATLAB variable ibm, which is created by loading ibm.dat, is a six-column matrix where each row is a trading day's data and where columns 2, 3, and 4 contain the high, low, and closing prices, respectively.

    Note   The data in ibm.dat is fictional and for illustrative use only.

High-Low-Close Chart

Load the data and set up matrix dimensions. load and size are standard MATLAB® functions.

load ibm.dat;
[ro, co] = size(ibm);

Open a figure window for the chart. Use the Financial Toolbox™ highlow function to plot high, low, and close prices for the last 50 trading days in the data file. Add labels and title, and set axes with standard MATLAB functions. Use the Financial Toolbox dateaxis function to provide dates for the x-axis ticks.

ylabel('Price ($)');
title('International Business Machines, 941231 - 950219');
axis([0 50 -inf inf]);

Bollinger Chart

The bolling function in Financial Toolbox™ software produces a Bollinger band chart using all the closing prices in an IBM® stock price matrix. A Bollinger band chart plots actual data along with three other bands of data. The upper band is two standard deviations above a moving average; the lower band is two standard deviations below that moving average; and the middle band is the moving average itself. This example uses a 15-day moving average. First, load the data using the ibm.dat data file and then execute the bolling function to plot the Bollinger bands.

load ibm.dat;
[ro, co] = size(ibm);
bolling(ibm(:,4), 15, 0);

axis([0 ro min(ibm(:,4)) max(ibm(:,4))]);
ylabel('Price ($)');
title(['International Business Machines']);
dateaxis('x', 6,'31-Dec-1994')

Specify the axes, labels, and titles. Use dateaxis to add the x-axis dates.

For help using MATLAB® plotting functions, see Create 2-D Graph and Customize Lines in the MATLAB documentation. See the MATLAB documentation for details on the axis, title, xlabel, and ylabel functions.

See Also

| | | | | | | | | | | | | | | | | | | | | | | | | |

Related Examples

Was this topic helpful?