Wednesday, October 7, 2009

MACD With SMA Filter

I've shown in previous post that a simple trend-following system using RSI(14) that perform quite well in FKLI and FCPO but perform miserably on Light Sweet Crude Oil futures and even worst on S&P 500 index futures which represent a more mature market.

To show you how difficult it is to trade in these market especially S&P 500 using a simple trading system that uses common indicators as strategies, I've backtested S&P 500 using our earlier MACD with SMA 20/50 as filter that has performed quite well on FKLI.

That means the system will go Long when the MACD(12,26,9) 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).  Backtested period Jan 1996 - Sep 2009 (continuous front-month back-adjusted) daily data with basic 1 contract (stop-and-reverse).

Here's the performance summary:




and the equity curve (before cost) chart:



The system that perform quite well on FKLI done badly on S&P 500 index futures from Jan 1996 - Sep 2009 !  That again shows how tough it is to compete with the best of the world. 

In my next post, I'll backtest one of the best (so far) performer on FKLI which is SMA 10/50 and see if
it can successfully exploit inefficiencies in S&P 500 index futures, if there is any and if it is that easy.  We shall see.


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.
    

Tuesday, October 6, 2009

World Market - Crude Oil, S&P 500 (More Mature Market)

A quick summary up until now.  So far our simple RSI(14) 55/45 system is profitable on FKLI and FCPO (refer to earlier post).  Both traded on the same exchange which is Bursa Malaysia.

Now, before we order and celebrate with Louis XIII de Rémy Martin Limited Edition, let  me use the same simple strategy (before adding filters and optimization) on two other more mature world product that is very famous, namely S&P 500 Futures (CME) and Light Sweet Crude Oil Futures (Nymex).  One representing equity-based index futures (cash settlement) and the other commodity based futures (physical settlement), both traded in US dollar.  The period selected is Jan1996 - Aug2009 with continuous front-month back-adjusted EOD data.

First, the performance summary report for the crude oil futures:


Not too bad, still profitable, although the standard deviation of return is a bit too high, meaning that the return is quite volatile.  Notice a single largest profit of around USD96K?  If we were to take that away the strategy is not attractive at all.  So, it perform not as good in Light Sweet Crude Oil Futures (compare to FKLI & FCPO).

Now, let us see the result on S&P 500 Futures:


Ouch!  Losing money big time on S&P 500 index futures!  In fact, I can't even backtest with less than USD300K trading just 1 contract!  Furthermore, I didn't even put in the commissions and slippage.  Why is it so?

My hypothesis is that in a more matured and more higher level of competitiveness, you just can't use a simple strategy and hope that it will be sufficient, as there will be less chance of seeing and picking low hanging fruits! 

At this stage if you still insist on using the strategy to trade the FKLI and FCPO only, then you have to constantly monitor your trading performance and be on alert for any market paradigm shift, knowing that the basic strategy  doesn't work on a more mature market.

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.
    

RSI Strategy On FCPO - It Works Again !

Remember the simple trend-following that uses RSI(14) that I've backtested on FKLI and it works?  Guess what, I've backtested the strategy on FCPO(Crude Palm Oil Futures) from Jan 1996 - Sep 2009 (EOD continuous 3rd-month unadjusted data) using basic 1 contract and stop-and-reverse strategy.  

The same logic that uses RSI(14) to catch early trend by going Long when daily RSI value crosses above 55 and trend-follow until turning Short when the daily RSI crosses below 45.  The hypothesis is that in a strong uptrend, the daily RSI(14) will cross above 55 and seldom drop below 45, and the reverse is also true for going Short.  The backtest is done without any stepping optimization and filters, just pure default settings of RSI(14) and arbitrary RSI value of 55-45.  That means the result can be further improved if you are interested in it and think that the logic behind is sound.  Of course you'll have to start performing proper statistical backtest (I will discuss in my future postings) on different products to get a robust system.

Here's the performance summary result:


and here's the equity curve (before cost) chart:



Nothing much to say here except that it is a profitable strategy on FCPO (a very volatile product).  In fact, it perform better (CAGR, Sharpe ratio basis) than the FKLI that we have tested!  It just shows that commodity generally tend to trend more than equity therefore a trend-following strategy will perform better over a long period of time, in this case more than 13 years. 

