Computer Methods for better Stock Market Research

Murty Rompalli

Computer programs and methods for analyzing stocks meeting user specified criteria are discussed in this paper. A new computer program was written in Perl and its use discussed. Some ideas to automate process of screening stocks are presented. Although this paper discusses computer programs, it is presented in a way that benefits both traders as well as computer experts who trade stocks. Although most methods are presented for Technical Analysis, some ideas are presented at the end for researching stocks using Fundamental Analysis.


Traders and Investors research stock market data frequently to identify stocks meeting a set of criteria. The stocks so identified are potential investments. Some users make use of technical indicators (Technical Analysis) while others look at company fundamentals such as Book Value (Fundamental Analysis). Some users use both Fundamental and Technical Analysis methods. Lets not talk about those users who buy stocks without doing any research.

Some of the most commonly used Technical Analysis tools are: TC2007, MetaStock, TradeStation [1-3]. Some Fundamental Analysis is possible using TC2007 but most users refer to company information or tools such as MetaMarket Plus for Fundamental Analysis [4] or use online services at web sites such as ValueLine and ValueInvestorsClub [5,6].

This document assumes that:

  1. You are a trader, investor or a computer expert with knowledge of stock market
  2. You use a computer (running Windows NT or above operating system) with Internet Explorer for stock market research and that you have an internet connection
  3. You use TC2007 Stocks version End-of-Day (version 4.0 or above)
  4. You use MetaStock version 8.0 or above configured to use End-of-Day data from TC2007. (i.e., Any one of MetaStock End-of-Day, Realtime eSignal, Realtime Qcharts with End-of-Day data from TC2007)
  5. You have a basic knowledge of common terms such as P/E ratio, PEG number etc. If this is not the case, please read basics of stock market at a good Stock Market Education web site. I recommend reading such information at Investopedia [7].
  6. This document applies to trading securities only (buy long or sell short) but not for any other investments such as options, futures, mutual funds etc.

Technical Analysis

Lets say, you worked hard to develop trading systems that best fit your style and back tested them with MetaStock Enhanced System Tester or some another method. Then most likely, you want to run explorations corresponding to your favorite trading systems periodically in the MetaStock Explorer tool. After your exploring the stock market is complete, you can look at the results report of each exploration you ran.

Some stocks meet more than one of your trading systems. That is, you will find some stocks in more than one exploration report. Wouldn't it be nice to find out which stocks met more than one of the selected trading systems and what those systems are?

Lets say, you select 10 explorations in MetaStock Explorer tool and run those explorations every time you want to research the stock market. It is not practical to print out reports of all ten explorations and manually track how many exploration reports does a particular stock shows up in.

If we can somehow automate the process of findng out which stocks show up in which exploration reports, it will save a lot of time and manual effort. Equis International, the company that makes MetaStock software program, also sells Developer Kit for software developers who can write add-on programs to automate as described above [8]. I would like to show a simpler method using a Macro Recorder program instead of Developer Kit.

Macro Recorder

A macro recorder is an external program that records user's keyboard and mouse movement actions during a period set by user. In a layman's language, its like VCR that records sound and motion on Video Casette and then it can be replayed any number of times.

I recommend use of a Macro Recorder to record frequent tasks such as running MetaStock Downloader (to convert TC2007 EOD data to MetaStock EOD data), running Explorer tool in MetaStock or even to save/print selected exploration reports after running Explorer tool. Once a task is recorded, user can simply run that particular action (called macro) and leave the computer alone. The Macro Recorder will then replay it, i.e., trigger the keyboard and mouse events exactly as you typed but without your help.

There are a lot of Macro Recorder programs available on the Internet. However, most of them are just not upto the job. Some do not record certain keyboard events such Control key or SHIFT key and others dont record highlight or copy actions. Some record well but cannot replay at the recorded speed. Remember, it is important to replay very slowly or better yet, at the recorded speed. Otherwise, replay will be too fast for the computer to respond.

Automate and EZ Macros proved to be working flawlessly in the case of automating MetaStock related tasks [9-10]. Automate is unnecessarily bulky with a lot of features ordinary traders dont use. I recommend EZ Macros for automating MetaStock or TC2007 tasks. One feature about EZ Macros that I like is that you can make a self-executable program out of a single recorded macro. American Systems, creator of EZ Macros, also makes a free scheduler program called EZ Scheduler [10]. This free program can be used to schedule various macros and run them at designated times automatically.

Launch MetaStock and then EZ Macros. Create a macro for, say, running MetaStock Explorer tool with a few explorations. After that, everytime you want to run Explorer tool:

  1. Launch MetaStock
  2. Launch EZ Macros
  3. Hide EZ Macros by clicking on the x on the top right corner (this closes EZ Macros window but it stays active in the system tray)
  4. Click on EZ Macros icon in the system tray to see the list of your macros.
  5. Then highlight your macro and click Run.

