Trading Is Not Psychological Rehabilitation Therapy

If you’ve ever blown-up a trading account, the shrapnel has likely wounded you on a permanent basis. After you’ve finished crying (there is not crying in trading, by the way, so you know) or completed your house remodeling project vis-a-vis your fist or heavy airborne objects thrust upon the wall, you will find yourself lying on your linoleum floor, smelling of cheap scotch, unshaven and distraught. This is where you need to be, before you move on. There is but one thing to do amongst the awful smells. Realize that markets don’t care what you think and the best you can do is trade probabilities. Yeah, you’re the House baby!

So, with this great insight you look for set-ups, set your stops — the place where you quote — know you are wrong — and quickly take profits on a small portion of your position while letting the other half (or third) r-i-d-e. You are on the road to recovering from your damage. And you feel good. Sort of. Maybe you publish a book, and then you reinforce your goodness feelings. You’re managing risk and taking profits and letting profits run and … ultimately trying to heal your wounds.

Do what you need to do. But consider that maybe you don’t need to follow the Psychological Rehabilitation template to trade. There are no police officers pulling you over for trading without a seatbelt (metaphor for stops). If you control the size of your trade and have a ‘healthy’ appreciation for market volatility, you don’t need stops. It’s not reckless, unless you’re reckless. And if you’re reckless, Psychological Rehabilitation trading will do you no good.

robot (SPX) = $

Not that there is anything wrong with the peasant trading method of marking up charts with targets and stop losses, but if that’s all there is to trading, I’d rather open a small bakery or work as an airline pilot. Or maybe make artisan cheese with milk from my own organic cows. Extracting money from markets is fun, exciting at times and generally satisfying for what it is, but the drudgery of hearing over and over about keeping your losers small, letting winners run, managing your risk with stops … ugh. You plan on doing this for how long again? No, for me there is just not enough there there to keep it stimulating. But once you start talking about algorithms and trading bots, now you’ve got my attention. Imagine a world where your little (or not so little) army of algorithmic robots are marching across the trading landscape and pillaging profits from semi-proficient chartists. Hmm, now that sounds like fun.

The linchpin of this trading fantasy is a good algorithm, of course. And getting your hands on one is not a simple task. You pretty much need to build it yourself. But this is the fun part you see. One should expect a little challenge and a high threshold for success. Skill acquisition involves getting re-acquainted with higher math and getting some solid programming proficiency under your belt. From my observations, the best languages to focus on include R, C#, Java and Python. I’ve personally chosen to focus on C# and R, and will attend to the others when time permits. R is quite nice as it is free and has a robust financial geek culture surrounding it. It’s true that this community has a few participants that have only a vague understanding of trading, but you’ll find that to be true at most prop firms anyway. And our friends in R world are quite smart in the programming department.

C# is a managed version of C++ (which is an object-oriented version of C) and the reason for choosing it is mostly because of the many C# neural network scripts out there. And because adaptive system solutions are deployable as Windows applications. Also, because it, like R, is based on a capital letter of the English alphabet.

For your higher math education, focus on statistical learning and its computer-science cousin known as machine learning. These two approaches share many things in common but they like to call things by different names. I don’t know, just to be different I suppose. You may find some interesting video lectures on everything from Bayesian inference to Support Vector Machines at videolectures.net, a treasure trove of highly educational videos.

Armed with programming language proficiency and a competent grasp of neural network architectures, you can go about creating our own prediction machine and wash your hands forever from the dirty task of pouring over charts and imagining patterns. This venture is fraught with danger and peril. Many have tried, few have succeeded. You can fool yourself just as easily with numbers as with chart patterns, maybe even more so. But just imagine for a moment pressing a button and watching your creation bring gold to your coffers while you sip on premium Oolong tea.  If it doesn’t work, you can always make cheese. Organic of course.

We Are All Grecians

Observing the ruckus in Greece about what they plan to do with a maxed out credit card, I cannot help but feel a vicarious empathy. The state unions and pensioners are protesting planned austerity measures, but wouldn’t you if your government-sponsored welfare was being threatened?

Think back to when you we just a young child and your parents threatened you with taking away television privileges or some such entitlement that was important to you. It’s not fair to offer something and then take it away. It’s demeaning, insulting and dis-empowering.

The Greek Prime Minister, Mr. Papandreou, has been appointed that country’s liaison with Reality. It’s a job that comes with no small sense of peril and loathing. Imagine if you couldn’t even get to work because your employees were protesting your office and you needed to find other suitable office space to plot your solutions.

