Tuesday, 23 December 2008

Developing a trading Strategy

How I developed my Swing Trading Trend Following Strategy.

1. I needed a system which I could manage at night because of the day job - meaning day trading was out of scope - a shame because (as with most newbies) this form of trading certainly captures the imagination!

2. I was not interested in position trading for two reasons.

My account was unlikely to be of sufficient size to manage the swings that a position trader has to cope with.
I wanted to be actively reviewing the markets on a daily basis so I could build my understanding.

3. The type of trading that suited me was swing trading. Being in a position for 2-5 days.

4. I then needed to decide whether I was a counter-trend or a  trend trader. Most trading commentators will tell you 'the trend is your friend' - I agree with them and initially decided upon being 'a trend following swing trader'.

5. I had researched numerous trading educators' methods and had some understanding of various indicators and what they meant. I decided to keep the system as simple as possible and so initially focused my attention on developing a simple moving average cross-over indicator. Click here for video. I tested on historical data using the 8 and 26 EMA's on the daily charts

Go long when the 8 EMA crosses above the 26 EMA
Go Short (or reverse) when the 8 EMA crosses below the 26 EMA.

I soon realised this system would mean I would always be in the market decided I wouldn't have time to manage that, so I started looking for something that I could use to refine my entry and exit techniques. (Remember I had a couple of hours per night to analyse the markets and make my trading decisions).

6. I had read various books that pointed to a technique using longer time frames to identify trends and then shorter time frames to identify entry and exit points. I decided I would identify trends on the weekly charts and entry points on the daily charts.

7. I moved my cross-over strategy onto the weekly charts. I could now say with confidence what I thought the markets were doing on a weekly basis.

8. Armed with my new found 'system' I now needed to figure out how to identify entry points on the daily charts. My research pointed us in the direction of something termed 'value' entries. This in effect describes market movements as oscillating above and below 'value'. When markets become overbought (too many buyers), they will invariably pullback to a more attractive level, the same is true if they are oversold - they will retrace to a more attractive level. I located an indicator called keltner channels which plots a 'value channel' a number of standard deviations either side of the average price. When the price is near the centre line this is said to be 'value'. This also provided us with ready-made stops and targets - when long the upper channel line would be my target and the lower channel line would be my stop. The reverse being true when I was going short.

9. I now had a trading system. To re-cap:

I looked on the weekly chart. If the 8 EMA was above the 26 EMA, then I would only trade on the long side.
If the 8 EMA was below the 26 EMA, then I would only trade the short side.
Based on my weekly trend decision, I would then look at the daily charts to identify 'value' entry points - these being at or near the keltner midline.
If the price was at or near the midline then I placed a trade with stops and targets placed accordingly, at keltner upper and lower channels.
10. It was time to test this strategy.

Back or Forward Testing? Some experts will tell you back testing is useless as there is no substitute for actually having your money at risk. I think that back testing has value - how else can you even begin to develop a strategy if you aren't able to compare it to some benchmark? All my systems have been back tested at some point in their development, however my back testing is not as scientific as some experts claim that it should be. I tend to eyeball my charts and see how that strategy performed historically. I have in the past developed strategies in Tradestation and then used their inbuilt back testing tools, but even this is far from ideal. I believe that the only way to really test a system is by forward testing it. Forward testing can take two forms; paper trading (using live prices but not actually placing trades) and reduced size live trading - which is far and away the best way of testing a strategy. I monitor and record my activity with great care as this gives us invaluable information on how the strategy is performing. Once I have tested a system like this for 3-4 months and the results are satisfactory (based on my money management strategy) I consider promoting the system to production.

I initially reviewed historic charts, identifying weekly trends was easy - my system was always in the market. (I made a note that I was never 'flat' - I knew this was a valid position - I may need to refine this later.) With a long or short bias decided, I then looked at the daily charts for value entries. Eyeballing the charts revealed a number of value entry points with about 40% of these 'trades' resulting in winners. I quickly worked out that if my stop and target distances were equally placed from entry and 40% of trades were winners, then I would lose money. This was clearly not a winning strategy....yet!

11. I had 2 areas to focus on.