However, further optimization and improvement will have to be done as the volatility of return (a risk measurement) is relatively huge and the max-close-drawdown-to-starting-capital is too big for most people to stomach (over 50%)!  Notice the largest profit on 1 contract? Over RM46K or 1852 points?  Can you hold your urge to take profit that long?  Or  can you handle the almost 300 point largest loss per contract?  Just make sure you don't have heart attack!  Happy trading and good luck.

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.
      

Sunday, October 4, 2009

How Much Can We Trust Backtesting?

I believe a lot of readers would be wondering how much can we trust the result of statistical backtesting based on historical data.   I guess a lot of you have definitely came across articles or gurus that equate doing live trading based on backtested result as "driving with rear view mirror" or something similar.

I would like to point out that the analogy is not quite correct.  In live trading, if we have sufficient capital to withstand a few drawdowns, we will survive losing trades.  In fact. there is no way to avoid a few losing trades once in a while.  However, when we drive, we can't afford to make a wrong turn or go straight when the road in front is winding, in fact, we can't really make a single mistake, as that would likely be disastrous!

Having said that, we must also realise the limitations of statistical backtesting as historical data is the only sample that we have and to make an educated guess on the likelihood of repeating patterns of the mass human psychology (market) and we can't be 100% sure that the same will happen again in the future, although a variation of the sample is likely to happen again as long as human has flaws!  I know this is confusing, as we have no choice, but to make a deterministic (same input, same output) conclusion (trading system) by just studying a sample (historical data) from hundreds of thousands of possible variations of the future!

To make the matter worst, the process of doing backtesting is susceptible to a lot of human biases, assumptions and errors such as worng historical record, selecting a bull or bear only cycle (period too short or sample size too small), curve-fitting the strategy to match data, wrong programmming or calculations etc.  One of the most dangerous example is hindsight bias (giving advice such as buy high sell low, or quickly take profit when market is ranging) and seeing one occurance and start assuming that the secret has been found! 

Remember, we can't prove that a hypothesis is correct, all we can do is repeating the process of trying to prove it wrong so that after thousands or millions of tests, we can have a degree of confidence in our model's successfulness in describing the pattern that it tries to capture.  The hypothesis just remains as the best solution so far.  We only need one observation that our model does not correctly describing the pattern to fix it or throw it away (such as failing an out-of-sample test)!  Just think of this as innocent until proven guilty.  If no one can prove you guilty, you remain innocent so far, it doesn't mean that you are really innocent!

On top of that, we need to do a stress test of the trading system using out-sample data and simulations on the variations of the result.  At the moment, one way of testing the trading system's result is to generate random sample data of the future via Monte Carlo Simulation which by itself is not perfect as certain assumptions about the pattern of distribution of the future data (possible data points of the results) has to be made, for example, a normal distribution, which may or may not be representing the real future data as the future is always unknown.  Besides, how many retail speculators or even the so call gurus know how to design and build their own Monte Carlo Simulator or even do and interpret the result from a commercial progam not to mention it usually is quite expensive.  Furthermore, can you really trust the simulation results?  Is there any correlation between the random inputs generated by the random number generator?

If I have scared you already, please don't be.  There are at least hundreds of ways we could have been knocked down by a car when we cross the roads but we still do it, why?  Simple, once we really understand what we are doing and are in control, we would have the courage to take the risk already, in fact, it has become second nature for us to take calculated risks in our everyday life without we second guessing them! 

Just always respect the market and have faith that humans will always have flaws!  I will try to explain how to design and evaluate robust trading systems for normal people like you and me in my future postings.  For now, good luck and happy trading!
     

Friday, October 2, 2009

Trading Strategies - The Problem and Solution

Please bear in mind that when I posted the performance summary report that showed losing money on a common use of RSI(14) counter-trend strategy backtested on FKLI, it doesn't mean that RSI as a counter-trend generally or the strategy spesifically cannot be used at all.  It may be possible to achieve a robust and working system by combining the strategy with some static or dynamic Stops as well as Exits.  You just have to test each hypothesis.

What I wish to point out here is that although trading is very simple; just Entries and Exits only, it is not easy to implement a long-term profitable trading strategy whether the strategy is discretionary or systematic.

Why is it so?  In my opinion, trading is just like the nature, a balancing act between two different forces and there is no such things as definite right or wrong.  You may be thinking of winning trades and losing trades but you are missing the bigger picture, winning and losing trades are just the result of our trading strategy which is in turn, the reflection of our internal believe system and wisdom. 