Greece has moved from the first Kubler-Ross stage of  Denial (evidenced by currency swap chicanery) to the Anger stage (personified by the protests of the disaffected electorate). Mr. Papandreou is charged with moving everyone along to the Bargaining stage (brutal spending cuts and tax increases). Sadly, after Bargaining there are still the Depression and Acceptance stages. The Kubler-Ross matrix was intended to help those suffering loss to understand the process they needed to go through. But sometimes, maybe we bring about some of this agony on ourselves.

The most common application to trading is to use this matrix in dealing with trading losses, and to do it quickly so as to minimize the extent of the loss. For instance, if you have a losing trade, the notion is to  accelerate the following steps:

1.  Denial (There is something wrong with my chart)
2.  Anger (I can’t believe the stupid market is doing this to me!)
3.  Bargaining (I’m willing to get out break-even)
4.  Depression (I’m never trading again)
5.  Acceptance (Take my money, I’m moving on)

Of course, it isn’t always this neat. Many times we’ll  learn to Accept our loss too soon, and subsequently screw up the order by becoming Angry and Depressed after we’ve Accepted our loss. The point here being that trading psychology is a bit more complex than what can be summarized in a 5-step process, but the behavior of other market participants and whole countries is not necessarily any more complex.

Besides utilizing dazzling fundamental analysis and pinpoint technical analysis, it’s useful to see that markets are comprised of humans (no offense to trading robots, of course), and we all respond in similar ways to certain events.

It’s unclear how Greece and the Eurozone will resolve itself around this latest issue of profligacy, but we know that the story is not over by any stretch. Those that don’t know their Sylvan history are condemned to repeat it. 

The Breakfast Spread

Traders oftentimes will look at different markets from the one they are trading to get a gauge on what may be looming ahead. The US Dollar is oftentimes cited as a leading indicator to the US Equities market. The price of Gold is sometimes looked at as a market consensus on inflation. Besides intermarket relationships, there are intermarket spreads that traders keep an eye on.

In the energy markets, the crack spread (2 parts Gasoline plus one part Heating Oil minus 3 parts Crude) is observed with keen interest. Bond traders like to focus on the spread between the 10-Year Treasury and the 2-year Note. But what is often overlooked are more subtle intermarket spreads such as the Breakfast Spread. What people are eating for breakfast has some significant predictive power to what may be happening to the S&P 500.

The Breakfast Spread is the closing price of Pork Bellies (read: bacon) plus the closing price of Eggs minus the closing price of Coffee. What we’d like to see, in normal times, is that folks eat the eggs and bacon, and consume a proportionate amount of coffee. When this balance breaks down, look out for some major selloffs in US stocks. Below is a chart that was created in R depicting the price of Pork Bellies, Eggs and Coffee, along with a calculation that plots the Breakfast Spread.

We can see that the price of bacon and eggs remains steady, albeit volatile. The price of coffee, however, has some substantial spikes about once or twice a decade. The resulting impact on the Breakfast Spread is a reading below 100. This happened in 1978, 1985 and 1998 – all a couple years ahead of a major market selloffs. The indicator takes a different turn in predicting the the selloff of 2008. Instead of registering a sub 100 reading, it registers a 100 plus reading, meaning that people are not drinking enough coffee with their breakfast, which can only lead to trouble long term.

Where do we stand now? Well the indicator is clearly forming a descending triangle and that can only mean one thing in the next year or two – an ugly market selloff. You’ll know when your co-workers starts skipping breakfast but not the coffee, or maybe they have a proper breakfast and drink two cups of coffee instead of one.

There is still much research to be done in this exciting field. Could we use the price of orange juice to further enhance the Breakfast Spread? What about butter? I don’t know where to get butter data, but it’s gotta be out there somewhere. In any case, it may be prudent to protect one’s long portfolio with a little insurance, just in case.

A Short List of Candidates

You can’t trade everything. Well, at least you can’t trade everything well. At some point, you should limit the universe of things you trade. And it’s okay. You don’t need to trade everything because quite frankly, nobody knows what you’re talking about anyway at the weekend cocktail party, and they don’t care. I implore you to be prudent in this way: commit to trading a specific world of underlyings, and quit chasing bright lights in the depths of the ocean, like everyone’s favorite Nemo character, Dory the Blue Tang.

