Home
Up

 




 

Developing Trading Systems - Part 2

Cho Sing Kum
28th Jun 2003

This is the second of a 3-part series which I wrote in a financial forum on 15th April 2001. Lightly edited.

 

Developing A Trend System

In Part 1, we discussed about the three types of market - trending, sideway and choppy. Today's article is about developing a trend trading system. I try to make this system very simple for the benefit of those who are new or have little experience with technical analysis. For those who are experienced with technical analysis, I hope this provide a stepping-stone to move further along in the journey to be a better trader. There is a big number of technical traders who use technical indicators in their trading but have not yet gotten onto the path of putting their mental trading systems into words that can be understood by a software to help them managed their emotional part of the decision making process. I hope this article will provide the impetus to do it.

Okay, let's go into the article proper now. Recall that in Part 1, trading systems are made up of parts that can be stripped apart and examined individually. These parts can be designed independently and are complete to do a certain tasks and nothing else. I always liken this concept to Formula One cars. Every part of the car performs a certain function and when combined, help make the car go faster in certain conditions - weather, tracks design, surface condition etc. So similarly, the parts that make up the complete trading system must do the same when combined - to make your car (profit) go faster in certain conditions (trend for this article today).

Most people, even with sophisticated information and trading tools tend to trade haphazardly. Although they base their trading decisions on technical indicators, their decisions are almost influenced by their human emotion. Trading strategically can rectify this situation.

 

Benefits of Strategic Trading

  1. You have your own trading system that is compatible with your psychological and emotional makeup. It is your system therefore you are comfortable with and can follow the outputs coming from it.
  2. You are not subject to emotional spur-of-the-moment decisions and therefore can reduce and manage stress.
  3. You have your own entry and exit criteria that you designed yourself and which you have validated through testing done historical data.
  4. You have all the important information pertaining to the performance of your trading system that not only ensured you are adequately capitalized to trade with but your risk is well managed too.
  5. You will gain confidence in your own trading system and yourself to trade in a very disciplined manner.

 

Visually Scanning Your Ideas

The first step is to scan through at least several years of price chart on different instruments to see how your idea of a criteria work. This can be easily performed with the help of technical analysis software that allow you to write a simple 'id*iot-proof' code to identify on the price chart whenever the criteria is met. The assumption made in Part 1 still remain true for this Part 2 and that is you are a technical trader. I will also assume that you are already using technical analysis software. Otherwise you may want to try with Excel or other spreadsheets. I will also assume you want to explore the features of the software you are using. Using an analogy, they are like Excel. Excel can be a very powerful spreadsheet. One with which you can build a customized program, or it can be a useless piece of software not worth its money.

Before you scan through price charts, you will of course have to be familiar with technical indicators and how they work. This is pretty much a very personal venture and experience and a lot of work need to be put in before you can have an idea of what to look for. In other words, you have to be master of the tools of your trade. I will leave the reading of indicators that I am going to use to you because the resultant picture will vary from person to person. No two persons will come to the same conclusion.

I have tried scanning through Singapore stocks so that I can use one for this article. Unfortunately, I couldn't find one. The nearest is Creative but the price movement is still not that conducive for the combination of technical indicators I intend to use. Perhaps some other indicators may help but certainly not the ones I am using here. This may also confirm the view as expressed in Part 1 that the Singapore stock index has the characteristic of a choppy market. I have experience with commodities, interest rate futures and foreign exchange. There are seasonal trends in commodities and persistent trends in interest rate futures and some currencies, especially yen. My aim is to show how to design and develop a simple trend system that trades a trending market with good result.

For our trend system today, we are scanning for a criteria that identify a dip in an uptrend (BuySetUp) and another criteria that identify a rally in a downtrend (SellSetUp). Usually, we will only know of the existence of an uptrend only after prices and risen, vice versa for a downtrend. This problem is common across all trend indicators and can make entering the market quite difficult. We want to look for, if possible, the first corrective price dip in a new bull and also the first corrective price rally in a new bear to enter our trade.

To explore whether the criteria work, I write a ShowMe study in TradeSation 2000i. What this study does is to paint a Blue dot when the BuySetUp criteria is met and a Red dot when a SellSetUp criteria is met. Since this is a trend system, I have chosen the IMM Eurodollar futures contract because this contract tends to trend every year. This is a futures contract on 90 days Euro Dollar Deposit (interest rate). Other similar 90 days Deposits, like the Short Sterling (LIFFE) and the Euro Yen (SGX-DT), also tend to trend every year. If you are not familiar with futures, don't rush into it until you understand the nature of the futures business and the risk involved, especially the very high leverage of the margin system. This can really kill those who are reckless and who do not respect risk.

Figure 1 shows how the dips in an uptrend are identified.



Figure 1. ShowMe study - uptrend market

 

Figure 2 is the same ShowMe study but during a time period when there was a downtrend in the IMM Eurodollar during December 1999 to January 2000.



