Quick Start - Technical Analysis Toolbox™
Quick Start

This guide shows you how to quickly get your hands on some data and start your analysis.

Contents

Get Started

Get historical data

Historical data is easily downloaded and managed with the stockasset function. First, define EndDate (the final date of data), DateRange (the period over which data is retieved), and StockList (list of stock symbols). Then, use them as inputs to stockasset to get the data:

DateRange = '1year';
EndDate = datevec(now);
StockList = {'DIS', 'PG', 'JPM', 'XOM', 'JNJ','GE', 'MSFT', 'EXC','MON'};
MyStocks = stockasset(EndDate,DateRange,StockList);

The resulting structure MyStocks has the following properties:

MyStocks
MyStocks = 

  1x9 stockasset

  Properties:
    Symbol
    Name
    Exchange
    StartDate
    EndDate
    Dates
    Open
    High
    Low
    Close
    Volume
    AdjCl
    ShortData


To access the structure for a specific stock, use either a numeric index (MyStocks(6)), or the name of the stock (MyStocks('GE')):

MyStocks('GE')
ans = 

  stockasset

  Properties:
       Symbol: 'GE'
         Name: 'General Electric Company'
     Exchange: 'NYSE'
    StartDate: '2008-10-22'
      EndDate: '2009-10-22'
        Dates: {253x1 cell}
         Open: [253x1 double]
         High: [253x1 double]
          Low: [253x1 double]
        Close: [253x1 double]
       Volume: [253x1 double]
        AdjCl: [253x1 double]
    ShortData: [1x1 struct]

back to top


View Data

Create a table with details about the data with the stocktable function.

stocktable(MyStocks)

Produces the follwing table:

back to top


Chart data

Display data with the stockchart function. Customize chart settings such as chart type ('candle', 'ohlc', etc..), chart period ('3months', '1year', etc..), and more with chartoptions.

coptions = chartoptions('candle','3months');
figure(1)
clf
hgroup = stockchart(MyStocks('GE'),coptions);
xlabel(hgroup(end),'Date')
title('MyStocks: GE','fontweight','bold')

MyStockStructure

back to top


Add Indicators

Add indicators to the chart with the addindicator function.

accdist = MyStocks.accumdist;
mcd = MyStocks.macdiv(13,26,9);
stoch = MyStocks.fullstochosc;
iStock = 6;
hgroup = addindicator(hgroup,mcd{iStock},'centered','macd');
hgroup = addindicator(hgroup,accdist{iStock},'centered','A/D');
hgroup = addindicator(hgroup,stoch{iStock}(:,[3 4]),'banded',[20 80],'slowstoch');
xlabel(hgroup(end),'Date')
title(hgroup(1),'Adding Indicators','fontweight','bold')

back to top


Add Overlays

Add an overlay with addoverlay.

bbands = MyStocks.bollingerbands;
addoverlay(hgroup,bbands{iStock},'BBands(20,2)')

back to top


Multiple Charts

Create figures with mutliple charts.

coptions = chartoptions('candle','2months');
nrows = 2;
ncols = 4;
accdist = MyStocks.accumdist;
mcd = MyStocks.macdiv(13,26,9);
stoch = MyStocks.fullstochosc;
bbands = MyStocks.bollingerbands;
nStocks = length(MyStocks);
figure(1)
clf
for i = 1:(ncols*nrows)
  if i>nStocks, break, end
  hgroup = stockchart(MyStocks(i),coptions,'subplot',[nrows ncols i]);
  addoverlay(hgroup,bbands{i},'BBands')
  hgroup = addindicator(hgroup,mcd{i},'centered','macd');
  hgroup = addindicator(hgroup,accdist{i},'centered','A/D');
  hgroup = addindicator(hgroup,stoch{i}(:,[3 4]),'banded',[20 80],'slowstoch');
end
image

back to top


Plot Indicators

Use the indchart function to easily visualize indicator data. For example, look at the MACD:

fastperiod = 13;
slowperiod = 26;
trigperiod = 9;
mcd1 = MyStocks.macdiv(fastperiod, slowperiod, trigperiod);
figure(1)
clf
indchart(MyStocks,mcd1{1}, 'centered', '3months')
xlabel('Date')
title('MACD','fontweight','bold')

image

Or, look at the RSI:

period = 14;
rsi1 = MyStocks.rsindex(period);
figure(1)
clf
indchart(MyStocks,rsi1{1}, 'banded', [30 70], '3months')
xlabel('Date')
title('Relative Strength Index','fontweight','bold')

image

Custom Indicators

Create your own custom indicators. Note the use of brackets when not explicitly indexing MyStocks.

for i = 1:length(MyStocks)
   MyIndicator{i} = (MyStocks(i).Close - MyStocks(i).Open).*[MyStocks(i).Volume];
end
figure(1)
clf
indchart(MyStocks,MyIndicator{1}, 'centered', '3months')
xlabel('Date')
title('MyIndicator','fontweight','bold')

image