Login Register FREE Account

Getting Started

This guide gives an overview of the steps necessary to import stock data into the TA Developer toolbox in order to be able to backtest a trading strategy in MATLAB. It describes how to download stock data from Yahoo! Finance and save the data to CSV files. Yahoo! Finance is used as an example in this article, but any stock data in CSV format can be used. It is shown how to import CSV data into the TA Developer toolbox using the CSV setup wizard. The data can be displayed in form of a candle stick chart and technical indicators can be applied by drap&drop.

 
Requirements
  • MATLAB
  • Microsoft .NET 4.0 or higher
  • TA Developer Toolbox

It is assumed that you have read the following article:

 

Getting Data From Yahoo! Finance

We will start by downloading the data of 11 technology stocks from Yahoo! Finance. We use the script called "getyahoo10.m" from the MATLAB file exchange (Yahoo Data Download Script) to download 10 years worth of stock data for these companies. Once you downloaded the script, please execute it as shown in the following example. For more information about this script please type 'help getyahoo10' into the command prompt.

>> techStocks='AAPL,ALTR,AMT,AMZN,CHU,DTV,GOOG,IBM,INTU,SAP,VZ';
>> getyahoo10(techStocks, 'C:\StockData');
 

 

Importing CSV Data

Type "tadeveloper" into the command prompt to start the TA Developer graphical user interface.

>> tadeveloper

The user interface consists of the main charting area and several toolbox windows. One of the toolbox windows is the Symbols box located on the top left corner of the screen. In order to import CSV data into the toolbox, open the Data Source Manager by selecting the link called 'Data Sources' located at the bottom of the Symbols window.

ta developer datasource

 

Click the Add button in the Data Manager to add a new data source.

 

Follow the CSV wizard steps to setup the data source:

1. Enter a Watchlist Name e.g. TechnologyStocks

2. Select the directory in which you saved the data files earlier e.g. C:\StockData.

3. Select the scale of the data. Choose "Daily" since we downloaded daily data from Yahoo! Finance.

4. Choose the data format. Enter "yyyy-MM-dd" in the text box labelled Date Format. The other boxed can remain with it's prefilled values. (See screenshot below) Then click on the 'Next' button.

5. If all the information has been entered correctly in the previous screen, a confirmation screen will be displayed showing Open, High, Low, Close and Volume information. Click "Finish" to create the data source.

 

matlab trading

 

 

Click "Close" to close the data manager. The newly created watchlist should now be available in the symbols box. Doubleclick on one of the symbol names to see a candle stick chart of the imported data. The chart area allows scrolling through and zooming in and out of the data.

 

 

 

 

 

Applying Technical Indicators per Drag&Drop

The TA Developer toolbox has a number of built in technical indicators. These indicators can be applied to the chart area by drag&drop. Simply select one of the technical indicators from the indicators window (window on the bottom left) and drag the indicator onto the charting area. A dialog will pop up asking about indicator parameters like the lookback period for the simple moving average in the example below. In addition the line style, line color, and line width can be selected.

 

After clicking the Ok button, the indicator should be drawn in the charting area like shown in the screenshot below. To remove the indicator again, right click on the indicator line and select 'Delete Indicator' from the context menu.

 

 

 

Next Steps

This article showed you how to import CSV stock data using the TA Developer toolbox. In addition, it was demonstrated how to visualize and apply technical indicators to the imported data. Importing data is the first step necessary to create an algorithmic trading strategy in MATLAB. The following article will describe how to use the data in a trading strategy backtest and optimization.

Creating an Algo Trading Strategy in MATLAB