Monday, February 03, 2014

Looking for an edge

The quantitative analysis presented here is an attempt to confront randomness in the stock market. Too often technical analysis is presented in a manner that misrepresents the nature of the market. In focusing on pattern recognition it is easy to make the assumption that patterns direct the market. It is a natural human condition to look for patterns and assign meaning to the chaotic world around us. However, there is danger in assuming that randomness is an unfortunate by-product of the dynamics of order. To the contrary, there are aspects of order in randomness, but we should never assume that outcomes are assured beyond the bounds of random probabilities.

That’s a tough statement to make in the investment business. There’s a lot of money staked on the idea that we can understand the market. Investors pay handsomely for that notion: management fees, time and money invested on analysis and guidance, among many costly investment expenses. Nothing is more costly, however, than the investment losses that occur because investors put capital at risk beyond the limits of random probabilities. We lose more money because we think the market has order when in fact it does not. Of course, financial institutions cannot present themselves as purveyors of randomness. That’s a business that goes by another name.

Stock Trends was designed based on the idea that we could categorize order in the stock market. Trend analysis is about assigning order to price movement. Reversion to the mean aspects of price momentum analysis has some application toward randomness, but the type of momentum analysis Stock Trends emphasizes is more aligned with harnessing forces of order evident in mass psychology. Exposing market randomness, at first glance, makes Stock Trends look like another snake oil gimmick – one of many peddled in the business of guiding investors. Is it possible to reconcile our trend analysis with the randomness of market outcomes?

The truthful answer to that question is… perhaps not. We can assume that many stakeholders with immense resources in the investment business are grappling with the same problem. There’s a big demand for quantitative analysts in the financial sector for a reason. It’s a battle with randomness that has forced the investment business toward a data science solution.
My solution for Stock Trends is to reframe our analysis question. It’s a solution that shifts our focus away from the traditional trend analysis framework – one that is based on notions illustrated by select samples of pattern evidence – to a framework that is data driven and presents all outcomes, supporting and non-supporting. Every technical analyst – honest ones, anyway – can show you ten contradicting charts for every tidy chart that illustrates a particular pattern. Our analysis question is now: what does the data really tell us? From that answer we can propose a trading strategy.

In previous editorials I’ve introduced a statistical inference model that attempts to translate sample observations into estimations of population means based on the indicator combinations presented in the Stock Trends Reports. The primary premise: that the Stock Trends indicator combinations represent distinct characteristics of a market condition. That condition is defined by the trend indicator, the length of trend category (major trend counter) and indicator (minor trend counter), the relative intermediate price momentum (Relative Strength Indicator) and weekly price performance (+/- indicator), as well as the evidence of unusual trading volume (volume indicator).

Here we are labelling across markets. The conditions of supply and demand represented in these indicator combinations are homogeneous – grouping the current market trend characteristics of iconic Apple’s big cap stock (AAPL-Q), for instance, with that of little-known W.R. Grace & Co. (GRA-N) on May 18, 2012.



The purpose of the inference model is to give us an estimated population mean and standard deviation from which to build a probability distribution – this on an assumption of randomness in the population of possible outcomes given the market condition (as defined by the indicator combination). Basically, we are trying to come to terms with randomness by assuming it, and looking for estimated indicator combination probability distributions that have a leg up on the expected random outcomes that include the universe of stocks.

Let’s again have a look at an example. It’s best that we look at the most easily defined Stock Trends event – the Crossover. We call this an event, but it is in reality a non-event. Strictly speaking it is a mathematical event defined by the crossing of a shorter-term (13-week) moving average trend line and a longer-term (40-week) moving average trend line – or more properly when the 13-week average share price moves either higher or lower than the 40-week average share price. This is not the kind of event that necessarily feeds back on a market for a stock, although in some circles it is promoted as such. However, it is an important event in our analysis that isolates changes in major trend category. It pinpoints when the Stock Trends parameters move between BULLISH and BEARISH.

Because in our inference model indicator combinations are supplemented with trend length qualifiers when querying the data for ‘like’ combinations, and the Crossovers by definition start a new trend, the Stock Trends trend counter for Crossover stocks is not much use for comparison. All Crossovers have trend counters 1/1. The way I have chosen to deal with this is to ascribe the length of the previous trend category (major trend counter) when looking for similar instances of Crossover stocks. This maintains an influence of time on the grouping of trend category changes as well. This is an important note to make about the Crossover stocks analysed.

Ford Motor Co. (F-N) is currently a Bearish Crossover (). It had a Bullish trend for 60 weeks, but the stock has faded off its resistance level at $18. Its Bullish trend did reward the Stock Trends S&P 100 Bullish Crossover Portfolio with a respectable 28% return. The assumed implication of a Bearish Crossovers is that it is a trade exit signal. Conversely, a Bullish Crossover is our typical trade entry signal. Accordingly, Ford was sold on the Bearish Crossover.



But what does our inference analysis really say about Crossovers? We’ve looked at some statistical analysis of that previously, but let’s evaluate how our probability guidance would have turned out for Ford’s stock over the past 30-years.

The first thing to note in the following data is that not all Ford stock's Crossovers are represented. Some of the Crossovers indicator combinations did not have a large enough sample size to complete the analysis. As such there are only 37 of the total 56 Crossovers that have occurred since 1980. A notable Crossover missing is that of May 8, 2009, a Bullish Crossover () that introduced a major Bullish trend.

 


Both sets of results - Bullish and Bearish Crossovers - are sorted by the average probability that the stock will return better than the expected mean random outcome - our inference model. We discover the following:


For Bullish Crossover events where the mean probability of Ford's stock (F) besting the expected return of randomly selected stocks was greater than 52%, the stock beat the expected random return 17 out of 21 period-returns (81%) [green cells represent returns that outperformed the expected random return]. This compares to 15 out of 36 (42%) when the mean probability is less <= 52%.