Identify 'stand aside situations' on the weekly charts - times where the market wasn't trending- this I hoped would improve my win/loss ratio.
Improve stop and target placement to improve reward/risk ratios.
12. Identifying stand aside or trading markets. My research found us reviewing an indicator called Heikin-Ashi which is a revised candle stick and enabled us to easily identify trending markets. I would only identify a trend on the weekly charts when both the moving average cross over AND the Heiken-Ashi indicators converged. I hoped this would keep us out of choppy/trading markets.

13. I now needed to work on stop and target placement strategies. How could I reduce my maximum potential stop whilst ensuring I didn't stop out of eventual winners? I found a concept called MAE (maximum adverse excursion) and MFE (maximum favourable excursion) - simply put, the MAE records how far against you a trade went before it became a winner, and the MFE records maximum distance a losing trade went in your favour before it became a loser. This concept seemed perfect, so I reviewed my charts and found, perhaps surprisingly, that I had quite small MAE numbers, meaning I could place my stops just below these figures and greatly increase my potential risk reward ratio.

14. I returned to the testing arena. The weekly charts now only gave a signal about 65% of the time which was still high (research suggests markets only trend about 30% of the time. More work needed, but going in the right direction!) Eyeballing the historic charts indicated a w/l ratio about 50%. (So by reducing the set-ups on the weekly charts from 100% to 65% I increased the W/L ratio from 40% to 50% - which was encouraging.) The average winner was approx 1.4 times the average loser. This now seemed like the beginnings of a workable swing trading strategy. Assuming a basic w/l sequence of w l w l etc, I would win 1.4 x 2 = 2.8 and lose 1 x 2 = 2, giving us a net profit of 0.8 unit. Not bad, but still not great. During this phase of the strategy development I began considering how I could deal with long runs of losing trades - I knew this wasn't strategy development it was more about money management, but it was important to have in the back of the mind. I located some statistics which gave a percentage probability of a certain number of consecutive losers based on the likelihood of the trade losing (with an increasing w/l ratio the probability of sustaining x number of consecutive losers decreases). With a W/L of 50%, there was a 16.6% chance of 3 consecutive losers. I introduced a rule to stop trading after 3 consecutive losers. This was really more about capital preservation than strategy development, but they are related to each other (you may have a strategy that wins 80% of the time and can therefore sustain more consecutive losses).

15. With my revised stop placement strategy and an additional rule around consecutive losers I now focused on target placement. I looked at MFE numbers and found a good number of trades that went my way initially, but then reversed for a stop. I definitely needed a slicker approach to target placement. This led us to Fibonacci lines. Which simply put show natural levels of extension and retracements. I looked at the nearest fib extension (127.1%) and retracement (61.8%) levels to define targets. I returned to the testing arena.

16. Let's summarise:

Weekly trends are identified using EMA and H-A.
Entry points on/near keltner mid-line on the daily chart.
Stops placed below average MAE with targets at the near line fib (127.1 or 61.8 depending on long or short).
I noted I had little in the way of filtering on the daily charts, I simply waited for a return to value before I entered the market. I had a nagging concern that this may mean I get into a position on the right side of the weekly trend, but the wrong side of the daily trend. This would be the next area for us to focus on.

17. I returned to my charts and performed my 'eyeball' back testing. Things looked better, I was certainly identifying winning trades and hitting my targets. Previous MFE figures now became winning trades as my targets were hit at fib levels. MAE still stopped out a couple of winners, but in the main the stop placement was good. I noticed when I looked at 8/26 EMA on daily, that I would sometimes enter a position when the weekly and daily EMA's diverged. There were also times when volatility spikes moved price quickly to my stop levels. How could I protect from these and potentially even benefit from them? Back to my research....I found an indicator that I felt I could use to address the volatility issue. Before I discuss, lets discuss a little market theory.

Markets are known to go through phases. During the early phases of a bullish trend, markets go through a phase called 'accumulation', this means there are more buyers in the market and the price will increase. After accumulation the market enters into a period where buyers and sellers are evenly matched and price action is minimal. This phase is termed 'consolidation'. The final phase in a market cycle is called 'distribution', where those that participated in the accumulation phase close their positions to book a profit (traditionally this meant people selling their stock). This will usually be accompanied by a price fall. Note however that sometimes a market can re-enter accumulation after a period of consolidation as the move strengthens (as it can re-enter distribution if the move down is strong). These market phases occur over all time frames and so it made sense to locate something that could tell us where in this cycle the market was on the daily charts. If I knew which phase the market was in, (in particular whether the market was consolidating) then, in conjunction with the weekly trend, I could avoid situations where I had divergence on the weekly and daily chart.

