What is Foolsaurus?

It's a glossary of investing terms edited and maintained by our analysts, writers and YOU, our Foolish community. Get Started Now!


How to Build an Automated Stock Trading System

Original post by Ben Taylor of Demand Media

Computer spreadsheets can be programmed to automatically trade stocks.

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).

Contents

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.


                   

Resources

References

About the Author

Ben Taylor has been writing since 2005 and has had work published by WEKU-FM and West Virginia Public Broadcasting both on air and online. Taylor holds a Master of Arts in English from Eastern Kentucky University and currently teaches composition and ESL there.

Photo Credits

  • Stockbyte/Stockbyte/Getty Images


Advertisement