Here are some tips for recording good macros:

  1. Try to use keyboard keys wherever you can. Minimum mouse usage during macro creation is recommended.
  2. Remember to enlarge the program window to maximum size first before you send any more keys in the macro. For example, to create macro for MetaStock task, start recording and first send the keys ALT+SPACE, x (to maximize program window to full screen) before doing anything.
  3. Use HOME key to go to top of list of explorations in Explorer tool. Similarly, END key to go to the last exploration.
  4. When typing filenames in "File Save As" box, type filename followed by a space. This is to get around the annoying windows filename guessing feature that will confuse the Macro when replayed
  5. Always replay the macro at the original recorded speed.

There was a time when MetaStock macros were available for its DOS version, although those macros were for simple tasks such as switching between charts. I do not think there is a MetaStock macro feature with our Windows versions today that eliminates the need for an external Macro Recorder program such EZ Macros. Integrated portfolio management and macro features, if and when introduced in the future, definitely make MetaStock more powerful.

MetaStock Explorer Tool

Now that we know the power of EZ Macros macro recorder, lets put it to use. First we have to install it. Then create a macro for something useful. We can create macros for running Explorer tool. We can also create another macro for saving reports of all explorations run in the Explorer tool. If we create a macro for saving exploration reports into text files, we can then save them for archiving or print them for reviewing. Or, we can somehow combine all the individual text files (created by saving the exploration results to different text files) into a single text file. To do that, we need a computer program. When we have such a computer program, we can obtain a single report file containing reports of all explorations run in the Explorer tool. We can process that single report file to find out, say, which stock shows up in which exploration reports.

Analyzing exploration reports

Assume that we ran MetaStock explorer tool and saved all the exploration reports into various text files. Then my program, Murty's Scanner, can be used to combine all those text files into a single text file. Further, that single text file can be analyzed to generate an output file showing stocks and explorations seperately. Another output file with just stocks or stocks that repeated can be created. This text file can be directly fed to TC2007 for further analysis.

More detailed instructions on how to use my mscanner program are available on its release page at http://www.murty.net/mscanner/ [11]. I will only list here sample uses of outputs generated by mscanner.

mscanner sample output
sample use
mscanner\BUY\WedFeb122244272003_TueFeb112130202003.txt Contains stocks with repeated buy signals. Load into TC2007 and analyze all the stocks in TC2007
mscanner\BUY\WedFeb122244272003.txt Contains stocks with buy signals. Load into TC2007 and analyze all the stocks in TC2007
mscanner\BUY\TueFeb112130202003.htm Contains stocks with buy signals. Open in Internet Explorer or Netscape and analyze on Yahoo Finance web site.
mscanner\SELL\TueFeb112130202003.htm Contains stocks with sell short signals. Open in Internet Explorer or Netscape and analyze on Yahoo Finance web site.
mscanner\SELL\WedFeb122244272003_TueFeb112130202003.txt Contains stocks with repeated sell short signals. Load into TC2007 and analyze all the stocks in TC2007

The mscanner program also creates a single text file called exp.txt containing reports of all selected explorations. This file can be printed and analyzed as well.

Ideas for Screening Stocks

Investors and traders most likely use some sort of online stock screener at least once in a while. Stock screeners are screening programs that generate a list of stocks meeting the screening conditions. Some examples of online stock screeners are: Yahoo Finance Stock Screener, Multexinvestor stock screener, Smartmoney stock screener etc. [12-14]. In addition to stock screener, Yahoo Finance has a lot of features most investors find useful [15]. Most of the online brokers also provide an online screener integrated into their trading website for their customers.

iOpus Internet Macros or other macro recorders for Internet Explorer can be used to automate the task of screening stocks using an online stock screener such as Yahoo Finance stock screener [16]. If you are looking for offline stock screeners, one of the best ways is to use scanning feature in TC2007 program. TC2007 and MetaStock both have their own formula language to create various custom explorations (in the case of MetaStock, also known as trading systems) and Personal Criteria Formulas (in the case of TC2007, commonly known as PCF). There are several resources on the Internet documenting MetaStock explorations and TC2007 PCFs including some contributed by traders publicly. Two such resources, both very useful, are TradeOn (for TC2007) and K.A.L.O.S.Z Research (for MetaStock) [17,18]. If you are a computer expert, you can also make use of various Perl finance modules from Perl CPAN archive and create programs to automatically obtain stock screener results periodically [19].

Fundamental Analysis

Most screening conditions that can be set in online stock screeners such as Yahoo Finance stock screener are for Fundamental Analysis. If you are an experienced programmer, you can easily create a program to interface with Yahoo Finance stock screener and generate screener output automatically with a single click. But if you are not, macro recorder for Internet Explorer such iOpus is a good option. Although EZ Macros can be used for Internet Explorer based macros, I recommend a macro recorder specifically created for Internet macros, such as iOpus Internet Macros.