For Bearish Crossover events where the mean probability of Ford's stock (F) besting the expected return of randomly selected stocks was less than 48%, the stock underperformed the expected random return 8 out of 9 returns (89%) [red cells represent returns that underperformed the expected random return]. This compares to 29 out of 42 (69%) when the mean probability is >= 48%.


This example tells us that our chances for a successful trade - that is, doing better than the return we can expect on a randomly selected stock - are enhanced by the inference model. As the average probability (across time periods) is outside some deviation (here above 52% and below 48%) of the probability of random stocks, the chances of a trade meeting our goals improve.

This explanation may seem complicated at this time, and future editorials will provide more examples to help us grasp the meaningfulness of the inference model. In the end, investors are looking for a slight edge, even in a game of chance.

Another important result of this analysis is that sometimes the inference analysis contradicts our expectations as far as the trade implications for the Stock Trends indicator. Sometimes a Bullish Crossover, based on the specific indicator combinations, presents an estimated return below the expected return of randomly selected stocks. Sometimes a Bearish Crossover, based on specific indicator combinations, presents an estimated return above the expected return of randomly selected stocks.

An example of this is found in the analysis of the current Stock Trends indicator combination of Ford's stock (F). Here are the estimated probability distributions over the 4-week, 13-week, and 40-week periods.




For 4-week returns distribution estimation, with 95% confidence, the 4-week mean return of the population of stocks with a smilar Stock Trends indicator combination to F will be inside [0.006%, 1.692%].

 Mean return  0.85 and standard deviation of 9.63

 For a Normal Distribution:
 For 4wk CLOSE P(R>0)=53.51
 For 4wk CLOSE P(R> 0)=46.49

For the 4-week period the probability of F returning better than the expected return of a randomly selected stock is 54%.


For  13-week returns distribution estimation, with  95 % confidence, the  13-week mean return of the population of stocks with a similar Stock Trends indicator combination to  F will be inside [ 2.531 %, 5.434 %]

Mean return  3.98 and standard deviation of 16.42

For a Normal Distribution
 For 13wk CLOSE P(R> 2.19)=54.35
 For 13wk CLOSE P(R>2.19)=45.65
52.3% of sample returns are >2.19%

For the 13-week period the probability of F returning better than the expected return of a randomly selected stock is 54%.



For  40-week returns distribution estimation, with  95 % confidence, the  40-week mean return of the population of stocks with a similar Stock Trends indicator combination to  F will be inside [ 5.9 %, 11.844 %]

Mean return  8.87 and standard deviation of 32.48

Normal Distribution

 For 40wk CLOSE P(R> 6.45)=52.97
 For 40wk CLOSE P(R>6.45)=47.03

50.77% of sample returns are > 6.45%

For the 40-week period the probability of F returning better than the expected return of a randomly selected stock is 53%.

The inference analysis is contradicting the trading implication of Ford's Bearish Crossover (). This is the kind of information I hope to make more readily available on the Stock Trends website. 

Ranking expectations

All reports and trading strategies in Stock Trends Weekly Reporter are derived from standard techniques of technical analysis. They are offered based on the premise that the indicators and chart patterns represented alert to possible trade events – either buying or selling. But because trading and investment advice is really a statement about future price movement - an uncertain domain – it should be framed as a probability statement.

The Stock Trends inference model I am developing is an attempt to do that. By looking at the results of past indicator combinations and assembling a sample space from which to estimate probable outcomes relative to probable outcomes of randomly selected stocks the model looks for a small edge in particular trend and price momentum situations. Put simply: if a trade is a toss of the coin, let’s find a 'special' coin.

First we must clarify that statements of probable outcomes enumerated here are not asserting what the actual outcome will be. That is unknown. The market could experience a massive correction, something that is in the realm of possible outcomes. Any individual stock could rally significantly… or drop precipitously. This analysis is not attempting to predict the price path of a stock. It is instead asserting that, assuming a particular distribution of the population of a sample space, a particular Stock Trends indicator combination signals a higher probability of a return greater than the one we would expect, on average, with a random stock selection. We’re playing to beat the monkey.

Ranking estimated means

In this week’s Stock Trends Picks of the Week reports (across all exchanges covered) there are 52 stocks highlighted. They include U.S. healthcare stocks like Eli Lilly & Co. (LLY-N) and AMN Healthcare Services Inc. (AHS-N), technology stocks like Digimarc Corp. (DMRC-Q), CommTouch Software (CTCH-Q), as well as precious metals stocks like Silver Standard Resources (SSO-T) and Agnico Eagle Mines (AEM-T) on the TSX. All of the stocks are selected based on a filter that looks for certain combinations of Stock Trends indicators, as well as share price and trading volume requirements.

The Picks of the Week report is designed as a weekly screening tool, helping investors locate stocks and exchange traded funds that might be signaling a good entry point. Generally, good practice is to look for additional confirmation, either technical or fundamental, in assessing the selections. The Stock Trends inference model allows us to evaluate these picks in terms of the statistical performance of grouped indicator combinations. Which stocks give us our best chance for a positive outcome?

The following heatmap graph ranks the current top Picks of the Week selections based on the inference analysis. Each stock is evaluated to see how much its expected mean return is above the expected mean return of randomly selected stocks. The stocks are then ranked by the average mean return across all three periods (the “mean of means”).

 
The colour scheme for the heatmap is set to the market base for random returns. Values that are greater than the expected mean return of randomly selected stocks have progressively darker green boxes; values that are less than the expected mean return of randomly selected stocks have progressively darker red boxes. Values hovering near the expected mean of randomly selected stocks are yellow. The color key legend gives us this representation. It also shows a density distribution of the “mean of the means” returns.

This analysis points us toward stocks that have the best record of indicating higher probabilities of positive returns throughout a 40-week period. At the top of the list – among this week’s Picks of the Week stocks – is NovaGold Resources (NG-A), AMN Healthcare Services (AHS-N), Hertz Global Holdings (HTZ-N), and Alphatec Holdings (ATEC-Q).