The right starting point to the solution is to realise that Entries and Exits represent the two different opposite sides of human nature.  If you are of the type that seeks instant gratifications or pleasures (majority of us) then you will most likely prefer to go Short when the market goes higher and higher or buy when the market kept dropping lower and lower as that is common instinct.  We are merely reacting to our basic needs.  If you analyse closely, this is just counter-trend Entry!  Where is the Exit?  How do you do it?  Most people have no clue.

As I've said before, counter-trend Entry is just one side of ourself that seeks instant pleasure, it usually is easy, we just do it.  If that is the case, the other oppsosite side would represent the one that is most difficult or challenging to us (remember two opposite forces), the Exit.  In counter-trend trading, it is counter logic to exit with a loss when after you have Shorted, the market goes higher and higher, as the price is even more attractive to add Shorts than to buy and cut your losing positions!  The reverse is also true for Longs.  When the market goes lower and lower, human nature is such that it is even cheaper to buy more, rather than to cut the Longs by going counter logic which is Sell to cut loss!  If most products are trending(over long-term), then you will have a problem with your Exit strategy.  You can't afford to win small(5 points) 4 times and lose big(25 points) merely 1 time consistantly!  You would have negative expectancy in your trading strategy, hoping will never change your odds.

That is the reason why trading is simple, but not easy.  And that is also why most successful traders (<5%) tend to be trend-follower as solving and implementing counter-trend exits(when most products tend to trend) represent a more difficult challenge than choosing trend-following which is counter logic and harder on Entry (buy when price goes higher) but relatively easier on the Exit as taking profit when the price goes even higher when we go Long or goes lower after we have Shorted (this generalization although is dangerous, but is true as long as most product tend to trend).  Furthermore, the logic for Exit is consistant with the logic for Entry in trend-following systems!

That's why most people choose the easier way to start, which is to Sell when they see market goes higher and higher or to Buy when the market drops lower and lower, which by itself is not the problem, but have no clue about how to Exit when the price goes against them and that is the biggest problem.  Who in the right mind would counter their own logic of Entry and willingly buy when the price goes higher after they have shorted? 

The conflict of logic between Entry and Exit in addition of no Exit plans at times caught them off-guard and delay the cutting loss process, especially when market move fast against them.  At the end they tend to close the positions unwillingly (always a sign of problem)!  And the cycle repeats again.  That's why not many people can implement trend-following strategy which is more difficult to start a trade.  It is human nature to give up too easily or listen to so call "expert"'s advice as they don't have to learn and bear the painful responsibility of admitting that their decisions were wrong.

Personally, the right Exit in trend-following strategy is even harder as one needs to withhold the temptations to take profits early.  That is however, entirely different topic.

Please bear in mind that the relationship between Entries and Exits in counter-trend and trend-following would have changed side if suddenly most products starts ranging all the time.  The Exit for counter-trend would become easy as taking profit to exit Shorts by buying when the market drop and selling to take profit when the market goes higher seems in sync with our instinct and logic! 

Until that day arrives, we'll need wisdom to defer our instant pleasure-seeking nature, the need to be validated by others, the need to prove that we are correct all the time(therefore focussing on short-term result) and go Trend-Following, although not easy, but easier than finding a good exit solution for counter-trend trading strategies that consistantly work and has a good risk-to-reward ratio in a trending environment.  At the same time, you must remain sensitive to market paradigm shift and if needed to, change your approach accordingly to match the ever changing environment.   Good luck and Happy trading!
     
       

Thursday, October 1, 2009

Trading Systems - RSI Strategy That Works

Finally, after a few simple testings, I've managed to use RSI as a simple trend-following strategy and it works(on FKLI).  In fact the logic behind it is sound as well, although the backtested result has a profit factor of 2, it is not as impressive compared to other strategies which I have yet to post. 

The idea is that when a market is in a strong uptrend, the daily RSI(14) value will  go above 55, and seldom drop below 45 when retrace downward and when the market is in a strong downtrend, the RSI(14) value  crosses below 45 and seldom reach 55 in upward retracements.

Therefore we could design a system that go Long when the RSI(14) rise above 55 and turn Short when the RSI(14) penetrates below 45.  Lets backtest the idea with Bursa FKLI from Jan 1996 - Sep 2009(continuous front-month EOD data without adjustments) with basic 1 contract.

Here's the performance summary report:


and here's the equity curve (before cost) chart:



*(please note that we have break-even trades here)

In fact, considering that the trading system uses only RSI(14) indicator with default settings and without any complex optimization, the performance is the best so far comparing to those that I've posted such as EMA(3/7), EMA(3/30),MACD without filter, Bollinger Bands and the BBZ system.  It only lost to SMA(10/50) which is the simplest !  The next question is, does it work on FCPO?  What do you think?

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.



