Category Archives: Strategies
Part 4 will focus on using Bollinger Bands for exits.
Specifically, if the bar closes outside the upper (long entry) or lower (short entry) bands, the trade will be exited on the open of the next bar. This is a very basic exit, and could easily be tweaked. For example, an exit could triggered if the high (or low) of the bar is above (or below) the bands, rather than requiring the bar to close outside the bands.
The Bollinger Bands were built around a simple (not exponential) 20 day moving average.
Let’s look at the long entry first.
Bollinger Band Long Exits
The spreadsheet below shows the results of the long entry coupled with the Bollinger Band exit.
The standard 2 deviation band works the best. The % profitable is good, but the average trade of $16.65 means that 1/3 E-mini point will be captured, on average.
The equity curve below shows the entry coupled with a 2 standard deviation Bollinger Band exit:
Bollinger Band Short Exits
The spreadsheet below shows the results of the long entry coupled with the Bollinger Band exit.
The 1.5 standard deviation band was favored by the short entry. The % profitable is very high, and the average trade shows that each trade may harvest better than 1/2 an E-mini point. Still, the win/loss ratio is very low.
The equity curve below shows the entry coupled with a 1.5 standard deviation Bollinger Band exit:
Putting It All Together: An Equity Curve of the Long and Short Entry with the Optimized Exits of 2.0 For the Longs and 1.5 for the Shorts:
Net profit of $25,200 represents an annualized return of 252.20%. The % profitable drops significantly to 57.45%. Average trade is $38.74, or not quite a whole E-mini point.
The astute observer may wonder why, when the longs and shorts are combined, the equity curve smooths out, the % profitable drops, and the sum becomes greater than the parts.
From what I can tell after looking at thousands of these trades over the last week, when the system is allowed to go long and short, it will often close a short trade and go long, or vice versa, before an exit is triggered. Basically, it stops itself out and changes direction with the trend. This hints that when I start testing stops, they might actually improve performance (it is often hard to find a system that improves when stops are added).
I think this is very very important for traders to consider, especially those who do not like to use stops. The system does not care that it took a trade in the wrong direction. When it gets a signal to go in the opposite direction, it closes out the losing trade and attempts to catch a change in the trend.
As I am running out of time to get this information out for Lazy Man to digest before the market opens, I am going to report on only one exit tonight: the RSI(2) exit.
I had to make some minor changes in the way the testing was performed. In prior tests, all trades were executed at the close of the bar in which the trigger occurred. In order to avoid some problems, I changed the code to have the exits execute on the open of the next bar. To be clear, the signal is still generated at the close of the bar, but the trade is not made until the open of the next bar. If this is confusing, let me know in the comments section and I’ll flesh it out a bit more.
The RSI(2) Long Exit
The spreadsheet below shows the results of the entry coupled with the RSI(2) long exit:
Note that using an RSI(2) exit of greater than 70 would have yielded decent results. Also note the % profitable is the best we’ve seen yet at almost 70%.
One potential problem is that the average winning trade is only 2/3rds as big as the average loser. It is possible that this will be improved when stops are added.
Below is the equity curve generated by the RSI(2) long exit.
The RSI(2) Short Exit
The spreadsheet below shows the results of the entry coupled with the RSI(2) short exit:
Similar to the long exit, exiting after an RSI(2) reading below 20 shows promise. The percentage of profitable trades is even better with some exits exceeding 70% winners. The size of the winners compared to the losers is still an area of concern.
The average trade is approaching $50.00 which means that each trade will capture (on average) one E-mini point.
Below is the equity curve generated by the RSI(2) short exit.
Longs and Shorts Combined
Below is the equity curve for the combined long and short entries and exits:
This represents an annualized return of 294.90% with a win percentage of 65.70%.
The RSI(2) trigger for the longs was set at 85 and the short trigger was set at 10.
Using an RSI exit with this system presents some difficulties. The primary problem is that an exit can executed on a bar which also fits the criteria for entry. What this means in backtesting is that the trade is closed on the open of the bar, but then re-opened at the close of the same bar. I did not re-do the code to work around this issue.
Another problem is that some trades are entered when the exit criteria has already been surpassed. For example, the system may enter long with RSI(2) that is already greater than 85. When this happens, the system waits for RSI(2) to dip beneath the trigger level (85) , and will sell once it crosses back above 85.
When the system runs both longs and shorts, a short trade is closed out if the criteria is met for a long entry. If the system is long and the criteria is met for a short entry, then the long trade is closed and a short is entered. This adjustment helped the long side trades which leads me to believe that stops might improve results when trading only one side (long or short, but not both).
Bollinger Band exits have been tested and show promise. The next installment will present the results.
Part 1 outlined the purpose of this series and established baseline results for the long entry when paired with a time-based exit, and again when paired with an EMA cross.
In Part 2 I show the results of using the short entry coupled with the same exits (time-based and an EMA cross).
At the end I include two equity curves: One with both long and short entries and the time-based exit and one with both long and short entries and the EMA cross exit.
Below is the spreadsheet that shows the results from the time-based exit for the short entry.
Compared to the results from the long entry, this is a huge improvement. Assuming 10K of starting equity, this makes an easy triple-digit annual rate of return.
Below is the spreadsheet that shows the results from the EMA cross exit for the short entry.
Not as good as the time-based exit, but still respectable. Note the win % is very low, but the average winner is better than twice the size of the average loser.
Below is the equity curve of the time-based exit for the short entry.
Below is the equity curve of the EMA cross exit for the short entry.
Below is the equity curve of the long and short entries paired with an optimized time-based exit of 50 bars for the longs and 20 bars for the shorts.
This represents an annualized return of 229.87%, assuming 10K starting equity.
Below is the equity curve of the long and short entry paired with an optimized EMA cross of 50 bars.
Note that this represents an annualized return of 185.80%, assuming 10K starting equity.
While I am well aware that time-based exits are very susceptible to curve-fitting, I am still somewhat surprised at how much they outperform the EMA cross. This seems to add weight to Lazy Man’s belief that the entry makes it possible to catch trends.
Part 3 will investigate the application of two more exits for the long entry: A RSI exit and a Bollinger Band exit.
Lazy Man began leaving comments on a recent post, Short Term Mean Reversion Still Working.
He asked for some help improving exits on a system he uses to trade futures. The comments section of the post will show how the idea for the project developed.
Because I’ve never worked on an intra-day system for futures using tick charts,Â I decided to see what I could come up with. It seemed as if it might be a good opportunity to help someone else out while providing me a chance to practice coding and backtesting.
Lazy Man’s System
For ES, a 3200 tick chart is used.
9:30am to 2:30pm entries only.
Trades are entered at the close of the first bar that trades completely above (long) or completely below (short) the 20 period EMA.
The high and low must not touch the moving average. The previous bar must have at some point traded beneath the 20 period EMA. (The entry is a variation of the classic moving average cross).
Trades are closed when any of the following are true:
2. Any bar extends to the wrong side of the MA by 50% or more.
3. He feels like the trend is over – and there is the problem – too much emotion. Lazy says he often exits too early or too late.
Let the Testing Begin
A baseline must first be established.
1 contract will be traded. $2.50 per trade commissions are included. The period tested was from 10/08/2008 to 4/09/2009.
I chose to start testing the longs first, coupling the entry with a simple time exit.
The results are in the top half of the spreadsheet below.
With the time exit results established, I then tested an exponential moving-average cross. The EMA cross exit triggers when price crosses and closes beneath an EMA. The results are in the bottom half of the spreadsheet.
Below is the equity curve that resulted from the baseline results, optimized to exit on the 15th bar.
Below is the equity curve for the moving average exit, with the EMA used for the exit optimized to 30.
So far, neither exit looks very promising.
Recent Trades are Below:
TBarsLX = 15 bar exit; LE = Long Entry; TX = 3:00 o’clock exit
I am going to keep testing exit signals until either I get bored with them, or I can no longer code them due to their complexity.
Lazy’s stops must also be tested.
Eventually, a smooth(er) equity curve may be produced.
The equity curve shows the results of buying the SPY first close beneath the 2 day moving average (dma) and then closing the long position on the first close above the 2dma. It also sells short the first close above the 2dma and covers the short on the first close beneath the 2dma. In short, it is in the market all the time, trading around the 2dma.
The system uses 10K starting equity, and compounds gains. No stop losses were abused in the making of this system.
Results do not include commissions or slippage, and adding commissions of $7.00/trade lowers the win rate to 62.2% and drops the annual return to 31.80%, reducing net profit by almost 9K.
The point is not to consider this is a viable system, but instead to observe and ponder the anomalies that come and go. I have been wondering for some time now how long it will be before this pattern changes.
If nothing else, when such a simple system works so well, for as long as this one has, I think that certainly the hardest part of trading is mastering the psychology. For example, I doubt even one person reading this has been trading a very short term moving average, religiously, despite the fact that the success of short-term mean reversion has been discussed by many bloggers.
I also wonder, if the same system was backtested during the previous (few) periods in market history where a very short term mean reversion system worked, and some ratios were developed to describe performance, with special attention applied to the ratios when it was outperforming versus ratios as it begin to fail, if a similar set of ratios would also exist for the current data.
Ultimately, the holy grail may be a simple system-health tool, able to be normalized across diverse trading systems, which would turn a system off before a meltdown. If such a tool were to exist, any new anomaly which lasted long enough to collect sufficient system-health data, could be traded.
Its fun to think about, anyway.
Cuervo has posted over in the Peanut Gallery a simple trading system he calls the 357SPY.
Nothing can quite explain how the system trades like an equity curve, so I am including one below, of the 357SPY.
For these tests, I assume 10K per trade, without compounding gains, .01/share commissions, and no stops.
The results aren’t too bad. If nothing else, with a 65% win rate over 546 trades, the 357SPY may make a good timing indicator.
Still, we can run additional tests to determine how robust a system is.
Lately I have been experimenting with Monte Carlo simulations after discovering a neat, free utility called Equity Monaco. For the more discretionary traders out there, Equity Monaco will work for you as well because all that is needed for the calculations are the profit/loss figures from each trade, in a .txt file. For example, here are the results for the first 10 trades from the the 357SPY: -198.47 22.70 -85.80 39.96 24.64 81.00 28.99 17.84 -24.53 6.66
This Monte Carlo simulator takes the historical sequence of trade results from the 357SPY and scrambles their order, (randomizes them) then puts them back together, and re-calculates the results: The profit, drawdowns, wins in a row, etc., of the sequence of trades are then recorded. It then does this 1,000 more times, recording and plotting the results of each trial.
The Monte Carlo results will help us determine if the 357SPY’s results are due to chance, or because of a legitimate edge. In the tests below, starting capital of 10,000 was assumed.
Terminal Profit Distribution shows that in 95% of the trials the 357 system made less than $22,000 in profit. However, in less than 5% of trials did it make less than ~$6,000.
Max Drawdown (%) Distribution shows that 95% of the trials had drawdowns less than 34%.
Max Drawdown ($) Distribution shows that 95% of the trials had maximum drawdowns less than $4,750.
Max Consecutive Winning Positions shows that 95% of the trials had 20 or fewer wins in a row.
Max Consecutive Losing Positions shows that 95% of the trials had 8 or fewer losers in a row.
The Equity Curves show all of the possible equity curves from the randomized trade data. Of interest here is that only 2 trials had terminal equity of less than 10,000. (Look at the very right side of the chart for the two squiggly red lines beneath the 10,000 line.) A hand-drawn best fit line looks to me as if it might end somewhere between 22 and 24K. This would represent profits of between 12-14K over starting equity. The system, as tested on Tradestation shows a total equity of $19,648.82. While this might be slightly less than we would expect, the number still falls well-within the fat part of the distribution of equity curves.
The distribution above is perhaps the easiest to understand. It shows the distribution of the raw trade data.
While the 357SPY can only be expected to earn a small but consistent single-digit return, one would likely not have lost money trading it (unless you were really, really unlucky) over the past 16 years (not including opportunity costs and inflation). In other words, one won’t get rich trading this system, but neither is he likely to lose money, if he trades it over a long enough period of time.
Of course the market is always free to undergo a regime change, which means that the 357SPY may stop working one day soon. However, the results of the last 16 years do not appear to have been achieved by luck alone.
I’ve been somewhat fascinated with a paper I found on the MarketSci blog. The paper is Returns in Trading vs. Non-Trading Hours: The Difference in Night and Day.
The paper is fascinating as it presents research showing a profitable trading strategy can be developed simply from buying the close of the QQQQ and selling the next open, day after day. The authors’ basic assertion is that the markets tend to be more bullish in the after-hours, at least on the QQQQ. Read the paper to understand why this strategy may not work as well on DIA or SPY.
Beyond presenting a profitable trading strategy, I believe the implications of the paper are that traditional strategies which trade open-to-open or close-to-close may be improved by switching to initiating positions at the close and liquidating them on the open. (This would certainly substantiate the aphorism that smart money trades the close while dumb money trades the open).
While it would be easy to take some of our existing strategies and apply a close-to-open scenario, I had hoped that I would first be able to get close to replicating the results presented in the paper. As of right now, I’m not close.
So all this build-up is not much more than an initial introduction to the idea of buying the close and selling the open, and an excuse for why I don’t have a great post tonight. Once I get closer to replicating the author’s results I will begin testing this idea across a few strategies and ETFs. Of course, I’ll share the results here.