A breakdown of the analysis – what does it tells us?

Let's have a look at NovoGold Resources. Currently, it has a Bullish Crossover () trend indicator.




NovaGold’s current Stock Trends indicator combinations (*see note) generate the following distributions of returns for 4-week, 13-week, and 40-week periods:



The returns distribution of stocks that shared a similar Stock Trends indicator combination to NG (as described in last week’s editorial) tells us that the stock will perform relative to the expected random mean return are as follows:

There is a 48.1% probability that NG will return better than the expected mean return of randomly selected stocks at the end of the coming 4-week period.

There is a 57.9% probability that NG will return better than the expected mean return of randomly selected stocks at the end of the coming 13-week period.

There is a 59.7% probability that NG will return better than the expected mean return of randomly selected stocks at the end of the coming 40-week period.

This analysis suggests that while NG’s shorter-term expectations are not that positive; the longer-term expectations are quite positive.

The components of the Dow Jones Industrials give us another representation of this analysis. Here not all 30 stocks currently have indicator combinations with large enough sample sizes for our inference model. This week there are 23 DJI stocks to compare.

Here we see that 3M Co. (MMM-N) ranks highest, and that Coca-Cola (KO-N) ranks lowest.

The returns distribution of stocks that shared a similar Stock Trends indicator combination to MMM tells us that the probabilities that the stock will perform relative to the expected random mean return are as follows:

There is a 52.5% probability that MMM will return better than the expected mean return of randomly selected stocks at the end of the coming 4-week period.

There is a 56.2% probability that MMM will return better than the expected mean return of randomly selected stocks at the end of the coming 13-week period.

There is a 65.95% probability that MMM will return better than the expected mean return of randomly selected stocks at the end of the coming 40-week period.

The analysis tells us that 3M Co. stock is a good bet. The stock is now in its 101st week of a Stock Trends Bullish trend and looks to continue along its path. At the very least, you would, on average, be better off buying MMM than buying a random stock.

At the bottom of the Dow Jones Industrials in terms of current expectations is Coca-Cola.

The returns distribution of stocks that shared a similar Stock Trends indicator combination to KO tells us that the probabilities that the stock will perform relative to the expected random mean return are as follows:

There is a 42.6% probability that KO will return better than the expected mean return of randomly selected stocks at the end of the coming 4-week period.

There is a 38.4% probability that KO will return better than the expected mean return of randomly selected stocks at the end of the coming 13-week period.

There is a 43.4% probability that KO will return better than the expected mean return of randomly selected stocks at the end of the coming 40-week period.

Here the analysis tells us that Coca-Cola’s stock is not a good bet. You would be better off to buy a random stock.
  
