Monday, May 28, 2012
Alligator Slippage
A while back I increased the slippage plus commissions on the reporting for this system to $45 per round trip. Since this system has fallen off of late, I've been reviewing everything including the slippage and commission impact. You can see the effect from the chart below, which is for the past 12 months, more or less. Since this is having such an appreciable impact, the effort to switch from market orders to limit orders is going to be accelerated for this system. It's difficult to judge the impact of this before hand, because of partial fills which can occur with limit orders. However, since this means you are getting your order filled without your limit price being cleared, the effect should be positive.
Saturday, May 26, 2012
A Tale of Two Strategies
The chart below shows the performance of ESCombo and Alligator since Jan 1, 2010. This performance is based on $30 slippage which is less than what I normally post on the website, so anyone making comparisons to that data may see some difference. About half of the period on the chart is post design, or out of sample. What is most striking is the recent divergence between the two systems with ESCombo shooting up and Alligator falling. Just by inspection, the advantage of trading these two systems together (ESGumbo) is quite clear, at least up until now. I can't predict what will happen, but a decrease in the divergence seems like a strong possibility. Neither the markets nor these systems move in a straight line. I certainly hope Alligator will correct up and ESCombo will just keep going, but that is putting hope over experience. The only word of caution I would offer is that moving from the cold system to the hot one most often leads to regrets.
edit: Updated mislabeled chart (05.26.2012)
Wednesday, May 23, 2012
Status Check on ES Swing
Right now the most recent trade on this system is looking good for a profit target exit at around 1220. Of course, never count your chickens....
Tuesday, May 22, 2012
ESCombo 3.0
I have taken the work mentioned in the previous post on trade filtering and applied it to the ESCombo system. This resulted in a general improvement in almost all system metrics. Most importantly, it shows better performance in the current market. This system will be published soon on siftradingsystems.com, but in the meantime here is the performance curve with a comparison to the ESCombo 2.0 system, which has been a steady performer the past couple of years.
Sunday, May 6, 2012
Real World Example Trade Filtering
The above chart show the results of a trading system trading the S&P e-mini (@ES.D). The data represents the time period from Jan 1,2000 through April 2012. The trades in this case are daily totals for a system which may do 1 or more trades per day. When the trades are plotted (blue line) you can see that it loses money. The Y axis represents cumulative S&P e-mini points net of slippage and commissions and since each point is worth $50 the system lost just over $46,000. The X axis is days. The red line is what we get when we plot the output of the regression function or Yr values. It winds up at about the same place on the chart which is what you'd expect. Of the available data, only the data through the end of 2010 was used as an input to the regression function. So, neither the post 2010 X or Y values can possibly influence the regression calculation because they were never used as inputs.
Now we see what happens when we apply the filter to the trade history. The purpose of the regression calculation is to attempt to predict what the Y values or profit will be. That trading performance can be predicted is our hypothesis. The way you test the hypothesis is to apply the correlation to new data. In this case that would be the data from the end of 2010 to the present. On the chart you can see that our filter/predictor does a good job of picking trades and produces a very nice looking upward trending net profit curve. That's nice, but not all that hard to do because the Yr values were fitted to the historical data through the use of the LINEST function. The real test is what happens when the trade filter is applied to new data. The new data in this case is everything after the red dot on the chart. That fact that the performance in the out of sample period is very similar to the performance for the in sample period can be taken as evidence that our trading hypothesis is valid.
You may be thinking, well, this was just luck because perhaps the OOS trades just happend to be from a period when the system was profitable irrespective of filtering. But, if you look at the unfiltered trades, which include all of the data, you can see this was not the case.
This, in a nutshell, is the entire basis for my trading methods.
Trade Series Optimization by Regression Filter
I'm starting a series on something I call Trade Series Optimization by Regression Filter or TSOBRF. Any trading system will produce a time series of trades which may or may not be profitable. Even if it's unprofitable, as long as some of the trades are profitable, it may be possible the make the overall system profitable by screening out or filtering the losing trades. To construct a filter it is necessary to have some data, as much as possible, which may be giving an indication of whether a particular trade is likely to be a winner or a loser. It is important that the data we are going to use to make the filter (X) be completely independent of the trade series (Y). What this means is that the X data must precede the Y data in time. If you wish to try to predict what the market will do today, you may only use data from the previous day or data that existed prior to the market open for the same day. Note that this is not the same as saying the Y values must be independent of the X values. We hope the opposite is true.
In the spreadsheet image below is a simple example of how to set up the filter calculation using Excel.
The data in this is example are all random numbers and have no connection with any market or trading. It's just to show how to construct a filter.
In Excel there is a built in function called LINEST. LINEST uses least squares analysis to find a first order equation which best fits known data. Its inputs are the independent variables (x values) which hopefully are drivers for the dependent variable or Y values. In this example, the X values are in the columns labeled X1 through X5, rows 12 through 19. The dependent or Y values are in the Y column in the corresponding rows. When we apply the LINEST function to our data set, its output is stored in the spreadsheet cells beginning in cell B2 down to cell G6. The LINEST function returns a lot of values, but we are only concerned with the ones in the first row. The values in the first row are the coefficients of an equation of the form y = C1*X1 + C2*X2 + C3*X3 + C4*X4 + C5*X5 + b. The LINEST output are in reverse order of the inputs, so I have reversed them in cells A8 through F8 so that they correspond directly to the X values in the cells below. The value b is a constant. So now we have an equation which fits our data as best as we can using a first order equation.
We then apply the equation to the X values one row at a time and put the result of this calculation in the column Yr. If our curve fitting were perfect, each value in column Yr would be exactly the same the correspond value in column Y. However, because this is just some random numbers it's hard to get any kind of fit at all. But, as a check on the calculation we sum up the values in columns Y and Yr for rows 12 through 19 and we see that the sums are exactly the same. If these sums are not the same, then some thing is wrong with the calculation.
What is happening is that this equation produced by the regression analysis is trying to predict what the Y value should be for a given set of X values. Because the data are random, it can't really do this, but it is still trying to give us an indication of what we might expect Y to be based on a given set of data. If the Y data were trading results, then we would want to take trades when the Yr values are positive, i.e. the trade was profitable. So, we now filter the trades by taking only the ones where the Yr values are grater than zero. We thus filter the values from column Y and put them in column Yf when the value Yr is greater than zero. When this is done and we sum up the Yf values we see the total is plus 15 whereas the total of all the trades is minus 9. If you get to this point and the sum of column Yf is still negative, then there little more you can do. Your theory about the relationship between the X and Y values must have been wrong. But even if your theory is wrong, you may still see a correlation as we do here with totally random data. In the next step we put the filter to the true test by applying it to data it has not previously seen.
In rows 21 and 22 we have two more data points which were not used to develop the filter. If we apply the filter to this out of sample (OOS) data and the filtered trades are positive then we may have something. In this case our OOS trades were +3 and -9, but the Yr values are both greater than zero, so the trades are selected, i.e. in actual trading we would have taken these trades. However, the sum of the trades is -6, so the filtering process did not produce profitable trades, and it's back to the drawing board.
I the next post I will show an example with real world data.
The data in this is example are all random numbers and have no connection with any market or trading. It's just to show how to construct a filter.
In Excel there is a built in function called LINEST. LINEST uses least squares analysis to find a first order equation which best fits known data. Its inputs are the independent variables (x values) which hopefully are drivers for the dependent variable or Y values. In this example, the X values are in the columns labeled X1 through X5, rows 12 through 19. The dependent or Y values are in the Y column in the corresponding rows. When we apply the LINEST function to our data set, its output is stored in the spreadsheet cells beginning in cell B2 down to cell G6. The LINEST function returns a lot of values, but we are only concerned with the ones in the first row. The values in the first row are the coefficients of an equation of the form y = C1*X1 + C2*X2 + C3*X3 + C4*X4 + C5*X5 + b. The LINEST output are in reverse order of the inputs, so I have reversed them in cells A8 through F8 so that they correspond directly to the X values in the cells below. The value b is a constant. So now we have an equation which fits our data as best as we can using a first order equation.
We then apply the equation to the X values one row at a time and put the result of this calculation in the column Yr. If our curve fitting were perfect, each value in column Yr would be exactly the same the correspond value in column Y. However, because this is just some random numbers it's hard to get any kind of fit at all. But, as a check on the calculation we sum up the values in columns Y and Yr for rows 12 through 19 and we see that the sums are exactly the same. If these sums are not the same, then some thing is wrong with the calculation.
What is happening is that this equation produced by the regression analysis is trying to predict what the Y value should be for a given set of X values. Because the data are random, it can't really do this, but it is still trying to give us an indication of what we might expect Y to be based on a given set of data. If the Y data were trading results, then we would want to take trades when the Yr values are positive, i.e. the trade was profitable. So, we now filter the trades by taking only the ones where the Yr values are grater than zero. We thus filter the values from column Y and put them in column Yf when the value Yr is greater than zero. When this is done and we sum up the Yf values we see the total is plus 15 whereas the total of all the trades is minus 9. If you get to this point and the sum of column Yf is still negative, then there little more you can do. Your theory about the relationship between the X and Y values must have been wrong. But even if your theory is wrong, you may still see a correlation as we do here with totally random data. In the next step we put the filter to the true test by applying it to data it has not previously seen.
In rows 21 and 22 we have two more data points which were not used to develop the filter. If we apply the filter to this out of sample (OOS) data and the filtered trades are positive then we may have something. In this case our OOS trades were +3 and -9, but the Yr values are both greater than zero, so the trades are selected, i.e. in actual trading we would have taken these trades. However, the sum of the trades is -6, so the filtering process did not produce profitable trades, and it's back to the drawing board.
I the next post I will show an example with real world data.
Thursday, July 7, 2011
Sick Alligator
The new Alligator system had one its worst months ever in June. Like anyone, I began to question the system and try to understand why it did so poorly. One of the things that can happen in designing a system is to simply arrive at too good a fit to the historical record. The easiest way to do this is to just keep adding different indicators like moving averages and stochastics and optimizing them until you have a really good looking backtest. With enough degrees of freedom it's possible to build a system from nothing. I don't think that's what we've done, but some things can creep in, even with the best of intentions. To evaluate whether this was the case, I re-optimized most of the optimizable parameters for the past 12 months instead of using the past 12 years as I would normally. I was able to make the system produce a higher net profit, and I could reduce the drawdown over the past two months, but I could not make it go away. And, when I was done, I had a drawdown that was almost as large, but in an earlier period. So, it's not merely a over-fit problem.


