Fatty Fat Fat

Valuable Pearls of Wisdom From a Fatty :: An Alternative to High School Education.

Fatty Fat Fat header image 2

Automated Day Trader: Double Moving Average Crossover, Test 1

October 17th, 2008 · 13 Comments

Using a modification of a double moving average crossover strategy and applying the 12/26 period intervals recommended by most MACD indicators, I let an autotrader loose on the S&P500 over a 2-day period.

Trading the S&P500 December future contract (ES8Z) on the Chicago Mercantile Exchange, I sampled price every 5 minutes, used an Exponential Moving Average (EMA) with a decay factor of 10% *, yielding a 60 minute/130 minute EMA double crossover strategy. The ES graph with EMA double crossover lines is overlayed is pictured (click it for a more reasonably sized image)

The blue line is the shorter-term (12-period) EMA and the red line is the longer-term (26-period) EMA. The simple strategy executed was to always carry a position of either long 1 future or short 1 future, determined by the relative position of the short term EMA to the long term EMA.

Visually, whenever the blue line is below the red line, the strategy is short one future; whenever the blue line is above the red line, the strategy is long one future. To test for crossovers, I just found the direction of (red-blue)*(previous red-previous blue). Negative values indicate crossovers, and whenever this triggers, it generated a market order to buy or sell a futures to invert the existing position. **

Trade Period Statistics:

  • Winning Trades / P&L (in points): 4 winners / 18.5, 40.25, 11.5, 2.75
  • Losing Trades / P&L (in points): 3 winners / -1.5, -2.5, -9
  • Total Raw P&L: 61.5 points * ($50/point) = $3075.00
  • Net P&L: $3075.00 less 33.60 in transaction costs = 3041.4
  • Total Trades: 7
  • Total Transactions: 14
  • Total Transaction Cost: 14*2.4= $33.60
  • Total Time in Market: 26 hours, 40 minutes
  • Profit Rate: $114.05/Hour **

In retrospect, there are a lot of ways I could have gotten burned in this experiment. I had a strict “quit after $3500 loss” safeguard built in, but other than that the method itself does not guard against extreme loss. For example, a highly volatile short term price chart with 100 point moves in relatively short time periods (imagine a cycle around 2 hours) would have caused this strategy to rapidly hit my $3500 loss limit. The periodicity of large moves should certainly be a factor when determining the sampling and EMA duration.

I am a fan of the double moving average crossover strategy for its simplicity, but do NOT believe it is a good strategy for all market conditions. In the current volatility environment, I think it can prove profitable though. It certainly deserves to be tweaked a bit more and have some better safeguards built in, which is my next objective.

Included: 10152008 Spreadsheet shows the same data as the graph above, trade entry/exit points, and P&L per trade.

* In retrospect, 10% is probably higher than I want to use. Not much thought was given to this number, except that in the example of EMAs I found, the author used 10% as well.

** The profit rate statistic is the most spurious statistic of all those I listed. It has no meaning whatsoever, but I like to fantasize that I may really earn that. In fact, all the above may be based on luck.

Read more about building an automated trader
Automated Day TraderMy initial statement of intent to design/research/implement an automated trader.
Automated Day Trader: Ignoring Non-Trade IndicatorsSimplifing assumption to ignore news and such and focus only on price behavior.
Automated Day Trader: Double Moving Average Crossover, Test 1My first test in the marketplace, implementing a very primitive strategy. In retrospect, it was a hasty and bad decision, but I was impatient to do something. I got lucky. Basic statistics on my first 48 hour trading period.
Automated Day Trader: Tools IB for execution, Excel/Matlab for all my number crunching.
Automated Day Trader: Most Technical Analysis is Crap Why technical analysis isn’t real, but it is. And why I’m trading a strategy that I don’t have 100% confidence in the theory that supports it.
Automated Day Trader: MomentumMomentum seems better than identifying peaks and valleys to me. Bonus: momentum indicators are easier to program than some sort of shape recognition algorithm.
Automated Day Trader: Double Moving Average Crossover: UdateAn update and my more recent thoughts about moving average crossover strategies.
Moving Average Crossover: AnalysisThe day I retired the autotrader so more research could be done. Thoughts for further research.
Moving Average Crossover: Backtesting SPX Backtesting SPX data using the first moving average crossover strategy. This methodology was later employed to pre-test all of my strategies, rather than diving in blindly like my first run.
Moving Average Crossover: Optimization BasicsBasic theory for optimizing a primitive moving average crossover. Introduction of stops and other features to improve moving average crossover performance changes this, but its a start for the uninitiated.
Moving Average Crossover: TheoryA more in depth discussion of theory, from the perspective of standard market theory and some numbers with backtested strategies. This is the post I wish I had read before I ever started dabbling in autotraders.