[note: for Bullish Crossover and Bearish Crossover stocks the trend counter criteria reverts to the previous week's counters. In that manner the length of the previous trend category is the pertinent comparison. This adjustment is made for queries on all Crossover combinations because the trend counters are set to 1 for Crossovers.]

Embracing Randomness

The investment industry can be defined in a number of ways, usually centered on its fiduciary role of managing and allocating capital. But fundamentally it is a data driven industry. Data is its lifeblood. Data is its nervous system. Data is what gives investment life. Without data capital cannot be managed or allocated. Without data capital is locked away, unproductive and hoarded.

Instinctively, we know this. Every investor makes decisions based on available data. Remember, data comes in many forms – much of it qualitative, unstructured, and fluid. Structured quantitative data is more readily recorded, warehoused and shared. It includes macroeconomic data, financial statements, capital stock changes, insider trading reports, industry market analysis, and – most importantly for market technicians - market trading data. In all its forms this data alerts the marketplace to investment channels and helps form our investment opinions. The magnitude of this data is impossible to quantify.

With so much data available how can we achieve optimally informed investment decisions? Is a truly informed position, one that is measured from all essential data, a realistic expectation? The way many investment professionals talk about their version of data analysis you would think it is. But there are too many alternate informed decisions to know which would be the best, the most profitable. Indeed, your quest to find the most profitable data analysis has likely led you to a numerous sources of investment information.

Of course, data can also tell us whether one version of analysis is superior to another. How can we know whose opinion to heed except for their past record measured in a response variable? What returns have been generated by a system of analysis? But what if the trading record of the analyst who has the best story supporting his or her opinion is not much better than results derived from investment decisions based on specious factors, like astrology or the Super Bowl winner? What if, for all the esteemed knowledge of the most brilliant market oracles, the result does not match the billing? These questions and the quest for a more rigorously-tested approach to investing bring many serious traders to the world of quantitative analysis. It is only by examining the trading results of informed decisions that we will know whether the data analysed to make those decisions holds the key to success.

So, we’ve arrived in the world of the ‘quant’ – a world of data variables and the dynamic nature of their relationships. It’s not easy stuff. But don’t let that scare you away. Like most things quantitative analysis can be broken down to simpler elements.

Stock Trends is an excellent data source for analysis. It provides a consistent set of variables – the Stock Trends indicators – that can be measured against a response variable. The response variable can be subsequent share price changes of any time parameter. However, we will focus on end-of-period price changes for 4-week, 13-week, and 40-week periods. These time periods represent trade time frames best executed by the Stock Trends indicator analysis. These would be most effective time frames for position or swing traders.

In fact, the average holding period for Stock Trends trading strategies based on changing trend categories (like the Dow Jones Industrials Bullish Crossover Portfolio trading strategy) is around 40-weeks, while the average holding period in more sensitive Stock Trends trading strategies tends to be lower – between 7 to 10 weeks. Typically, we will be focused more on the 13-week time frame (3-months) as the most pertinent time frame, but both the 4-week and 40-week time frames are of interest, too.

Regardless of time frame of our quantitative analysis of Stock Trends, we will be most interested in finding opportunities to trade where the probabilities of a market outcome are better than that exhibited by random selections. Why? Because regardless of how informed decisions are codified – every Stock Trends Pick of the Week or every Jim Cramer recommendation, for example – measured trading results of any prescribed period that follow will, given enough data, tend toward a normal distribution (bell-shaped). A normal distribution, like the one presented below, implies randomness. It has 50% of observations above its mean, and 50% below its mean.

This is an important understanding of trading. In an ideal trading system there would be a positive skew to the distribution of trading results, one with a fat tail on the right side of the distribution curve. This would represent a trading record with a significant number of ‘home runs’. For example, when you look at the published Stock Trends portfolios, in particular the Nasdaq 100 Bullish Crossover Portfolio, the positive skew is evident.



However, real world and model trading strategies can only be products of a sample of possible outcomes. No matter how successful a trading strategy appears in a sample, we know that the outcomes are not a complete representation of all outcomes – past, present and future. We cannot know precisely the shape of a population distribution, but it will tend toward a normal, bell-shaped, distribution. The shape may be “skinnier” (a higher kurtosis in statistical terminology) than the example standard normal distribution shown above, but the symmetrical aspect will be formed.

If even the best strategy, using the most essential, optimal data inputs, eventually develops a distribution of results that approximates a normal curve, and a normal curve is the expected distribution of results derived from random data inputs - what is the difference?  Certainly, anyone who has done capital markets quantitative work will confront this question. That is why it is important to embrace the randomness of markets. A key to success is in understanding it.

As an example of the distribution of returns we expect from random results, here is a distribution of the 13-week returns of 1,000 randomly selected North American stocks from randomly selected dates.

 

How do we turn the random nature of the market into a profitable trading plan? 

Stock Trends can help.

A key premise of technical analysis is that market valuations are subjectively determined. Buyer and seller – opposing forces – effect a market price based on the balancing of these subjective valuations. In classical market technician parlance, the market price discounts all available information. However, an interdependent set of variables add a dynamic feedback loop to this subjectively determined price – elements of time, and price change. We call this price momentum and it factors into much of the terminology of technical analysis. We’ll avoid elaborating on that, but suffice to say price change is a significant element in the subjective environment of every market and is an important variable for every buyer and seller. It results in the establishment of price trends, as well as the breaking of those trends.

The reason we study price trends – and the raison d'être for Stock Trends – is the self-fulfilling aspect of price movement. The Stock Trends indicators are variables that represent different aspects of price change, as well as time. The trend indicator categories – BULLISH and BEARISH – tell us about the relative price changes over a longer time frame. The Weak Bullish () and Weak Bearish () trend indicators tell us about possible changes in those long-term price trends. The Bullish Crossover () and Bearish Crossover () indicators tell us about changes in the trend categories.

Adding the element of time to the trend indicators is the trend counters (major and minor trends), both of which help characterize the assigned trends. They tell us how long a stock/ETF/index has been trending – an important variable that alerts us to concepts of trend fatigue and other psychological aspects of price movement. Market technicians use techniques that attempt to interpret time fractals; similarly Stock Trends trend counters also extend our trend analysis framework.

The Relative Strength indicator measures price momentum relative to the price movement of the benchmark market index over a thirteen week period, while the RSI +/- indicator gives a binary representation of the relative price momentum versus the benchmark index for a one week period. Finally, the Stock Trends volume indicators isolate unusually high weekly trading volume.

The Stock Trends variables – most specifically the combination of these variables – provide us with a dataset that is ripe for quantitative analysis. A very simple question we can pose: what are the statistical returns that the market generates after particular combinations of Stock Trends indicators? This is the concept being developed here, and introduced in recent editorials.

Let’s look at combinations (trend indicator, RSI indicator, RSI +/- indicator, volume indicator) from the current week ended Jan17.  Of over 8,000 N.A.-listed common stock, exchange-traded-funds and income trust issues (NYSE, Nasdaq, NYSE-Amex, and TSX) with Stock Trends trend indicators, there are 1,113 distinct ST indicator combinations this week. Some combinations are shared by multiple issues; some are unique. Some combinations are absent this week, but recorded in other weeks.

Each of these distinct combinations, for the most part, is repeated in the Stock Trends database of over thirty years of weekly reporting. In the database there are 16,668 distinct combinations recorded, with each combination representing a sample of what would be a larger population of distinct combinations possible. Not surprisingly, the most frequently recorded combinations are Bullish trends () centered around the market’s price momentum (Relative Strength Indicator near 100).

In order to more accurately find like combinations of the ST indicators, though, we add another two variables to the indicator combinations – the major and minor trend counters – and group RSI values within discrete ranges. In this manner we can attempt to group each combination in a meaningful way that reflects similar qualities of trend, price momentum, and volume.

By running a query for each of the current issues with a Stock Trends trend indicator to find like observations of these indicator combinations in the historical data (about 8.4-million records) and measuring the subsequent 4-week, 13-week, and 40-week returns we can determine the statistical mean and standard deviation of those returns for each sample. Then using statistical inference methods estimate an interval for the population mean. From those intervals we can rank each indicator combination.

That’s a lot to digest. Let’s try an example.

Cigna Corp. (CI-N) is a notable name in the health care sector. Its Stock Trends Bullish trend is now 67 weeks long and the stock is outpacing the S&P 500 index by 13% over the past 13-weeks. That’s a healthy trend.



But what does this kind of trend and price momentum tell us? What guidance do other examples give us?
A query to the Stock Trends database locates 311 other records with similar Stock Trends indicator combinations. Of those records 303 pre-date 13 weeks ago and consequently have 13-week price returns recorded. The distribution of those returns is illustrated in the graph below, represented by the green density curve. The blue lined plot is of the corresponding normal distribution of the sample.

Remember, the distribution presented represents a sample of returns. Indeed, all portfolio records are samples. Back-test to your heart’s desire – but every portfolio record is by definition only a sample of a much larger population of trades. Samples - especially relatively small samples - can be flattering, and they can be less flattering, but what we are really interested in is the population of trades that are represented by a trading strategy.

Obviously, we can never truly generate a record of this or any such population. However, using statistical inference methods we can extrapolate some important pieces of information about the population from the sample. We can estimate the mean and the standard deviation of the population from the sample.

The mean 13-week return of stocks in the CI sample is 5.43% and the standard deviation of those returns is 14.98. Those are two measurements of the distribution illustrated above that we can use to say something meaningful about the population.

For 13-week (closing price) returns estimation, with 95 % confidence, the mean (average) return of the population of stocks with a similar Stock Trends indicator combination to CI will be between 4.0 % and 6.85 %. This means we are pretty confident the mean is above the mean return of a randomly selected stock (2.19%). Also, if we accept the mean return as 5.4%, a normal distribution of the population of 13-week returns tells us that 58.6 % of returns will be above 2.19% (the 13-week mean return of randomly selected stocks).

Remember, this edge is relative to the random outcome we expect, which is a 50% probability of besting the mean market random outcome in the coming 13-weeks. In an exercise of chance, an edge in positive probable outcomes is an excellent foundation for relative success. Applied to the stock market it is also effective, although success will also be a function of trading practice. In this CI example there is still a 41.4% chance the 13-week return will be less than the mean return of random results, and a possibility that the loss could be substantial. It is imperative that investors learn proper trade setups to limit losses. This analysis, like all analysis in the investment business, is a starting point. Portfolio management tools are always the key to long-term trading profitability.

Stock Trends is working toward providing this quantitative analysis on all stocks, and editorials ahead will help bring a better understanding of how to use the information.

Friday, March 15, 2013

Trading after the signal


Slippage is an important issue for market timing investors. It is a costly consequence of almost all transaction-heavy trading plans – certainly more of a concern than commission costs. Briefly defined, slippage is the difference in the price at which you intend to buy or sell an instrument and the price at which the order is filled. There are multiple reasons for this divergence, including the time that passes between order placement and execution and the relative liquidity of the instrument. Closing the gap between your expectation of what price a stock will be bought or sold and the price you actually get filled should be an important part of your trading practice.

But what about the slippage that occurs between a market signal and trade order? This is an especially important consideration when following a system published by a market-timing advisory service. Can the rates of return achieved by a trading system be closely simulated? How does the model function in real trading? Readers here would ask how do the model Stock Trends Portfolio trading systems rate against actual or achievable trading results? The  signals generated by the Stock Trends trading systems are issued after the close of trading on Friday, but the model portfolios register the Friday closing price as a transaction price. Can subscribers to the service attain the same returns registered by the model portfolios by trading post-signal in the following trading sessions?
 
First of all, a clear statement can be made about exactly duplicating any portfolio: It would be highly improbable that the transactions of a trading strategy can be matched. Even high frequency trading systems generating split second orders cannot be regenerated exactly in the marketplace because every fraction of a second represents a new market for an instrument. Of course, the differences in results may tend toward insignificance when the time between signal and order execution is small, but actual order regeneration at the same price is still highly improbable over numerous trades.
 
However, we would like to see that the results generated in a particular model are reasonably simulated in actual trading. What is acceptable in terms of variance between the model results and actual results will depend upon the over-all profitability of the system. In other words, will a trading system provide returns high enough to make the differences in actual results acceptable? If a system gives you 5% returns you won’t be too happy with a 2% difference in actual results. If the system gives you 20% overall returns, 2% slippage might be acceptable.
 
Periodically, I do get asked how the Stock Trends model portfolio performance holds in a post-trigger market  - what would be the real trading results for subscribers who want to mimic the trading activity directed by the published strategies? The answer to that question depends on the trade efficiency of the investor and on the type of stock traded. Poor trade order practice and illiquid, volatile stocks make a bad combination.
 
Certainly, placing ‘market orders’ on trades in this category of stock will very often result in less than optimal results. As a point of reference I will direct readers to the Stock Trends Handbook chapter on executing trades, but there are many other sources that can educate investors on how to properly make a trade. It is important that every investor know that regardless of their source for a trade signal – whether from an advisory service, your own analysis, or your taxi cab driver’s – the responsibility is on you to execute the trade as optimally as possible. A signal to buy or sell is not a signal to go to the market unprepared. It is essential to be tactical with every trade order.
 
For now, let’s assume that trade order best practice is being used. What can we learn about the differences in trading results possible for investors who go to market after the Stock Trends Portfolio trade signals are issued? I will only do analysis of this question on the weekly data series I maintain and will only seek to approximate possible results on the assumption that the trade is executed in the following week. As a result any differences that are highlighted in this analysis may in fact be lower if the trade data was for the following trading day instead of the following trading week. Nevertheless, I believe this analysis should give us a pretty good idea of what kind of replication of trading prices is likely and whether there is a significant difference in results from the model portfolios published here.
 
How can we truly approximate actual trades made? Even if I presented trade tickets for each trade it would not be an accurate representation of the population’s (every subscriber who transacted on the signals) trade record. It is necessary to approximate as a central measure, to estimate a price at which a transaction would have tended toward. If we take the mid-point of the range of the stock price in the following period we can estimate a central point, although without actual inter-period data to see what the distribution of prices tells us it would be an imprecise estimate. For instance, a stock may have traded mostly above the range mid-point. This analysis cannot tell us how individual stocks traded on a daily or intra-day basis.
 
If we take a sample (data, csv) of over 5,200 transactions directed by the six active Stock Trends model portfolios currently published and extract trading data for the following week after trade signals (both buy and sell), we get the following statistics of the results for post-trigger trades made at the midpoint of the weekly range :
 
Mean of the difference between the post-trigger price change (%) and the published price change (%):-0.18
Median of the difference between the post-trigger price change (%) and the published price change (%):0.19
Median Absolute Deviation of the price difference from the published trigger price:3.84
 
This tells us that approximately 50% of the transaction prices obtained in the post-trigger period (the following week) at the midpoint of the price range had overall trade results within the range of 3.65% lower and 4.03% higher than the published trade price changes. Roughly restated, if an investor bought or sold the stocks posted in the Stock Trends portfolio transaction reports the week following, and obtained a price near the midpoint of the weekly price range, the overall results of the trades would differ only marginally from the posted results.
 
Of course, there will be varying experiences on individual trades, and some traders will obtain better or worse prices than the midpoint of the range. A mythical trader who somehow managed to enter each position at the lowest price and exited at the highest price post-trigger would have experienced a 47% improvement in overall returns. Conversely, a mythical trader who somehow managed to enter each trade at the highest price and exited at the lowest price post-trigger would have experienced a 44% drop in overall returns.
 
These two highly improbable scenarios only serve to expose the range of experiences that are possible given the broader parameter of this analysis – that the trade takes place within the following trading week of a buy/sell signal. The ranges expressed here would likely be tighter if the analysis were done solely on trades the day following the buy/sell trigger. One hopes that the typical trader would tend toward the midpoint (although it would also be a mythical trader who makes all trades at the midpoint of a range) and the results experienced over an extended period would be in line with that published in the model portfolio reports.
 
This exercise serves two purposes: first it reaffirms that post-trigger trading can simulate the model performances. But more importantly, it reminds us that investors trading their own account should be certain to always engage the market tactically, use limit orders regularly, and to make every effort to exact the best price possible in every trade. 

Wednesday, February 27, 2013

First steps toward quantitative trading


Finding the right combination of indicators is an important launching point for technical traders. Fine tuning different charting constructs, different momentum and trend indicators and back-testing results - that's the life of many market timers. Indeed, optimizing indicators and trading systems is a growing part of the investment business, as much with wealth management institutions as among the many retail traders who live by the success of their algorithms. In its own way, Stock Trends is part of this movement toward quantitative trading.

Most quantitative trading runs through finely tuned statistical models that guide both trading systems and portfolio management. The Stock Trends analysis is more static in terms of the indicators used, but seeks to optimize applied trading systems within the given parameters. The toolset used here is basic: a moving average study, a momentum indicator, and a volume trigger. But together these elements provide a powerful - and simple - means of engaging the market on a quantitative level. Each report Stock Trends publishes can be used within the framework of a trading system.

Optimizing results through statistical modelling is a multi-step process. The first thing that must be achieved is to understand your data. It is important to be able to describe its characteristics and to determine the independent and dependent variables. I have started that process in recent editorials by generating some statistical output of the Stock Trends data. The next step is to break down those descriptive statistics by category. Each subset of data that is pulled from the data history can be grouped and assessed for differences in results of the output variable - namely, the post-observation performance of individual stocks or ETFs, or the probable outcomes based on statistical predictive models.

With a given combination of Stock Trends variables, for instance, are there sub-groups that have different characteristics. We can seek to ask questions like: what are the differences in central tendencies and the distribution of results for low priced stocks compared to high priced stocks? Does price momentum propel small cap stocks higher compared to large cap stocks? Do certain sectors perform better for the momentum trader? There are many of similar questions we can evaluate, and all would be important ones to answer when developing a trading model.

Building on last week's editorial, let's take another sample of the Stock Trends data and see what it can tell us about different categories of stocks. Of particular interest is whether we can identify any divergence of performance statistics between stocks based on their share price and the Relative Strength indicator. The Stock Trends Picks of the Week report (available to subscribers of Stock Trends Weekly Reporter) provides an interesting sample of the data for discovery of important relationships between the variables. Last week we looked at statistics of the entire sample; here we group the data and compare results.

Again taking a sample of Picks of the Week selections since the beginning of 2012 until February 8,2013 we can create new categories for the share price and Relative Strength indicator and group by ranges.

Share price ranges
$2.00 - $4.99
$5.00 - $9.99
$10.00 - $19.99
$20.00 - $49.99
$50 - max($800)

Relative Strength Indicator (RSI) ranges:100-104
105-109
110-119
120-149
150-max(800)

These groupings are arbitrary, and not based on any statistical method to create bins (groups). Nevertheless, they help us categorize the data in terms or ranges that are easy to understand.
So how do the statistics for the percentage change in price (to the current end date, February 22, 2013) break out for these groupings?

Below is a table, ranked by median percentage change of the groups (median represents the middle value of observations). It gives us a breakdown of the number of observations, as well as some important metrics of central tendency and distribution of results.

price group($)RSI groupnumbermeanstandard deviationmediantrimmed meanminmaxrangeskewkurtosis
(20,50](150,800]2915.5740.6814.7014.50-69.60117.10186.700.27-0.22
(50,800](99,105]3808.4014.558.258.24-71.80102.20174.000.398.74
(20,50](110,120]6988.7022.407.408.05-70.10172.40242.500.976.46
(10,20](120,150]4049.4631.837.308.03-75.90138.20214.100.651.43
(50,800](105,110]2646.9916.826.907.51-49.6058.00107.60-0.290.69
(20,50](105,110]5617.8817.686.807.53-57.00110.30167.300.604.30
(20,50](99,105]7018.4015.956.507.59-50.00101.00151.000.673.85
(50,800](110,120]3117.9519.356.307.54-44.70106.80151.500.492.09
(10,20](110,120]4207.1526.356.106.55-98.30156.80255.100.593.68
(5,10](105,110]1186.3730.665.754.66-91.20150.00241.201.265.40
(50,800](120,150]1107.5325.555.757.38-55.9062.50118.400.00-0.07
(10,20](105,110]2876.9621.315.206.57-64.00104.10168.100.362.43
(10,20](99,105]3236.6520.784.805.97-98.3096.40194.700.144.63
(5,10](110,120]2699.2334.144.307.39-92.00127.10219.100.611.08
(5,10](99,105]1235.4118.464.104.83-58.0089.40147.400.844.67
(20,50](120,150]3906.6830.643.754.49-71.00168.10239.101.304.43
(5,10](120,150]3363.4633.311.201.38-89.40142.60232.001.022.96
(1.99,5](105,110]596.9634.590.003.97-65.10114.70179.801.011.21
(1.99,5](99,105]595.8532.02-1.101.87-41.70120.20161.901.603.13
(1.99,5](110,120]1474.3144.33-1.800.84-85.60277.70363.302.059.51
(5,10](150,800]775.6566.87-2.00-3.09-79.90352.40432.302.388.75
(1.99,5](120,150]2897.8953.54-3.001.69-88.80228.10316.901.332.46
(10,20](150,800]540.3161.09-4.50-3.51-95.10176.40271.500.680.30
(1.99,5](150,800]1706.1262.25-4.70-1.92-84.90501.80586.703.4322.18
(50,800](150,800]814.7558.73-14.0514.75-38.60109.20147.800.59-1.58

See full table and article at www.stocktrends.com

As with most tables, the first thing that jumps out is the extreme values. In particular, at the bottom half of the rankings are stock picks that had share prices between $2 and $5, across RSI values. The Picks of the Week report during the period was least populated by stocks in this price range. It is clearly the most variable price group, and also the poorest performing as shown by the low values for the median and trimmed mean (trimmed mean here excludes the top and bottom 10% of observations).

However, with variability also come the outliers - those observations we trim in statistical analysis. In the statistical world outliers are problematic. For some traders, it's their holy grail. It's the grand slam home run they celebrate. Here it would include the 500% gain on the November pick of Novogen Ltd. (NVGN), or the 277% gain of the January 2012 Santarus Inc. (SNTS) pick - among a number of other very profitable trades.

Nevertheless, when modeling a trading system it is always most important to understand the risk-reward balance. Attempting to capture higher returns on individual trades can be self-defeating. It is far better to model a system that keys on more predictable results, with low variability and a distribution that offers the best chance of long-term profits. The groupings in the top half of the table presented here would represent the more controlled parameters.

Below is a plot that compares the mean (average) percentage change in price for Picks of the Week in the sample (with a 95% confidence interval represented by the vertical bar). Also presented are Box Plots that give a visual representation of the distributions of the percentage change in price by Stock Trends RSI category range for each share price grouping.




Based on this sample of data we could focus on certain price and RSI ranges when evaluating the Picks of the Week report. For instance, we notice that relatively higher priced shares with high price momentum (high RSI values) performed better. More generally, though, it seems that stock picks with a share price above $20 provide the most consistent results. If we take a subset of the Picks of the Week sample with share price >= 20, we find the following distribution:

If we limit our analysis to Picks of the Week with a share price of $20 or greater, what kind of performance could we expect? Assuming that an investor could randomly select 5 different Picks of the Week over the period, the statistical breakdown is as follows:

This distribution is for 1000 random samples of 5 Picks of the Week, share price >= $20. Here we can see that the distribution is closer to a normal, bell-shaped distribution.




Minimum1st QuartileMedianMean3rd QuartileMaximum
-19.55.84512.7713.5220.7658.70



numbermeanstandard deviationmediantrimmed meanminimummaximumrangeskewkurtosis
100013.5212.0112.7713.11-19.5058.7078.200.390.75

 See full table and article at www.stocktrends.com


These descriptive statistics of categories are just a starting point. We should also take other samples of the Picks of the Week data. This simple analysis is presented to show that the RSI indicator can be modeled in different ways to optimize on specific variables. In order to develop a trading model we need to delve deeper into the variance and correlation of the Stock Trends indicators as well as other market data variables like trading volume.

This particular exercise, though, helps us look at the Picks of the Week report (which is a specific sample of stocks that exhibited a particular combination of Stock Trends indicators) more constructively in terms of quantitative trading. Although there are levels of charting analysis that help pinpoint technically attractive trades within the Picks of the Week report, systematic traders should understand the importance of discovering the variable constraints that correlate with minimizing variance in trading results. In particular, we can learn how the Stock Trends indicators can guide us toward developing effective trading systems.

Wednesday, February 20, 2013

Stock Trends Picks of the Week: a statistical look


The primary action matrix published here is the Stock Trends Picks of the Week report. These reports are groups of stocks, organized by exchange, that match a defined criteria or combination of variables. Each of these observations are results (roughly stated here) of the following query: select stocks and ETFs, valued over $2, that have a Stock Trends Weak Bearish () or Bullish Crossover () trend indicator, a minimum level of trading volume, and a Relative Strength indicator of at least 100. Those that are Weak Bearish must also have a high probability of being a Bullish Crossover within three weeks.

This weekly screen focuses on Weak Bearish and Bullish Crossover stocks and ETFs for a simple reason: this is the transitional trend moment where issues are theoretically primed to begin a new bullish trend. Although the parameters of Stock Trends are by definition lagging, the assumption is that the long-term trend has or will change category. Sometimes arriving late to the party, these selections still arrive in time to have the forces of trend work for the trade. That is the modus operandi for the Picks of the Week report.

However, the report does not filter down to deeper levels of categorizing observations, and as a result the list is too extensive to use without additional filtering. It is really up to the investor to match the trend qualities that are presented and the technical merit of each potential trade. That is an important question: how do you isolate the best trading opportunities from the Picks of the Week report?
 
The answer to that question does not come easy, and I won’t attempt to answer it in this editorial. Instead, let us just say for now that one way is to draw at random from the Picks of the Week report. Before we assign value to the report itself – never mind finding the optimal trade within the report – it is important to know how outcomes of the report stack up against random outcomes more generally. Will random selections from the Picks of the Week report yield better results than random selections from the broader population – namely, all stocks and ETFs? Surely, there should be a statistically significant difference in the two probable outcomes, otherwise the Picks of the Week report lacks credibility.
 
Before we look at comparisons between random sample performance of the Stock Trends Picks of the Week and from a broad sample of the data population, we can get an understanding of the central tendencies and distribution of random samples of the Picks of the Week report. For instance, if an investor simply bought 5 different random Picks of the Week selections – what would be the statistical representation of those choices? This kind of mean analysis of random samples is a common statistical method in probability models.
 
Let’s take a sample of the Picks of the Week report: all selections, across all exchanges, since the beginning of 2012. The sum of the weekly picks during this period is 6,599. That’s a big grouping and includes all picks right up to February 8, 2013. The inclusion of very recent Picks of the Week (those in the last month, for instance) is problematic in that it does affect central tendency and distribution of the positive returns, but not in a more significant fashion than the use of “end-of-period” returns.
 
There are obvious problems in measuring results for a given period. For instance, stocks may reach a high and subsequently retreat, thereby under-reporting possible results if a simple end-of-period statistic (based on the most recent closing price) is used. Also, in practical terms, stocks that have hit stop levels may have been sold before the end period, thereby reducing the amount lost on the trade. Nevertheless, we’ll simplify this analysis to make the evaluation on a very crude level. We are asking: if an investor blindly picked 5 different stocks/ETFs from the Picks of the Week reports at any point during the time frame and held them to the end-point (February 15, 2013), what is the mean return and what would the distribution of those average returns look like?
 
First, here is a summary table and histogram of these Picks of the Week returns (% change since selection):
 
 
 
 
Minimum value (PSN-T)1st QuartileMedianMean3rd QuartileMaximum value (SNTS-Q)
-98.3-4.06.48.67820.0274.3
 
 
 
 
 
numberstandard deviationmedian absolute deviationrangeskewkurtosis
659928.7517.64372.61.337.51
 
 
When we present the Stock Trends Picks of the Week, though, our expectation is not that every trade will be successful. However, we would like to see that the distribution of results is favourable. In practical terms, an appealing distribution will be asymmetrical, skewed positively with a fat tail to the right. While we can describe data with mathematical determinants that tell us of likely results, including simple measures of central tendency such as the mean and the median, in the end each pick represents a random sample of this subset of the larger population. We would want to see how these descriptive terms compare to the population itself.
 
We won’t make an attempt to calculate the population distribution now, but we can estimate that it would be close to a normal distribution, which would be symmetrical and possibly centered at the zero value, depending on the market’s overall direction. However, we can see that the distribution of the Picks of the Week sample is asymmetrical, that it is skewed positively – a long tail to the right. Half of the results fall with the 1st and 3rdquartile (the interquartile range)– between -4% and 20%. If an investor were to buy just one of the many selections in the Picks of the Week report since the beginning of 2011 their trade would have a greater than 95% chance of resulting in a return between -29 and 42%, which represents all those picks within 2 median absolute deviations (remember that the actual results obtained may be different in a real world scenario – profits booked at higher prices, losses capped at higher prices when a stock holding begins to retreat).
 
But putting all your eggs in one trade is not a trading plan sensible investors would endure. It is presumed that an investor would spread risk across trades. We should then be more interested in the distribution of average returns on samples of several picks. Let’s again assume that the investor makes a handful of trades in the period based on random selections from the reports (again, across all exchanges), and holds them until the end period. These mini-portfolio results should tell us something about the effectiveness of the Picks of the Week report.
 
A basic statistical method often used is sampling. By taking a random sample multiple times – actually many, many times over – we can estimate probable outcomes. Generally, this kind of resampling tends to prove a basic statistical truth: regardless of whether a statistic shows a non-normal distribution, as the sample sizes increase the statistic will tend toward a normal distribution. This is called the central limit theorem. However, let us take a first step and keep the sample size consistent with money management constraints and estimate that an investor’s portfolio would consist of at least 5 positions.
 
Bootstrapping 1,000 random samples (with replacement, since each of these samples is an independent portfolio) of those 5 selections from the Picks of the Week report generates the following histogram representation of the sample mean (average return of the 5 selected picks) distribution, as well as a summary table:
 
 
 
Minimum Value1st QuartileMedianMean3rd QuartileMaximum Value
-25.088.1117.7718.928.0690.4
 
 
 
 
 
numberstandard deviationmedian absolute deviationrangeskewkurtosis
100015.9114.83115.480.580.84
 
 
Now we see that the measures of central tendency have moved up – the mean (of the sample means) is 19% - and the distribution is closer to a normal distribution. More importantly, most of the sample means are above 3% (one absolute deviation below the median). The following box plots of the sample returns and the sample means returns give us a good graphical representation of the data.
 
 
Differences in the kernel density plots are also represented by the horizontal shape of the violin plots.
 
 
Overall, this analysis indicates the Picks of the Week reports have a good record of delivering trades with above average performance. This analysis does not go deeply enough in the data to indicate optimization and does not accurately compare against random sampling of the broad population of stocks. Nevertheless, it gives us an idea of the statistical metrics behind the performance of this particular subset of Picks of the Week selections.
 
I’ll be digging further into the Picks of the Week report and try to isolate various combinations of the Stock Trends variables and trading stats that change the returns distribution significantly from the sample’s distribution. There are some things we can learn about price momentum and how it delivers different results based on the sector, market capitalization or the price of the stock, and other variables. Applying more rigorous statistical analysis of the Stock Trends indicators will be the primary goal of editorials. Also, while there may be room for a return to market commentaries, I am the first to recognize there are many, many sources of “opinions” about the market direction. I’ll try to stick to quantitative trading analysis, and statistical meat here. In the end, the decision about trading is up to the investor. The best any information service can do is provide a framework for understanding the risk and rewards at hand. There is no certainty - but it’s a lot better to know your odds.