Archive for the ‘System Trading Musings’ Category

Rusty Apple

October 2, 2009

The main objective of system trading is to create a trade system that has predictive value and can make money for years to come. If a system historically doesn’t make money, it’s not worth pursuing. Or is it? In the curious world of trade system development, some have stumbled upon good trading systems by fading their original idea, which performed so abysmally that you couldn’t lose that much money unless you started throwing it out the window as fast as you can. System trading can also provide other insights into market behavior that, if not yielding a tradeable system, can at least give you some ideas about developing one. From the twitter world, I got the following idea from AshRust: How about each time the VIX spikes X% buy AAPL, then sell after 5/15/30 days w/ 10% stop loss? It’s an interesting idea that’s contrarian and uses intermarket analysis to trigger a long trade. Does it work? Can you trade it? Or is it nothing more than a curious data-mined notion? (more…)


Trade your Equity Curve

September 24, 2009

System traders understand that their approach to trading requires nerves-of-steel patience while in a drawdown, gut-wrenching discipline in taking every signal generated by the system (and I mean every signal – no ifs, ands, buts or maybes) and cat-like reflexes in executing signaled trades before doubt can creep into the kernel regressing, quadratic equation. Whoever said that system trading takes the emotions out of trading doesn’t know the half of it. Doubters and skeptics of system trading recite the ‘past performance doesn’t guarantee blah, blah, blah’ mantra, refer to the perils of overfitting and data mining, and express a general independence from the enslaving nature of system trading. Well, you’ll be happy to know that you can be a system trader and not take every trade. How? Trade your equity curve. (more…)

Expected Drawdown on 50/200 Cross

June 29, 2009

After running a single backtest on the 50/200 cross for ES futures going back 25 years, we found that the maximum drawdown for the system was $81,425. This is an intraday drawdown that the historical simulation experienced. But what if by some wild chance, history does not repeat itself and the trade sequence in the future does not mimic the past?

In our historical simulation, there were 17 losing trades and 10 winning trades. The first ten trades ran in the following order: winner, loser, loser, winner, loser, loser, loser, winner, loser, loser. I can type out the order for the entire 27 trades in the system, but you get the idea.

What’s to say the order of wins and losses will be exactly the same in the future? Answer: nothing. In fact, we’d be very surprised if the next 27 trades followed the same order as the first 27 trades. The fact that the first 27 trades fell as they did is completely the result of luck. And the equity curve derived from this order is also the result of luck. If we are to derive a reasonable expectation of what our drawdown could be going forward, we need to take out the element of luck. How do we do that? We randomize the trade order. Enter Monte Carlo simulation.

Think of this as shuffling cards, and taking a snapshot after each shuffle. All black cards are winners and all red cards are losers. We have the deck stacked with 17 red cards and 10 black cards. For those with statistical savvy, you’ll recognize there is not even a valid sample size of 30 to draw statistical inference from in our exercise. At this point, we’re just going through the process, and make no claims about the validity of the 50/200 cross as a tradeable system.

Since I use TradersStudio, the following is Monte Carlo data derived from the software. I’m also using a Monte Carlo Test macro designed by Rich Denning, who was kind to contribute the macro in a recent issue of TASC.

First, let’s take a look at the original equity curve for the system:

After running the Denning Monte Carlo macro, we have the following distribution chart. The Y axis is the total number of trades sequences that have fallen into the X axis bin. The X axis is the level of drawdown. You will notice that most of the trade sequences (about 108) had a drawdown of $99,760. The total number of trade sequences run were 1,000.

Finally, here is a terminal report that shows what the drawdown expectation is given different confidence levels:

Since our distribution is not normal, we have limited utility for standard deviation in determining confidence levels. Instead, we take the percent of simulations to find the interval. This takes into account the kurtosis natured skew of our distribution.

What’s interesting is that our historic simulation’s max drawdown of $81,000 is quite a bit below the average of $104,000 and the median of $128,000. In fact, we really shouldn’t get too excited about the drawdown on this system until it exceeds the 95% level, which is $149,000.

As stated earlier, these statistics are more or less a practice run of the process and a definition of best practices in systems development. It’s clearly almost ridiculous to draw any statistical conclusions from a system that averages about one trade per year.

