Monday, September 28, 2009

The Effects of Adding Filters in Designing a Robust Trading System - MACD - Continue

Before I start adding filters, I would like to touch on a controversial subject in designing and testing trading systems, that is Optimization. 

Why can't I just change the parameters of MACD that I used?  For example keep changing the period used in MACD from (12,26,9) to (19,40,9) with increment 1 each time then compare the performance summary and try to get the best result.  Then plot a heat-map and choose the best parameters.  A lot of famous authors call this process optimization.  Some argue that it is curve-fitting. 

In my opinion they are both correct, optimization is a form of curve-fitting.  When you over do it, it become more and more curve-fitting but when you do it just right (that's why it is still an art), you are just trying to get the parameters that reflected better on the signature of the market you are testing as each market has different types of players and the underlying product is also different.

When you do optimization, pay extra attention to the results from neighbouring numbers, you have to be extra careful e.g. when SMA 10/20 and SMA 12/20 are losing money but your SMA 11/20 produces great numbers.

The easiest way to tell that a trading system is over curve-fitting is by looking at the number of indicators used.  A robust trading system should be simple but no simpler. As a rule of thumb, if it has more than 5-6 indicators usually it is a sign of over curve-fitting already as you may be trying to catch every top and bottom in the chart that you are looking at.  Just be honest with your out-sample testing result!

OK, enough talk, lets get back to adding filters to our MACD system.  Since the FKLI market is an equity index-based and the underlying is actually tracking a baskets of stocks, and by and large stocks over a long period of time (e.g. 10 years) are bullish bias, we can try adding a faster SMA period to go Long and a slower period to confirm the Short so as to cut down unnecessary whipsaws.  I would test with SMA 20 as a filter to go Long and SMA 50 as a filter for Short.

That means the system will go Long when the MACD line crosses above signal line AND the closing price is above SMA 20 (closed).  It will turn Short only when the MACD(12,26,9) line crosses below the signal line AND the closing price is below SMA 50(closed).

Lets take a look at the result...



And the equity chart (before cost)...




The result is much better comparing with the one before we add the filters.  We have also cut down a lot of unnecessary trades.  To be more sure (we can't really be 100% sure anyway) adding filters does have effect, we actually have to do the statistical significance test (null hypothesis test) which I won't discuss here as it is a big and heavy subject on its own!  However, you can learn on your own, just google "inferential statistics" or "descriptive statistics".

Good luck in systems building and testing.

Disclaimer: Taken from CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER OR OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.

AND

WHATEVER YOU READ HERE SHOULD BE USED AS LEARNING AIDS ONLY AND SHOULD NOT BE CONSTRUED AS INVESTMENT ADVICE. IF YOU DECIDE TO INVEST REAL MONEY, ALL TRADING DECISIONS ARE YOUR OWN RESPONSIBILITY.

 

No comments:

Post a Comment