Figure 2. ShowMe study - downtrend market

 

Naturally we must also know how we are going to be whipsawed in a sideway market. Knowing this, we will be well prepared for equity drawdown. Figure 3 show the type of sideway market situation from February to May 2000 when this is not going to work. Money management stops are especially important during this period.



Figure 3. ShowMe study - sideway market

 

Defining Trading Rules

In this system, we define both long and short entries as well as exit orders. The long and short entries do not reverse our position. The exits close out our positions and exit us out of the market. In defining entries, we also perform some setup work that involved identifying the dips and rallies. We also define the stop loss we are prepared to risk and the condition for our trailing stops to come into effect - the amount of profit first (floor amount) before a trailing stop of a set percentage kicks in. We also define the initial fund/account size and the pre-set risk per position.

 

Setup

  1. Calculate two Moving Averages, a 5-day and a 20-day, to determine the overall direction of the market.
  2. Calculate a 5-day Slow Stochastic to follow the short-term wiggles of the market to identify the minor dips and rallies.

 

Long Entries

The Buy Setup criteria is complete when:

  1. The 5-day MA has crossed above the 20-day MA
  2. The 20-day MA is sloping up
  3. The 5-day SlowK having reached below 30 then crosses above the SlowD

An order is placed to BUY at the Market On Open the following day. There is no pyramiding. When a long position is already established, subsequent occurrences of BuySetUp will be ignored.

 

Short Entries

The Sell Setup criteria is complete when:

  1. The 5-day MA has crossed below the 20-day MA
  2. The 20-day MA is sloping down
  3. The 5-day SlowK having reached above 70 then crosses below the SlowD

An order is placed to SELL at the Market On Open the following day. There is no pyramiding. When a short position is already established, subsequent occurrences of SellSetUp will be ignored.

 

Exits - Money Management Stop

An initial account size of US$20,000 is assumed. This is a very conservative account for the non-aggressive trader. Money risk per position is not more than 2 percent of initial account size inclusive of commission and slippage. This means that in the event that a position turns out wrong, the position would be stopped out with a loss that is not more than US$400 (US$20,000 X 0.02) per contract. The money management stop is US$250 per contract (equivalent to a 10-tic move). Commission is set at US$20 per round turn and slippage is set at US$25 per stop order done. The assumed total is a maximum US$290 per contract for every losing position. Which means that this account will not trade 2 contracts of Eurodollar since doing so will carry an initial money management stop of US$580 (US$290 X 2), which is above the US$400 limit. An increase in account size or an increase in the money risk of 2 percent (not a wise thing to do) will enable more contracts to be traded.

The money risk of 2 percent per position will also apply to other instrument, example Euroyen, Sugar#11 or other instruments, including stocks that the account size can handle. It is not advisable to have at any one time more than 5 open positions. It kind of become difficult to manage. So if we limit to 5 open positions, the total money risk is 10 percent or US$2,000 (US$20,000 X 0.02 X 5). This should be very comfortable and will allow room for catastrophe risk.

 

Exits - Profit Protection Trailing Stop

While the initial money management stop take care of the initial money risk, this will drop out once the position has accumulated an unrealized profit of US$2,500 (100-tic). A profit protection trailing stop takes over to protect the unrealized profit to the amount of 80 percent. This means that if maximum unrealized profit were to drop by 20 percent, the trailing stop automatically exit us out of the position.

 

Designing The Trend System

Now it is time we transform the individual parts of the trend system into writing that can be expressed mathematically. We then put this into a technical analysis software that will take care of the translation into trading signals. In my case, I will use the TradeStation 2000i software and the built-in EasyLanguage. I believe the same trend system can be assembled using other technical analysis software.

Here is the EasyLanguage code:



Figure 4. EasyLanguage code for the trend system

 

Notice that the PositionSize to trade is always the integer portion of the formula:
PositionSize = IntPortion((AccountSize * Risk)/(StopLoss + Commission + Slippage));

Hence, even if the result is a PositionSize of 1.99 only the integer portion of 1 is taken. It will not round up to 2 to prevent over exposure of risk. Better to lean on the safe side.

Notice also that the exit orders for the money management and profit protection trailing stops are not specifically written out in the code as buy or sell stop orders. They are taken care of by TradeStation in following part of the codes.

The money management stop per contract:
SetStopContract;
SetStopLoss(StopLoss);
where StopLoss has an input of 250

The profit protection trailing stop:
SetPercentTrailing(FloorAmnt, Percent);
where FloorAmnt has an input of 2500 and Percent is 20
The number of contracts is also not necessary since this is also automatically taken care of. See Figure 5. If the software you are using do not have this feature, you should be able to write this out a one part and implement it.



Figure 5. Tracking Center showing the active order to be placed with broker

 