50/200 cross in SP Futures

June 25, 2009

If someone were to buy and sell ES futures over the last 25 years based on the 50-day simple moving average crossing over the 200-day moving average, what kind of results would they get?

Below is a table that represents the statistics of this simple trade:

Now if we were to optimize the parameter set and run permutations, would the results improve with different parameter sets?

I ran 112 permutations with the fast average ranging from 30 to 100 in steps of 10 and the slow moving average ranging from 120 to 250 in steps of 10.

Next I plotted the slow average against the fast average and then used Net Profit as the third axis. This yielded an optimization space that is depicted below:

Below is the optimization space based on the Pessimistic Return on Margin objective function. Notice that the 50/200 cross stands atop a lonely hill that represents a local maxima, but not the global maxima.

How to Create a Trading System

March 27, 2009

It’s simple, but not easy to create an effective trading system that has a positive expectancy of success.

And if you’re like me, you don’t mind skipping a few steps along the way to get to the exciting aspects of your system, that being its execution with real money. Ah, but it will cost you to skip steps. It’s like putting flour in the oven to bake a cake, even before you mixed in the sugar, eggs and milk.

Here is a recipe for creating a trading system. It has six steps. After that, you get to trade it with real money. You get to eat the cake you’ve baked.

1. Observe Patterns

Markets have recurring patterns that are reflections of the psychology of its participants, namely other traders. You can observe these patterns by simply looking at candlestick formations or by seeing how a technical indicator such as RSI responds when a price action develops. You need to notice something is happening. You need to listen. You need to be aware of your surroundings and what is happening in the moment. Remember that you have no money on the table at this point so the chances of your vested expectations clouding your observations is minimal.

2. Quantify Your Observations

Every time the 10-day simple moving average crosses the 30-day simple moving average, the price action follows in the direction of the cross. Well, maybe not always but mostly always. How can I quantify that observation? Simple. IF the 10-day crosses the 30-day to the upside, THEN price action will likely be bullish. IF the 10-day crosses the 30-day to the downside, THEN price action will likely be bearish. You will notice the use of the word ‘likely’. How likely is ‘likely’. That’s what we’re here to find out.

3. Define a Trading Criteria or Method

Based on our moving average crossover observations, we would like to exploit the price action to the upside and downside, depending on what the market is telling us at the time. A system is a specific procedure for entry, stop and exit. I don’t like the “R” word (‘rules) because of personality issues I have, but you can certainly use the “R” word if you are not prone to a blatant, rebellious penchant for breaking rules. The important thing is to feel comfortable in your own skin here. Your system must be specific or the data you’re about to glean will be rendered meaningless. If you are not consistent in execution, you will get statistically invalid testing results. This is the science part of trading. So it can run like this: IF the 10-day crosses the 30-day to the upside, THEN I enter on the open of the next 5-min bar, stop 0.30 Average True Range (ATR) below, and exit when the 10-day crosses the 30-day to the downside. There, that was simple, no?

4. Do a Backtest of 30

Thirty is generally considered the minimum sample size to get even remotely valid probabilities. With this size you can calculate average wins, average losses and compare the two for an expectancy ratio. Now, backtesting is kind of a chore. Actually, it is a chore and probably nobody really takes pleasure in this step. There will always be the few that do enjoy this part of the process, just like there is always someone that takes great delight in measuring a cup of flour. Regardless, we are going to do this thing.

Apply whatever studies you used in your previous observation and go back in time on your charts. Wherever you system says to go long, jot that number down, jot down the stop number and then observe where the system exited, whether at the stop or at the exit. Now do that 29 more times. Add up your winners versus your losers. Calculate your average winner versus your average loser. Now do simple math. Expectancy = (% winners x average winner) – (% losers x average loser). If this number is not greater than zero, throw that strategy into the trash can. If it passes the smell test, move to the next step.

5. Do a Backtest of 100

Repeat the top exercise but this time you’re investing more time to get a more statistically valid sample size. If the results still yield better than zero, go to the next step.

6. Paper Trade the System for 100 trades