It can be anything such as large cap stocks, penny stocks, major currency pairs, or just one stock or currency pair. Or just the ES futures. Or you can make the case of trading what is cool and in vogue, such as GOOG into earnings, or gold stocks when everyone is buzzing about gold. I’ve chosen to trade the universe of liquid futures. And I’ve wittled down the list of qualifying candidates to just fifty-two.

My list is crafted carefully around major market groups, which have a tendency to inter-relate and correlate. The basic groups include:

1. Currencies (7)
2. Interest Rates (10)
3. Equities (9)
4. Metals (5)
5. Energy (4)
6. Commodities (17)

Currencies:

This group includes the Dollar, Euro, Pound, Yen, Aussie, Swiss Franc and Canadian Dollar. Pretty much the major currencies with the Aussie and Canadian related to commodities.

Interest Rates:

This groups consists of US Treasuries (2-year, 5-year, 10-year, 30-year), the Eurodollar and foreign treasuries that include the Canadian 10-year, the Gilt Long Bond (British debt), and the German debt complex of Eurobund (10-year), Euro BOBL (5-year) and Euro Shatz (2-year). Potential inter-market relationships between these markets and both the currency and equity markets abound.

Equities:


Okay, the standard US equity markets need to be included. I’ve chosen to leave out the DOW futures and focus on the S&P; 500, Nasdaq 100 and the Russell 2000. For international exposure I’ve included the Nikkei (Japan), CAC 40 (France), Euro STOXX 50 (Europe), FTSE 100 (Britain), DAX 30(Germany) and the Heng Seng (Hong Kong).

Metals:


You can’t leave out gold or silver. Their ratio is actually an important metric. I’ve also included other precious metals such as platinum and palladium (think catalytic converters and cell phones), and the base metal of copper.

Energy:

Of course we include crude oil and natural gas. Also included are refined products such as heating oil and gasoline.

Commodities:


This is the largest group, so let’s divide it up into Grains, Livestock, Forest and Softs (I’m following the CME Group convention here).

Grains include corn, wheat, soybean, soybean oil, soybean meal, oats and rough rice.

Livestock includes live cattle, lean hogs, feeder cattle and everyone’s favorite future – pork bellies.

Forest includes lumber.

Softs include cocoa, coffee, cotton, sugar and orange juice.

And that’s it.

Just 52 underlyings, many of which have interesting inter-market relationships.

This is my final roster of players, and they will all participate in future backtesting regimes. Will I trade them all? No. Money management may limit the total number of underlyings to a small percentage of the universe, but those 5-7 futures will represent a good diversification of product, and will also be the best representative for a particular trading strategy.

Dory got confused once in Finding Nemo and said: ‘I don’t know where I am… I don’t know what’s going on. I think I lost somebody but I, I can’t remember.’ Don’t be that fish.

Long R, Short Excel

R is very speedy statistical package that’s like an F-18A Hornet, versus Excel which is like a paper airplane. R is professional sports, Excel is Pop Warner. R is Mona Lisa, Excel is stick figures. R is … okay, you get the idea. I’m long R, and short Excel. For traders that are analyzing vasts amount of data, it’s time you made the switch to the trader’s statistical package of choice. You have to work a little at understanding the scripting language, but it’s nothing that you can’t wrap your mind around in a few nights after the kids go to bed. I’m just getting acquainted with R, and I’m already putting my copy of Excel on eBay.

Cut-and-paste versus read-in:

After you’ve generated vast amounts of data from an optimization run, you find yourself with the loathsome task of cutting and pasting the data into an Excel spreadsheet that you’ve probably already pre-formatted to look at the data. It requires you to select the data and not miss any rows, and it opens up the possibility that something gets left out. With R, you don’t touch it once you’ve converted it to a .csv file. You simply reference it in your script.

Manipulating columns of data:

In Excel, you know the drill. Select a cell to compute the mean of a row and then select the elements of a column that you’d like to apply the formula to. When you have over 1,000 rows, it takes a while to drag that stupid mouse. Just as you approach the end of your values, the cursor goes wild and runs down to infinity. Ugh. Well, with R that is no longer an issue since you define the column of data (called a vector) to a script that quickly returns the value you’re looking for.

Add-in packages:

Remember how excited you were to install the Data Analysis pack in Excel and how it gave summary statistics for a column of data that included mean, standard deviation and other stuff you had no idea what they were? Well, that’s a standard part of R. And as you graduate from Statistics 101, you’ll find that there are add-in packages in R that range from neural networks to Bayesian statistics, from genetic algorithms to copulas (side note: the geniuses who created tranched derivatives that came home to roost last year used gaussian copulas, amongst other things).