Here are some example tasks for Fundamental Analysis that can be automated and used periodically:

  1. Sample settings for Yahoo Finance stock screener for creating Internet Macro.

    Industry Any  
    Index Membership Any  
    SHARE DATA      
    Share Price $1 Min $10 Max
    Average Volume 10k/day Min Any Max
    Market Capital 250 mil Min Any Max
    Dividend Yield Any Min Any Max
    1 yr Performance Any  
    Beta (Volatility) 0 Min Any Max
    Sales Revenue 1 bil Min Any Max
    Profit Margin 0% Min Any Max
    Price/Earnings (P/E) 0 Min 30 Max
    Price/Book (P/B) 0 Min 5 Max
    Price/Sales (P/S) 0 Min 5 Max
    PEG 0 Min 1.0 Max
    Est 1 yr EPS Growth Any  
    Est 5 yr EPSGrowth Any  
    Avg Recommendation Any  
    Display info for Actively Screened Data  

  2. Using utilities such as wget, lynx or simple Perl scripts, download historical price data from the Internet and also P/E, P/B, P/S, PEG values for every week (for every 5 trading days) in the past 4 years. Identify stocks whose current P/E is near lowest value of P/E or stocks whose current P/B is near lowest value of P/B, or stocks whose current P/S value is near lowest value of P/S, or stocks with PEG number near lowest value of PEG.
  3. Using wget or other tools, download dividend payout information. Then identify which stocks have their current Divident Yield above current interest rates in the country or stocks whose Divident Yield is near highest value of Divident Yield in the past 3 years.
  4. Using Perl or other scripting languages, download daily volume and float information for your favorite stocks and keep track of changing values of Float/Volume ratio and Float - Volume. These values are especially interesting for those stocks which have high Short Ratio.

Use of Perl with CGI and other perl modules, including Yahoo Finance related perl modules from CPAN archive, is recommended for quickly developing a utility to automate complicated tasks. UNIX/Linux operating system is a good choice for quickly developing scripts to achieve above tasks, for example, by using lynx, bash scripting and mySQL database software for storing historical values [20,21,22].


Both Technical Analysis and Fundamental Analysis can be automated with the help of simple perl scripts and in most cases, macro recorder programs or internet macro recorder programs. Murty's Scanner can be used to better analyze multiple reports of explorations run in MetaStock Explorer tool. Online stock screeners such as Yahoo Finance stock screener can be automated using Internet macro recorders such as iOpus Internet Macros. External Perl programs can be written to search for stocks meeting various fundamental analysis criteria.


1 MetaStock software made by Equis International. Official web site: http://www.metastock.com/
2 TC2007 software made by Worden Brothers. Official web site: http://www.worden.com/
3 Tradestation software made by Tradestation Securities. Official web site: http://www.tradestation.com/
4 MetaMarket Plus software made by Paritech. Product web site: http://www.paritech.com/us/products/software/metamarket.asp
5 ValueLine Investment Survey and other products from ValueLine, Inc. Official website: http://www.valueline.com/
6 Value Investors Club is located at http://www.valueinvestorsclub.com/
7 Investopedia is a finance education portal located at http://www.investopedia.com/
8 MetaStock Developer's Kit by Equis International, Inc. Product location: http://www.equis.com/Partners/Developers.aspx
9 Automate software made by Unisyn software. Official web site: http://www.unisyn.com/
10 EZ Macros software made by American Systems. Official web site: http://www.ezmacros.com/. EZ Scheduler, a free scheduling program by American Systems, is also available on the same web site.
11 Murty's Scanner developed by Murty Rompalli. Official web site: http://www.murty.net/mscanner/
12 Yahoo Finance Stock Screener is located at http://screen.yahoo.com/stocks.html
13 Multex Investor is a finance portal by Multex. Web site location: http://www.multexinvestor.com/
14 Smartmoney Stock Screener is part of premium service by SmartMoney. Official web site: http://www.smartmoneyselect.com/
15 Yahoo Finance is a Finance portal by Yahoo. Web site location: http://finance.yahoo.com/
16 iOpus Internet Macros software made by iOpus, Inc. Web site location: http://www.iopus.com/iim.htm
17 TC2007 PCFs and other useful information for TC2007 users by TradeOn. Official web site: http://www.tradeon.com/
18 MetaStock formulas and other useful information for MetaStock users by K.A.L.O.S.Z Research. Official web site: http://trader.online.pl/.
19 CPAN is Comprehensive Perl Archive Network. Official web iste: http://www.cpan.org/. Search for keyword "finance" from the list of all modules on CPAN web site.
20 Lynx is a text based web browser for UNIX and Linux operating systems. Official web site: http://lynx.browser.org/
21 mySQL database software made by MySQL AB. Official web site: http://www.mysql.com/
22 Several public domain utilities contributed by users around the world are available for UNIX/Linux operating system at Freshmeat web site maintained by Open Source Development Network. Go to official web site at http://www.freshmeat.net/ and search projects with keywords: stocks, finance, yahoo


Murty's Scanner and mscanner are trademarks of Murty Rompalli
All other products, services and web sites mentioned in this document are trademarks of their respective owners.

Securities investments carry significant risks. Please contact your broker or financial advisor for more information.

© Murty (My GPG Keys) All Rights Reserved