This one is pretty hard for a lot of us. Paper trading is bogus and a waste of time, we tell ourselves. You don’t get the same emotional conflicts with paper money as you do with real money. That’s all true, but that is also the point. We will use results from paper trading to measure the performance of real money trading later on. Airline crews don’t jump into a new jet before executing procedures in a simulator. That’s done for some very good reasons. Once we’ve completed our 100 live paper trades, we compare it to our backtest of 100 samples. Were the results as expected? Good, it’s time to eat your cake.

7. Trade Real Money

Everyone loves this step. We now execute 100 trades with real money. Don’t stop after 7 trades just because the first 6 were losers. You’re violating the statistical requirements of your analysis. There is a random distribution of each trade, but patterns develop after a significant sample size. Now compare your real money trades to your paper money trades. Similar? You probably did worse with real money and the reason is you are prone to execution errors when real money is on the line, just like our free-throwing NCAA basketall star is with 1 second left on the clock and down by 1. The difference between your paper results and your real results represents what you need to learn.

We’ll take on trader psychology at another time. In the mean time, enjoy the bounty of your trading system as you become wealthy beyond your wildest dreams.

Trade System Bravo

March 18, 2009

Trade System Bravo is my second ‘work-in-progress’ on developing a trade system with positive expetancy.

The chart is based on 30-minute Heikin Ashi candlesticks. They’re painted grey and black instead of red and green to tone down the emotional force behind traditional candlesticks.

The price band around prices is a Keltner band. These bands are based on Average True Range (ATR) and instead of containing price action, they signal breakouts. When price action closes outside the Keltner channel, it has a higher probability of continuing in that trend. The above chart is today’s EUR/GBP currency pair. The signal for entry is a candle closing completely outside the channel. The stop-loss is the channel boundary plus pip spread plus five pips.

The above chart triggered long entry at 9260, with the stop-loss set at 9235. Based on the definition of the stop-loss, you can see it moves up with price action. System limitations prohibit ‘loosening’ a stop once it is set. So 9235 is the lowest stop-loss permitted for the trade, but not the highest. The stop-loss is currently 9282 based on its breakout.

Indicators in lower studies include RSI and the Trendicator. The Trendicator is my super-secret proprietary indicator that shows trend.

The system’s procedure for entry and stop-loss placement is simple and clear. What is not clear is where to set the limit. A moving stop-loss is one option for setting a limit. On the above trade, it would lock in a 23 pip profit at this point. But is there another exit indicator that can maximize profits? And what would that indicator be? Maybe two Heikin Ashi candles closed against the position? Maybe an RSI value? Maybe a Trendicator value?

Where would you place your limit on the current winner?

Trade System Bravo is a work-in-progress. I’ve traded it twice. Once for about 100 pip profit, another for about 30 pip loss. I have not backtested it yet. And I’m not in the EUR/GBP trade illustrated above. Realize that two trades is obviously a small sample and not statistically valid. I’ve heard 30 is the minimum number of data points to draw statistical conclusions, but obviously the more the better.

Trade System Alpha

February 11, 2009

The Trade System Alpha is my first formalized trading system. And yes, it’s not for sale.

I hold the belief that a trade system should be unique to the trader. Ideally, nobody should know about how it works in a meaningful way except for the trader.

My Trade System Alpha is designed for day trading setups. It uses the 5-minute to enter and exit trades. Here are the list of technical indicators used:

1. Heikin Ashi candlesticks. Used in conjunction with a moving average to trigger entries and exits.

2. Moving Average. Type and length confidential, but as stated above, it triggers entries and exits.

3. Donchian Price Channel. Length and displacement confidential. It’s main purpose is situational awareness.

4. RSI. Length confidential. Situational awareness as to the oversold/overbought condition.

5. Trendicator. Proprietary and confidential indicator. Confirms entries by indicating the current trend, and its strength. It may be difficult to gather from the picture above, but the Trendicator has four states: Green and above, Red and below, Yellow and above, and Yellow and below.

This system should be considered mostly discretionary since it isn’t in the market all the time, only when I choose to put a trade on. And though the entries are pretty clear cut, I take discretion in taking a trade.

