How to Build an Automated Stock Trading System

How to Build an Automated Stock Trading System
••• Stockbyte/Stockbyte/Getty Images

An automated stock stock trading system can improve the accuracy and performance of your investments -- and will also save you time and reduce the risk of operator error. Using macros and computer programming language, a computer spreadsheet such as Microsoft Excel or Apple iWork Numbers can be programmed to transact stock trades on your behalf when the stock -- or other security -- meets certain criteria. Macros can automatically download a stock's performance data and execute trades using the programming language Visual Basic for Applications (VBA).

Downloading Data

A computer spreadsheet can import data from the Internet by connecting to a website, such as Yahoo! Finance or Google Finance, that streams stock quotes, opening and closing prices and trading volume. After creating a spreadsheet file, navigate to your spreadsheet program's data tab and select "From Web," which will open a miniature browser, according to the ConnectCode website. Navigate to a specific stock's historical chart, then set time constraints. Your spreadsheet program will indicate which data can be downloaded -- select the table and give the spreadsheet authority to download the data to your computer.

Automating Downloads Using Macros

A macro is a series of commands that utilizes VBA to automate a task you frequently perform. Enable the "Developer" tab on your spreadsheet file, then create a macro that automatically downloads stock data from the Internet. Programming macros is tricky, so consider downloading pre-programmed macros from the firm which made your spreadsheet, such as Microsoft, Apple or an independent firm. To customize your macro to download stock data, set parameters such as the stock's ticker symbol, start and end dates and the site from which the macro will download data.

Interpreting Stock Data

A macro can interpret the data your spreadsheet automatically downloads. Using your parameters for buying and selling a specific stock, a macro can identify when a specific stock meets your conditions for a trade, as well as other performance indicators to inform your trading decisions. Program a new macro to interpret the stock data in your spreadsheet, setting constraints based upon the stock's price, trends in price movement and its trading volume, for example.

Automating Trades

When your data-interpreting macro indicates that a stock has met your trading requirements, program one additional macro to communicate the trade to your online brokerage account. Macros execute commands based on events, such as a stock consistently trading at a certain volume for a number of consecutive days. To execute a trade, provide the macro with your brokerage account information, including the source of funds to execute the trade, the number of shares to be traded and any other information specifically required by your broker. For a price, some firms offer automated stock trading systems with pre-programmed macros.