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™
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
function to provide dates for the x-axis ticks.
figure; highlow(ibm(ro-50:ro,2),ibm(ro-50:ro,3),ibm(ro-50:ro,4),,'b'); xlabel(''); ylabel('Price ($)'); title('International Business Machines, 941231 - 950219'); axis([0 50 -inf inf]); dateaxis('x',6,'31-Dec-1994')
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
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
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