The stop loss is set at a market-defined location where the chances of my trade working out start decreasing. I will also exit a trade before it hits my stop loss if it’s not setting up as expected. Again, kinda discretionary.

Trade System Alpha is my attempt to reduce random trading. It’s not a rules-based system in the true sense, but it is a framework that has a positive expectancy.

Once you set up your own trading system, you’ll find that losses are simply the cost of doing business and have nothing to do with you being right or wrong. In a twisted way, you can look forward to losses because you know your odds increase on the next trade being a winner. We can get into the statistical validity of that being the case if you’re not always trading, but let’s leave that for another time.

Good luck setting up your own trade system. And don’t get caught up in the phrase ‘trade system’ like I often do with certain phrases. You get the idea. Call it a system or criteria or whatever. As long as it’s not random dart throwing.

Stress testing in real time with real money

January 30, 2009

The market has a fee it likes to charge you to show you where your trade system is weak. This week, my bill came to 52 pips times three contracts, or $156.

A little background for this week’s classroom:

I have a trade system for day trading forex that includes four studies.

On the actual price chart (candlesticks) are two studies:

1) Donchian Channel (for situational awareness)
2) 21 EMA (for situational awareness)

On lower studies are two studies:

1) RSI (for situational awareness in executing entries and exits)
2) Super-secret proprietary indicator (SSPI) used for triggers.

A quick note on SSPI. It is a momentum oscillator, trend identification histogram developed by myself.

Here’s how the trade sets up:

Daily trend defines the major trend, and its strength the probability of continuation. Smaller time frames indicate if a countertrend is underway or if the trend is firing on all cylinders.

Trades are entered on the 5-min chart using the SSPI. For example, if daily, 60, 30, 15 all show a downtrend, wait for a counter rally in the 5-min to begin petering out before entering.

The way trades were closed for a loss was when the 5-min closed and the SSPI showed me to be on the wrong side of the trade.

On Jan 27, I got long the NZD/USD (Kiwi) pair. The daily trend was down, but a strong counter rally was underway in the 60, 30, and 15. The 5 showed the counter rally was taking a breather — perfect time to enter long. I knew a Fed announcement was coming so I was monitoring the situation. The announcement came, and nothing. Fed keeps rates at 0.25%. Okay, now let’s get back to our regularly scheduled counter trend rally. Next thing I see is RED. Big RED candles and heart palpitations commence.

My SSPI was designed to keep me out of whipsaws so I needed to wait for a 5 min close to trigger me to close for a loss. Meanwhile, losses are piling up in triple time. I wanted to throw my system out and close for a 60 pip loss, but I’ve been down that road too many times, where I close a trade at the absolute worst price before it moves in my direction. So I wait. I ask myself, what the hell is going on here? (confusion not a good sign), It’s got to stop this f#$%ing free fall, right? (hope, another bad sign). Finally, my system tells me to go to guns and close the trade. It’s over. Using RSI and 1-minute charts I wait for retracement from solid red so I’m not the greatest fool. It comes. Execute. I’m out. 52 pips. Holy hell, what just happened?

Some well-meaning readers may suggest I create a rule to remain flat in currencies during Fed announcements, but I don’t believe in rules. Rules are a way to surrender your responsibility to some ink on a piece of paper that glares at you as it rests near your monitor. And anyways, you’ve been breaking rules your whole life. What makes you think you won’t find a way around your new rules? As far as I’m concerned, they’re useless.

No, I’m not gonna make a stupid rule. I’m gonna stop trading today. Trading when you’re confused, upset, angry, disappointed or generally pissed-off is random trading, and we don’t like to do that anymore than we like eating glass.

Two days later I look at the charts with my studies again. You’d be surprised what you see when you don’t have the stress of a trade on. Right before my eyes, the RSI warned me that there was an oversold condition underway, way before my trigger. So easy as pie, I have a new stop loss exit procedure:

Exit a trade for a loss when SSPI indicates your on the wrong side of the trade, or if RSI moves to an oversold/bought condition against you, whichever comes first.

Tuition well spent.

not that it matters, but after the fateful exit, the Kiwi fell another 100+ pips in the next ten minutes, and closed the week about 125 pips below my exit.