Cost:

I think I paid in the neighborhood of $250 for my copy of Excel. I paid nothing for R, since it is open-source and free.

The issue of crashing Windows:

I have crashed my computer by asking Excel to compute too much data. So far, R hasn’t produced the same results. And based on its architecture, I’m not expecting it.

Graphs and dynamic data:

If you want to create a chart or graph of something in Excel, you need to navigate through that stupid menu of crazy pictures to get something that’s clunky and difficult to maintain. In R, you use scripts to create charts and graphs, and the data file feeding the chart is dynamic so that each time data is added, R will incorporate the new data. No offsetting shenanigans.

There are video tutorials available at the usual places you’d find that sort of thing, and a very robust community of R users to help get you started. So put down your toys and get to work. There is much data that needs analyzing.

System Trading is Quicksand without the Quick

Perhaps the best way to describe the path to system trading is slogging. It’s like one of those dreams where you’re trying to run in the sand, and it keeps sinking. And then it starts to rain and the wind starts blowing you backwards. Like many things related to trading, system trading sounds simple on its face, but becomes increasingly elusive as one pursues it.

System trading distinguishes itself from other forms of trading in that it has a high threshold for capital allocations. Feelings, notions, guru tips and gut instinct are not sufficient for the system trader. There needs to be a formalized approach to the trade that can be back-tested on historical data. This first step is not all that involved, really. There are many off-the-shelf programs that can perform a back-test of a trading system. But once you get the results, what do you do with it?

You ponder, perhaps, and cast a skeptical eye upon promising results. You start wondering (and rightfully so) whether past performance has any correlation with future returns. Well, how would you know? At this point you can either sell the program to others or try it out yourself.

A way to test the back-test is to perform an optimization. This is running the back-test with different parameters (ie, moving averages with varying length for an MA crossover system). If it performs well under this process, you can gain some more confidence in your system. But how would one define ‘performs well’? There are many metrics to look at including net profit, drawdown and ratios of those two. How many permutations were profitable as a percentage of all the permutations that were run? What percentage of permutations had a net profit that exceeded maximum drawdown? Is that a good number? What is the best parameter set? What was the measuring stick used to determine the winning set? Now we see where the quagmire begins.

You are now the proud owner of stacks of statistics that you need to sort out. It’s like going through your coupon drawer. You know, the one that has mostly expired coupons, and some for junk you wouldn’t buy if it were free. The optimization results are not a self-evident validation or rejection of a trade system. It takes a thinking person to evaluate what they’ve got.

And after this is sorted out, there is still another step of testing the system on out-of-sample data. Why? Well, because your optimization process found good parameters, but it fit the data to do it. The process is called curve-fitting in statistics and involves making things fit. Not necessarily bad, but it can be overdone. That’s why we walk-forward, or test on out-of-sample data. It’s the same thing as trading the system in real-time. After this process is complete, you find yourself with another truckload of disorganized coupons.

Besides the programming skills needed to do the basics, you need a decent grasp of statistics, good organization skills (where did I put that file on the Coffee market between 1998 and 1990?), and the basic understanding of how markets work. Understanding markets is crucial, as many nerdy statisticians with excellent programming skills have proven by losing large sums of money. Don’t be afraid of having to learn a lot of stuff, though. Trading is not for the lazy.

Trade your Equity Curve

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.

Your system’s equity curve is how much money it’s making. Any standard package will be able to draw the simple chart for you. It has its ups and downs, with hopefully more ups for your sake. The goal for system traders is to create a smooth equity curve, meaning there are no radical departures from a gradually increasing trendline.

If your system’s equity curve looks sloppy and you can’t live with it, you either stop trading the ugly beast or you start a process of making it look better, which usually involves adding filters (to get the bad trades out) and other overfitting exercises. If you start down the path of overfitting so that everything looks neat and pretty, you might as well quit trading right now and donate your trading capital to a local charity. You’ll save yourself frustration and feel good about contributing to your community.

A natural tendency amongst system traders upon viewing an ugly equity curve is to revert to their discretionary trading habits. Take this trade, but not that one. It’s no longer system trading at that point, but discretionary trading with system tools. There is another way to maintain the integrity of the vast amounts of statistical data you acquired about your system during its development. And that is to code an algorithm to throttle or feed your system based on its equity curve performance.