Technical Market Indicators are Just Tools

If there is one thing that my examples on Bollinger Bands showed and soon on RSI is that there is no such thing as good or bad market indicators, they are  just your tools, the effectiveness depends on how you select and use those tools in designing a trading system that is compatible with you and with the market that you are trading.  They are not trading systems on their own(which I'll discuss in my future postings).  Comparing them to trading systems is just like saying that buttons and zips are the same as pants.  They are the ingredients of the system.

When the market paradigm shifts(with detection tools which I'll go into in the future), either the parameters of the indicators in your system have to be changed or a whole new set of indicators and therefore new strategies may be needed to capture the new market structure.  You just have to be flexible enough to adapt.  I know, it is not easy to be rigid in following the system's signal and be flexible to modify the system when it started leaking at the same time!  That's probably why less than 5% are succesful traders.

Another close analogy would be to treat market indicators like the weapons that you will use in a war.  Every weapon has its strengths and weaknesses, it depends on where(which market), how(trading strategy), when(time-frame) and with whom(market participants) you fight your war, you just have to study and know them (like we need to know the indicators) and choose the ones that fit well with your own strengths and weaknesses.  It is ok to lose a few battles (individual trades) but what is important is to win the war(long-term trading result)!

There is no perfect trading system, only the ones that you are in balance with and have full confidence in applying then you stand a chance to survice the eventual worst drawdown and be successful in trading.  

This is the part where lady luck comes in.  If you are unlucky, you may start trading and immediately being hit by the worst drawdown, then you may have problem trusting the system, yourself and may even pull the plug before the turnaround comes.  If lady luck is on your side, you may have big profits that way pass your worst drawdown threshold and the rest is relatively smooth sailing already provided you don't get over confident and continue to respect the market, your best teacher in the world!   Best of luck & happy trading!     


  

Wednesday, September 30, 2009

Profitable Bollinger Bands Strategy - Trend-following (Breakout Entry)

I have shown that trading counter-trend using standard settings in Bollinger Bands is a good way to lose money in FKLI in previous post.  Now I'll reverse the strategy into a trend-following (breakout entry)  instead.  If my backtesting program is correct, the gross profit and gross loss should be the opposite of the counter-trend result, and therefore should be profitable.

Here is the performance summary:


and the equity curve (before cost) chart.



You can see from the report that it is indeed a profitable strategy (although not really impressive) and the equity curve chart is the reverse of the counter-trend chart. 

In fact from the performance summary report you can also know the minimum capital needed to sustain the maximum unrealised drawdown and still be able to trade at 100% margin according to the margin of RM5K(just top up whatever amount if you think that the highest possible margin is higher than the one here).  It also shows the average annual return if you decide to go with that minimum capital. 

I would suggest a much higher capital as it is very hard to stomach a drawdown of over 50% considering you need a return of 100% at that stage just to get back to your starting capital.  The usual rule is the percentage of maximum unrealised drawdown over starting capital of not more than 30% as the worst trades will always be ahead of you.  Even with all this you can never be certain that you will survive as the future performance is always unknown.

With some simple optimization, I am sure a better parameter with smaller drawdowns and higer system expectancy would be found.  Just make sure the sample (in-sample as well as out-sample) data that you test on contain all the different market cycles of bulls, bears and sideways market.  You just need to find a trade-off that matches with your own risk appetite.


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.  
 

Bollinger Bands Counter-trend Strategy - Continue

    
Here's the performance summary report for Bollinger Bands strategy described in my earlier post, backtested on Bursa FKLI from Jan 1996 - Sep 2009 (continuous front-month EOD data without adjustment). 



and here is the equity curve (before cost) chart.



It surprises me again.  The strategy lose money big time!  It contradicts with my observation on daily charts that the prices seem to bounce between lower and upper Bollinger Bands. It even challenges the statistical notion that prices tend to fluctuate between 2 standard deviation (should be about 95% of the price movements) from the average moving price of the past x periods.  However, all is not lost, it also means that the reverse should be profitable meaning using it as a trend-following strategy instead of a reversal or counter-trend strategy. 

The question is, how much risk we'll have to take and what is the minimum capital to start in order to reduce the chances of blowing up our account before reaching the expected profit (maximum adverse excursion)?  I'll discuss and post some of the systems based on Bollinger Bands in my future postings. 

For now, I'll leave you with one question to ponder.  How do we verify that if a performance summary is good then the strategy really work?  Couldn't it be profitable just by luck or chance only?  In short, how do we trust the backtest result?

Hints on my future postings:  What is the problem with this advice that I kept overheard a broker gave to his clients; it goes roughly like this "The market is ranging, when it is ranging you should quickly take profit already...".  This is how I always evaluate every advice given by the so call pros--IS IT IMPLEMENTABLE MONEY MAKING ADVICE?  It doesn't matter whether the advice make sense or not, as sometimes money making advice counter our logic at first but works nevertheless.  As I have shown, even strategies that seems so logical, and is being advised by so many pros proved to be losing money.  Go ahead, take your best shots.


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.
      

Tuesday, September 29, 2009

Bollinger Bands - Counter-trend Strategy

Today, I overheard an interesting advice given by a broker to his client which goes somewhat like this "...sometimes you can also use Bollinger Band to sell when the price goes up above the upper line, then buy back when it goes to the lower line, short also can make money, long also can make money one, the price sometimes go up down up down one..." 

The conversation inspires me to detour again.  Hmmm... counter-trend trading.  I'll put Bollinger Bands to the test on my next posting.  What does your gut feel tell you?  Do you thing go Long when the price of FKLI penetrates lower Bollinger Bands and then turn Short (reversal trade) when it penetrates upper band (default setting--BB20,2) using EOD FKLI from 1996 - 2009 will make you good money?  We shall see...

Quite A Surprise (Again) on RSI !

I recall a friend/trader who is very obsessed with RSI (Relative Strength Index).  Everytime when we talk he would ask "what is the RSI on this date?", "what is the RSI on that date?" followed by his usual remark "ohhh, that's why it drop lah.." or "aha, that's why it goes up..".  For this friend of mine, I've put aside donchian style breakout in favor of RSI in this and subsequent post.

A very quick intro to RSI.  It is an oscillator which measures the relative strenght of the movement of prices.  Please google the rest on your own.  It can be programmed in excel as well, in my opinion, not as easy as MACD.

This time I do a backtest using RSI(14) using a very common strategy and default settings: go Long when RSI(14) crosses from below to above 30 (oversold), go Short when RSI(14) crosses from above to below 70 (overbought).  It is a Stop-and-Reverse(SAR) system where you square Long and turn Short at the same time and vice-versa.   The data used - Bursa FKLI continuous front-month EOD contract from Jan 1996 - Sep 2009.  Moeny management: basic 1 contract, SAR.

Heres the result...





And the equity curve (before cost) chart...



What a surprise, a common strategy that losses quite a lot of money!  Suddenly the ever so famous phrase "more than meets the eye" come into my mind.  In fact I can't even test with seed capital below RM90K !   A sure way to learn about risk of ruin!  If you look closely, the account has already blown up with the huge unrealised loss!  Ever wonder why people lose money trading purely on RSI using common strategy recommended by brokers, trading websites, books and seminars?

In my following post, I will try to find justice for this indicator by either using it as filters or optimize the parameters and see if I could get a robust and working trading system out of it.

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.

Monday, September 28, 2009

Turtle, any one?

     
Stay tuned, the turtles will be on the chopping block next...or maybe RSI...or Slow Stochastics...
    

3/7 EMA?

     
I get quite a lot of die hard fans of EMA 3/7 telling me how many hundreds of percent they have made in a short period of time.  Yes, you know who you are, don't be shy to admit! 

I'll post the backtested result here for your reference and feel free to correct me if I am wrong.  I know the die hard fans will claim that they are trading intraday, my advice?  Good luck!  You'll definitely need it.  To be fair, it is still a profitable system albeit a mediocre one, provided that your commissions and slippage is extremely low.

Here it goes...(Backtested parameters: Bursa FKLI EOD Jan 1996- Sep 2009, Stop-and-Reverse with basic 1 contract)




And as usual....
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.
       

What About EMA 3/30 ?

    
My brother wants to know the backtest performance summary for EMA 3/30 crossover.  Here is the result brother. 



And the equity curve (before cost) chart...






This is a Stop-and-Reverse (SAR) system trading 1 contract on Bursa FKLI (continuous front-month EOD data) from Jan 1996 - Sep 2009.  When the EMA 3(closed) crosses above EMA 30 (closed) the system would go Long 1 contract on next-day open and turn Short on next-day open when the EMA 3 (closed) crosses below EMA 30 (closed).

Happy trading brother!

And as usual....

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.
      

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.

 

Sunday, September 27, 2009

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

Here, I would just like to test the usefulness of adding filters in a trading system.  As usual, before designing any trading system, we'll have to at least make sure that the underlying strategies make sense to us.  In this example, I would like to test the profitability of using a very famous momentum-based oscillator called MACD and backtest the system on FKLI index futures from 1996-2009.  After that I would try to add a SMA filter and see if it would improve the performance of the trading system.

The MACD is a relatively short-term momentum indicator and the positive or negative divergence is easy to program in excel and therefore can be easily tested.  The reason I want to test this is because from a daily chart observation, it looks like a very profitable strategy going Long when the MACD line crossover above the signal line and going Short when the MACD line crossover below the signal line.  For the test, I'll go Long on next-day market open when we have a positive divergence (MACD line crossover above the signal line) and turn Short on next-day market open when there is a negative divergence (MACD line crossover below the signal line).  It is a Stop-and-Reverse system.  I will be using the default setting of MACD(12,26,9) and a daily closed of FKLI from Jan 1996 until August 2009(continuous front-month data) trading basic 1 contract.  If you want to know more detail about MACD, you can read Gerald Appel's (the inventor of MACD) book title "Technical Analysis - Power Tools for Active Investors".

And here is the trading system's performance summary report before adding any filters.




This is another case of observational bias in trading (a lot of traders fall into this category).  Things that look good on a few occurances (minutes, hours, days, weeks or months of observation) when put under statistical long-term test yield a different result, and quite often a disappointment!  To be fair, the system actually is profitable before adding in the cost of trading and slippage + rolls.  Again, that is why a lot of system sellers are unrealistics in giving you the backtested trading performance summary without adding the actual cost and skid of trading!  Be very careful when you read those system performance summary.

To add salt to the wound, we have to remember that very often the performance of a good and robust trading system will degrade overtime!  So we can't fool ourselves that it will perform better in the future. 

In the next post, I will add in a SMA as a filter and see if we can improve the system's profitability.  Until then...

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.

 

Friday, September 25, 2009

Equity Curve Chart




And here goes the sample equity curve chart for the fixed ratio MM performance summary that I have just posted.


With Fixed Ratio Money Management




Here you can really see the difference in performance when appropriate money management rules are added.


I choose (of personal taste) Fixed Ratio MM from the author of the book "The Trading Game - playing by the numbers to make Millions" by Ryan Jones instead of Fixed Fractional MM made popular by Ralph Vince in his book "The mathematics of Money management - risk analysis techniques for traders". You can find out the reasons for choosing fixed ratio over fixed fractional in his book, I don't wish to discuss here.

Equity Curve Chart



And here is the equity curve chart for the SMA 10/50 (daily closed) FKLI trend-following sample system that I have just posted.


Awaken from Hibernation





Didn't update the blog for quite some time. Have been taking my own sweet time to improve on my backtesting system on MS Excel. It has been quite a challenge trying to design and implement a backtesting system that I can at least show it to people who knows their stuff.


Some major things that finally my backtesting system can do:


1) Separate Long trades and Short Trades (earlier system was a SAR-Stop-and-Reverse only system) and get their trade statistics for e.g. % of winning long trades v.s % of winning short trades, average winning long trades v.s average winning short trades etc


2) Each direction of trade e.g Long trades can have different parameters for stop-loss and profit-exit. Example: I can have a Donchian style 20 period breakout above for going Long with 2ATR(Average True Range) for stop-loss and 18 period exit and 22 period for going Short with 1.5ATR for stop-loss and 18 period exit. I know a bit overkill at times and must be careful to avoid situations where parameters for going Short is earlier than Long exit, no meaning if you are trading a single account. How do you turn Short while holding Long ?


3) Probability that your maximum intraday unrealised loss would not reach a certain amount. Example I can now know that 99% of the time my open positions should not have reach 60 pts for FKLI if I am trading a trend following system based on SMA 10/50(daily) crossover system.


4) Probability that my maximum intraday unrealised profit should reach. For example using system above, I can tell that 50% of the time I can expect maximum intraday profit of 69 pts.


5) Fixed Fractional Money Management or Fixed Ratio Money Management



And many other little tweaks and improvements.



Enough talk for now. I will leave you all with a sample trading system (above) and its performance summary backtested over 13 years using Bursa Malaysia's FKLI spot-month continuous contract. Please remember: Always verify the performance summary on your own.

AND

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.