Tags: Experiments · Money

13 responses so far ↓

  • 1 Ricardo Niederberger Cabral // Dec 8, 2008 at 11:55 pm

    Very interesting experiment. Where do you get historical data for doing backtesting before letting it loose?

  • 2 Rocko Chen // Dec 9, 2008 at 1:22 am

    Quit while you’re ahead. Random price drifts do not offer long term positive expectancy; this kind of scheme would take large losses as soon as volatility changes.

  • 3 fatty // Dec 9, 2008 at 2:20 am

    Ricardo:
    In truth, I was a moron the first time and didn’t backtest sufficiently. I was actually just gambling.

    When I do backtest, I use bloomberg for historical data and test mostly in Matlab,

  • 4 fatty // Dec 9, 2008 at 2:23 am

    Rocko:
    I think you’re mostly right. I also believe that its largely not a positive expectation strategy. I disagree with the notion that it is really a formula for large losses with changes in volatility.

    I think that at worst, the strategy is zero expectation before costs, with a negative expectation due to trading costs/bid-ask crossing.

    I also believe that these strategies are certainly not applicable all the time, but may be appropriate for certain volatility conditions. Identifying the right conditions is more critical to the algorithms success than the code itself (which any high school programmer could figure out).

  • 5 Andrew Vorobyov // Dec 9, 2008 at 7:55 am

    :) guys - it’s not working, only on back tests. There is no money making machine.

    Truth about auto trading systems - you CONSTANTLY need to adjust them to be profitable and majority of them sucks.

  • 6 Anonymous Coward // Dec 9, 2008 at 4:23 pm

    There is a very big difference between back tested systems and actually implemented systems.

    I have yet to see someone implement a *profitable* MACD auto trading system. The system is simple enough, actually, too simple to work.

    Do you really think that if MACD’s were profitable, anyone would work for a living? Well, chances are yes. But you get the point.

    There’s also the fact that post-market prices don’t reflect what you can possible get in a live setting. You’ve got a few factors to consider. I’m willing to be you assumed that you would place trades at 16:00 (ish, at more or less close price) … but, then there’s slippage, partial fills, he market actually closing (if you’re not direct access).

    IMHO, automated trading isn’t all about having really complex options pricing algorithms and what not. I also like the simplicity factor here. But you can’t rely on just one indicator, you should use a few, and only pull the trigger when a few go off. The point being that simple indicators will, more often than not, won’t give you much of an advantage, but the more you got, the more of an edge you get.

  • 7 fatty // Dec 9, 2008 at 8:13 pm

    Anonymous Coward:
    1. love the name
    2. i think you’ve hit the nail on the head with regards to simplicity. you can design all day long, but at some point you start over-engineering a problem that can’t really be tweaked anymore. plain moving averages is as simple as it gets, and i certainly agree that more criteria should be implemented than just that, but its important to know when to stop.

  • 8 John Nelson // Dec 11, 2008 at 12:22 am

    Rule-based systems based on technical indicators will not work. I am not saying this because I trust the pseudo-scientific ramblings of EMH peddlers (just read the assumptions underlying most models for a good chuckle); I am saying this because I have tried MANY of these style systems with no success.

    That being said, don’t stop trying. You learn more about markets by trying lots of things that will, in retrospect, seem hopelessly naive. It’s part of your traders tuition.

  • 9 Rich Life Carnival #19 - Money Blueprint Edition | Rich Life Equals Better Life // Apr 7, 2009 at 12:29 pm

    [...] presents Automated Day Trader: Double Moving Average Crossover, Test 1 posted at Fatty Fat [...]

  • 10 Jestsmirldise // May 4, 2009 at 5:40 am

    Skymnmoma turequiex

  • 11 hentai rape game // Jun 14, 2009 at 7:25 pm

    nice! i’m gonna make my own journal

  • 12 detounlidlift // Jun 15, 2009 at 5:25 pm

    For centuries families and nations have used coats of arms as ways to describe themselves and what they stand for.
    Imminfurf

  • 13 teen incest vids // Jun 28, 2009 at 6:26 pm

    eh. really like it :)

Leave a Comment