I’ll offer three equity curves but instead of the naked one you’re used to viewing, I’ve added a MACD on a lower panel and two simple moving averages, a red one (50 day) and a green one (20 day).

keeptrading

The first one is a no-brainer. With an equity curve like this one, you want to keep trading it. Feed it, nurture it and read it bedtime stories.

It’s steadily climbing with the 20-day average nicely above the 50-day, and the MACD not showing any warning signs. If this is your equity curve, nice work.

proceedwithcaution

Next, let’s look at one that may be in a little bit of trouble.

It has had a steep run-up just lately, but now the spread between the 20-day and 50-day is tightening to the point where the 20-day is threatening a breach of the 50-day. The MACD shows stalling momentum and a general decline.

stoptrading

Finally, let’s look at a not-so-pretty equity curve. This one has had its 20-day crossover its 50-day, and the MACD is confirming a deteriorating situation of steady decline and sub-zero line occupation.

Do yourself a favor, and let this system tell you what it’s going to do next before allocating anymore funds to it.

For system traders, it’s just a matter of programming when your system takes a trade or leaves a signal alone. You can program a moving average crossover or a host of other technical indicators that you may use in any typical trading system. You’re not being discretionary if you program under what equity curve conditions a trade is taken. The programming aspects involve creating a shadow or virtual system that follows along your regular system. I haven’t programmed one yet myself, but I know I can do it in TradersStudio. I’ll post the system once I’ve gotten it correctly coded.

Equity curves are not unlike stocks, and stocks are not unlike equity curves. That’s why we sometimes refer to stocks as equities. Your system is basically a stock that you’ve invested time and energy into. You can employ the buy-and-hold philosophy with your system, or you can trade it.

To emphasize the fact that you can view your equity curve just like you would any stock, ask yourself what favorite stocks the three equity curves above look very similar to. If you guessed AAPL, IBM and F, then you’re right.

I’ve filed for a divorce

I think, and hope, that we can still be friends, but my days of being married to high-probability discretionary trading are over. This separation is amicable and mutually agreed upon. We had a good run, but things ran into trouble last year when the market gave us something we’ve never seen before. Our relationship has never been the same since. The screaming, the accusations … oh, it got ugly. I thought maybe we could work it out this year, but this latest 3-week rally has put a permanent end to our relationship.

High-probability discretionary trading is the mistress or spouse of many traders. She is seductive, beautiful and addictive (lady traders, feel free to visualize her as a him, if you’d like). She promises, and oftentimes delivers, low risk for high reward. There is nothing so alluring as visualizing a setup that has a defined risk (the place where the trade no longer works) and its potential reward, which can be five times larger or more than the risk.

High-probability discretionary trading’s father is Poker. He taught her growing up that it’s all about betting based on the size of the pot and your individual odds. He taught her that you don’t need to play every hand, and sometimes it even makes sense to fold a good hand to get an idea of how others are playing.

Where my relationship with high-probability discretionary trading went bad was in my expecting something from her that she could never deliver. Probabilities that were actually based on reality. You see, her probabilities are a little problematic, and she will be the first to admit it. I know there are many successful traders out there who are still very happily married to high-probability trading, and maybe things would have been different with me if I had just listened more. Who knows. It is what it is.

Even though I’ve had relationships with fundamental trading, intuitive trading and emotional trading, I found high-probability trading worth getting married to. Now that I’m moving on, I’d like to introduce you to my future spouse: system trading.

I know she’s kinda boring compared to the others, but I love her for that. She’s a little frumpy, awkward in public and can’t play sports, but she’s a bit more real to me the than the flashy others.

System trading takes a notion or idea and puts it through a scientific process of validation. It includes backtesting, optimization and walk forwards. It involves compiling a statistical profile for a trade system and the market to be traded. When she fires off a signal, you take it. No discretion. All the work you’ve done on understanding the system depends on you taking every signal. It’s a very committed relationship that way.

If all you like to talk about is the latest reality show and what your neighbor is selling his house for, then you probably won’t like system trading. If you like Wittgenstein, Tolstoy and Gabriel Garcia Marquez, then you may have found your mate. We talk about things like intermarket correlation, genetic algorithms, neural networks, particle swarm optimization and fuzzy logic over breakfast. It’s fun, but then that’s me.

Expected Drawdown on 50/200 Cross

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 Traders Studio, 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:

WoodShedderOriginalEquity

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.

WoodShedderDistribution

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

WoodShedderMCTerminalReport

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.