This system was built based on studying market characteristics over a long period of time and then trying to build a system that models that behavior. Of course, the past is not always prologue, but I believe markets such as stock index futures are going to exhibit some of the same behaviors in the future as they have in the past.
So what is the behavior we're talking about. Two of the things Alligator is based on the tendency of gaps to fill, and the tendency of markets to have choppy days where the price moves up and down, but does not really go anywhere. Much of this is related to a statistical phenomenon called "regression to the mean", which just means that measured variables tend to go back toward the middle of their typical range when they are near the outside of their range.
June was an unusual month in two important respects; the number of days when the market moved out side of the opening bar range and never came back was unusually high, and the number of days in which gaps were filled were relatively low. You can see the data in the following images (click to view).
In June 2011, there were 14 uni-directional days. This means the market moved away from the opening bar range 14 times and never came back. Uni-directional days are bad for this system because it results in a lack of "chop" which we are depending on for part of our returns. There are only 20 trading days in a month, so 14 is a high percentage, and more importantly, you can see from the histogram that 14 is in the right hand tail of the distribution curve. It's not as if it's never happened before, but it's not normal.
Gaps fills were below normal which you can see in the other chart. Historically, gaps fill about 14 times per month, and in June, 2011 we only had 11. These are not 100% gap fills, but only that which is required to reach the exit price for a trade entered at the open. This system always fades the gap, if it trades them at all. This month was not a complete anomaly, but it was definitely a negative for the system.
Any system is going to have bad spells which are going to result from the kinds of events mentioned here. It cannot be avoided. I'll be watching carefully to see what happens next.