The order shown in Figure 6 is the profit protection trailing stop calculated at the close of business 6th April, the day that ED Sep2001 reached the highest level of 95.855 since the system went long on 27th June 2001 at 92.805. This position is still open. The order to Sell 1 at 95.245 Stop is exactly the 20 percent retracement level of the 92.805 (entry) to 95.855 (highest) move. This open long position has an unrealized profit of US$7,050 as shown on the caption.

The rest of the EasyLanguage code are quite easy to understand and self-explanatory.

What Is The Result?

We apply this trend system to the IMM Eurodollar Jun2001 futures testing the system with historical data from 14th Jul 1994 to 11th April 2001. The advantage of testing on Eurodollar futures is the availability of sufficient long historical data. The downside is that this contract was so far forward at that time and may not be actively traded until now. For our purpose, it is good enough and liquidity is still any time better than SGX stocks. For more accurate testing which I believe will yield better results, it is better to test on active contract months and roll accordingly before expiry. The performance summary is in Figure 6. No optimization was done. The complete performance report in Excel format is attached at the end of this article for you to download. The only thing missing are the graphs.



Figure 6. Performance Report for the trend system

 

Recall that in Part 1, it was stated that the percent profitable trade for trend system are usually low. In this case, it is 38.89 percent. But this is made up for by the bigger profit when the trade is right and the small losses when wrong. In Figure 6, there is an open position unrealized profit of US$7,050 that is not factor in the Total Net Profit of US$7,027.50 yet. I am very sure that the profit protection trailing stop at 95.245 will ensure this is a profitable trade and therefore pushing up the total number of winning trades to 8 (from 7).

Earlier I mentioned that there should be a maximum of 5 positions at any one time, Eurodollar being just one. So dividing the AccountSize of US$20,000 by 5, we allocate US$4,000 to this. This amount is at least a few times that of the margin requirement for Eurodollar futures, which usually is below US$1,000 confirming once again that this is a conservative account.

Take a look at the equity curve in Figure 7. Notice that the equity starts at US$4,000 as I have set it and see the beautiful upward slope - a trader's dream.



Figure 7. Equity curve

 

The equity curve demonstrated consistent performance and considering that this is without optimization, it does suggest a sound approach especially when the system did not generate that much trades in about 6 1/2 years of testing. Nineteen trades in total to be exact. There were two times that positions were held for ten months - once in 1997/1998 and the last one is the presently open long position. A good indication that this system can let profits run. The Performance Report is attached at the bottom of this article in Excel format. The graphs are the only part that was not saved. Download it and have a look.

Improving The Trend System

Dissecting the performance of a trading system is very important. So you must study the performance to come out with ideas on where and how you want to improve on the individual component parts of the whole system. This is actually where the most work will be spent, as it is a continuous effort. What I have covered today is only looking at one position at a time. The system can be expanded to trade other instruments in different exchanges worldwide. All the systems are then consolidated, monitored and tracked as one portfolio.

One of the problems with monitoring such a portfolio is that profits and losses are in different currencies. They have to be reflected in the base currency for proper management. When these are huge (in the case of banks and funds) and for some reason are not converted back to the base currency, you will also have to manage the currency risk. Hedging come into picture. Say you have profits in US$, you can design a system that will only go short US$ against SGD. You will be surprised how a weakening in the US$ against the SGD can wipe out a considerable amount of profits.

As an example, say you have a US$1,000,000 profit. If the US$ were to drop from 1.8000 to 1.7000 to the SGD, your profit will dropped by SGD100,000 (US$1,000,000 X (1.8 - 1.7)) if left un-hedged. On the other hand, if US$ were to strengthen against the SGD to 1.9000 from 1.8000 your US$ profit will bring an additional SGD100,000 for you.

In Summary

As promised, I have designed this system to be as simple as possible and yet profitable. I hope that you can see how easy it is to design and develop trading systems. It is not that daunting after all. This is what we have covered today:

bulletBenefits of Strategic Trading
bulletVisually Scanning Your Ideas
bulletDefining Trading Rules
bulletSetup
bulletLong Entries
bulletShort Entries
bulletExits - Money Management Stop
bulletExits - Profit Protection Trailing Stop
bulletDefining The Trend System
bulletWhat Is The Result

 

Click to download the Performance Summary.

 

In Part 3

I am planning a Part 3 that covers managing all 5 positions at the same time with the help of portfolio management software that works with TradeStation 2000i. I will try to include the conversion of profits and losses back to the base currency but will leave out hedging the currency exposure. This will really take strategic system trading using technical analysis to a much higher plane.

 

Back to Let's Learn Technical Analysis Index page for more articles...

 

Important: These charts and commentaries are provided as an education on how technical analysis can be used. Technical Analysis & Research is not an Investment Advisor and we do not claim to be one. These charts and commentaries are not to be construed as investment advice or any other investment service other than the originally intended purpose as stated here.

 

Copyright © 1998 - 2010, Technical Analysis & Research.  All Rights Reserved.

All product names are trademarks of their respective owners.