The following toolbox financial charting functions plot financial data and produce presentation-quality figures quickly and easily.
Bollinger band chart
Time series Bollinger band
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 (
then call the functions using subsets of the data. The MATLAB variable
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.
The data in
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
to provide dates for the x-axis ticks.
xlabel(''); ylabel('Price ($)'); title('International Business Machines, 941231 - 950219'); axis([0 50 -inf inf]); dateaxis('x',6,'31-Dec-1994')
MATLAB produces a figure like this. The plotted data and axes you see may differ. Viewed online, the high-low-close bars are blue.
in Financial Toolbox software produces a Bollinger band chart
using all the closing prices in the same 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.
Assuming the previous IBM data is still loaded, execute the function.
bolling(ibm(:,4), 15, 0);
Specify the axes, labels, and titles. Again, use
dateaxis to add the x-axis
axis([0 ro min(ibm(:,4)) max(ibm(:,4))]); ylabel('Price ($)'); title(['International Business Machines']); dateaxis('x', 6,'31-Dec-1994')
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