Can you tell if stock price of company X will rise or fall tomorrow?

If Yes, then I guess you are a billionaire. Aren't You? But answering this question with all certainty is not that easy, rather never possible. Although there is, nor will be a perfect algorithm that can achieve this aim, investors around the world have tried and tested many methods. Broadly speaking there two schools of intelligent investors. Those, who dig into the past annual reports, profit-loss statements of companies and make a forecast based on that, are called "Fundamental Analyst". Another school of guys, interestingly do not care to know whether a company is making profit or loss. Rather they are only interested in the price trend. They believe that price reflects all the news, views, rumors and sentiments and just considering the current price trend, they can forecast the future trend.  These guys are called "Technical Analyst" or "Chartist".

What a technical analyst or chartist does? If you are a seasoned investor or have ever watched the stock price charts closely, you must have found some patterns, which recur and most of the time price move in the same direction after the pattern is seen. So a chartist analyzes the charts to find out different patterns and forecasts the following price movement.

If you have read so far, you would be interested to see some patterns. So here are some.

So if you are an investor and tracking 300 stock issues for investment, then you have to sit down with these charts and dig out the patterns yourself. But who wants to do anything manually if a computer can do that in seconds. Yes there are some software in the market that recognizes the patterns automatically. But as an expert chartist knows chart reading is an art, not a science. The definition of a pattern differs from one chartist to other. A chartist can afford to have a cup without a handle, while another may insist on  the handle. So how can a single software cater to the needs of different analysts. The solution: to write your own software!!!. Certainly it is difficult for an investor who is not an expert programmer. But how about a programming language, which   allows the investor to describe a pattern as he sees it. For example, the following pattern, called head-and-shoulder can be programmed in a few lines as follows:

hill = up >> down                                   

head_shoulder = hill >> hill >> hill
                       ?? [ high d > high b,
                            high d > high f,

                            high b = high f
                          ]

           head.jpg (20931 bytes)

Above definitions tell that, a hill pattern is a concatenation( >> operator) of two primitive patterns up and down. A head-and-shoulder pattern is formed by concatenating three hills; and it has some constriants like high price at point d is higher than high price at point b and high price at f etc. These constraints are specified using the ?? operator.

We call our language Chart Pattern Language (CPL).   For details please refer our ICFP paper.