To explain further lets look at an example.

The weekly trend is long.
I look on the daily charts and note that the price is extended from value, so, I wait for the price to enter the value area.
After 3 days, the price enters the value area and I buy.
The price quickly heads towards my stop and I are stopped out of the market.
If I had identified which phase of the cycle the market was in, I could have acted accordingly. I would have been warned therefore, that the next phase (potentially distribution) would accompany a potentially significant price move down. I needed to ensure I understood both the weekly trend and the daily phase of the market. I reminded ourselves that a market could enter accumulation, then consolidate before re-entering accumulation again. I therefore needed to identify consolidation phases and work out how to pre-empt its next move - accumulation or distribution. If its next move converged with my weekly trend, then I would have an entry signal. My work around keltner channels lead us to a concept called The Squeeze. This indicator seemed perfect as it identified both market cycles and an indication of the next phase of the cycle. How the squeeze works - using the keltner channel and the Bollinger bands, periods of consolidation are identified. In conjunction with a momentum indicator the squeeze can be used to identify a consolidation phase and the potential direction of the move. I integrated this into my daily charts. If the weekly was long and the squeeze indicated the next move was long and I was near 'value', then I would enter the market. If the squeeze diverged, or I was far from value, then I would stand aside.

18. Another re-cap:

If I are long on the weekly, I look at the daily charts.
I wait for a value entry. When the market moves into value, I use the squeeze to identify the market phase. If the market is distributing (more sellers than buyers) I stand aside. If the market is consolidating I wait to see which way the market is likely to move, (post consolidation). If it moves long (accumulation) I go long if it moves short (distribution), I stand aside.
This strategy was now really stacking up, I decided (after eyeballing on the historic charts) to go live with small size.
19. What does 'small size' actually mean? For us it meant risking as little as I could. My trading plan put 2% of my account at risk on each trade I made. Forward testing meant I risked a maximum of 0.5% per trade. Using spread trading I are able to define the amount per point I wish to risk, so in my £10,000 swing account I could risk £50 (0.5%) on each trade. What was my criteria for success? Initially I required a minimum of 50% wins to losses with my average winner 2 times average loser, but until I had some trading history for this strategy I had no real way of knowing how it was likely to perform. Remember I stopped trading after 3 consecutive losers. I had also decided to quit trading for the month once I made 7% on a particular strategy, however as I was trading 1/4 size (e.g. 0.5% as opposed to 2%), so my 7% monthly target became 1.75%. These were the parameters I used in this test account.

20. I would scan the following markets to identify set ups for this strategy on a daily basis. Dow, S&P, Russell, NASDAQ, Wheat, Corn, Soybean, US 30 yr Treasury Bond, Silver, Gold and Platinum. If I identified a set-up I placed either a limit or market order. My stop placement now became a function of two factors. MAE and maximum risk per trade based on my money management policy. Given I only wanted to risk 0.5% per trade, my position size (amount per point) was likely to be small. For example on the Dow, the MAE based stop placement meant I placed stops 250 points from entry, and given 0.5% of the account was £50, I risked 20p per point (50/250). I was hardly the last of the high rollers, but assuming the strategy passed the gate criteria for release into production, this would change.

21. During this testing phase it’s absolutely imperative that I follow the strategy to the letter, if I do not, then how do I know how well it is performing? I must follow my daily disciplines on this testing strategy is if it were a live strategy and I was using all my Grandma's pension fund. It really is that important!!

22. During this forward testing phase, it soon became clear that with this strategy, I got between 1 and 2 set-up's per week across the 10 markets I followed. This meant between 4-8 trades per month. Assuming a 50% W/L ratio with the average winner = 2 x average loser. My rudimentary analysis calculated the following:
If I make 4 trades per month, 2 will win, 2 will lose. The winners will net 8% and the losers will lose 4%, so I will be 4% up for the month
If I make 8 trades per month, 4 will win, 4 will lose. The winners will net 16% and the losers will lose 8%, so I will be 8% up for the month.
There is a 17% chance of 3 consecutive losers. If this occurs I stop trading.

The strategy now seems to be a good one. I had developed the technical aspect iteratively, I had forward tested on small size, I knew that under normal market conditions, the strategy had an edge. I now needed to continue forward testing it until I had confidence to begin trading it full-size

blog comments powered by Disqus