Sunday, August 4, 2013

10 New Back Tests: TSI Vector Strategy

In the past day I was able to knock out 10 new back tests using the True Strength Index (TSI) vector strategy. The results are promising and in this post we'll take a look at them in some detail, and also take a peek at their respective equity curves.

I am finding that as I have several ticker symbols that respond well to the strategy it is getting a bit quicker to add new promising candidates. Ultimately I would like to have around 50 of these in play, then do the 'bring me down to reality' process of using the TradeStation Walk-Forward analyzer and, assuming there is anything left to look at, begin posting the trades in real-time and see what happens.

The area in the left side panel of the home page will be used to record the real-time trades. I will replace the existing 'Stock Quotes' gizmo (just below 'Subscribe to my blog') with a list of (hopefully) 50 stocks/strategies. Each stock listed will include the signal indicated for the open market order of the next day's trade. The signal will either be BUY, SELL, HOLD or NO TRADE. Also, each ticker symbol will link to its own separate page with the data I have regarding its back test results and a recording of its performance in real-time. 

I purposely devised the strategy so that it is entirely based on where the stock ends at the close each day. That is, at 4:01 pm est I will know the market order signal for the following morning's NYSE open at 9:30 am est. It will be nothing complicated to use because one either buys, sells or holds at the open each morning. No limit orders, no stop orders, etc. Just market order to BUY or SELL. My strategy is written this way and that is precisely what it back tests.

Let's look now at a graphic that details the 10 new back test candidates. A number of these are mining companies but from here on out I will be expanding more broadly into the stocks that are members of the S&P 500 index.

One of the understandings being brought into clearer focus as I do this back testing stuff has to do with the general topic of risk and pain. Each strategy gives me an opportunity to control both concepts quite well. But the interesting thing is that if one has a decent tolerance for pain, tempered by an accurate understanding of risk, over time that person will, by far, make the most money.

The two S&P 500 ETF (SPY) strategies offer good examples of this observation. Both have extremely high win/loss ratios (88.6% - 86.5%) with modest $Avg Net per Trade ($150 - $160). However, both also have a large losing trade in excess of $1,000

As I am able to adjust the value for the stop loss variable, the results shown above have the stop loss for SPY-1 set to 15% and SPY-2 is set to 11%. If I try to avoid the large losing trade in SPY-1 by ratcheting down the stop loss from 15% to 4%, the largest losing trade shrinks from $1,055 to $815. And an even tighter stop of just 2% yields an even smaller largest losing trade of $690.

But the rub is that the 15% stop loss shown above for SPY-1 yields,  over 10 years, a Total Net Profit (including commission expenses - $7 to buy, $7 to sell) of $13,221. The 4% stop loss yields a much smaller Total Net Profit - $8,063. 

By taking less risk with the 4% vs. 15% stop, the largest loser shrunk by $240 ($1055 - $815). But the Total Net Profit yielded when using the 4% stop loss also shrunk - by a whopping $5,158 ($13,221 - $8,063).

My question: is reducing the largest loss by $240 worth giving up $5,158?

If one really cannot take much pain, dropping the stop loss from 15% to 2% brings the worst trade down from a loss of $1055 to $690, but also drops the Total Net Profit to $7,248. This strategy would allow one to sleep better at night, I suppose, but in the end one may consider it expensive sleep - to the tune of $5,973.

Here is a graphic of the first 4 ticker symbols' Equity Curves: AEM, AU, COST and GG

The Costco (COST) and Goldcorp (GG) strategies were a little slow to get in gear - kinda spinning their wheels for the first 8 - 10 trades. The Agnico Eagle Mines (AEM) equity curve is just about textbook perfect.

Here are the next 4: JCP, NCMGY, NEM and SA

On first blush the equity curve of JC Penny looks questionable after trade 20. The data that is not seen is that JC Penny topped at the same time as trade 20 - February 2007 ....... at $87.18. 

Any idea where JCP closed this past Friday? If not, the answer is $14.28. Over the past 6+ years, shares of JCP have lost 83.62%. Meanwhile, the strategy (bless its heart) kept trying to make money and really did not get anywhere, but it did not lose much either. Very little, in fact..... just a few hundred bucks.

And finally for the 2 equity curves of SPY.

If you followed the dialog above about risk tolerance and stop loss settings, you will understand why each strategy exhibited a vicious knife stab or two in their otherwise 'perfect' equity curves.

I hope you have a good week and keep in touch, OK?



  1. Hi John,

    These are outstanding results. Congrats!

    I see most of the stocks were tested over a 10 year period, including SPY.

    Did you find that the system gave better results when the security was in a bull market? For example, miners up until 2011, or SPY from March 2009? If you had a simple MA system to determine bull or bear, or perhaps using the weekly chart with MA's or even with something like ichi-moku, perhaps you could use the dominate trend as a filter. Trade only stocks or etf's that are in a bull market. ??

  2. John, congrats on the results you have achieved so far. I know you've put in a lot of time and hard work and I greatly appreciate your sharing your findings with us! Looking forward to seeing the "real time findings" as they evolve. Hope you get your project documented before school starts.

    All the Best,

  3. Thanks Gerald - I'm working on it as hard as I can. Not sure how this is going to turn out but if I press on I suppose we will all have a pretty good idea in a few months. Fingers crossed and doing the work. John

  4. pimaCanyon - yes, that is exactly what I do with your moving average idea. So yes, the system performs better when price is moving higher consistently and it drops out, as best it can anyway, when the bears are in control.

    Hey, for now this is a long only strategy.

    If you read my comments for JC Penny above (even better, looked at a JC Penny longer term chart) you would see that the system held it's ground (did not lose a lot of retained profit from earlier bull years) while the JCP stock collapsed from something like $85 to $14 from 2007 to today.

    Maybe just dumb luck, but that kinda impressed me. If I personally had tried to buy long only for 6 years while JCP lost over 80% of its value I am quite sure I would not still have all the marbles in my pocket.

    Anyway, I am being encouraged to start the walk forward testing to see if I can get a preliminary grip on what, if anything, I have. This appears to be a comparatively slower process as the computer runs for hours on end before finally producing a lengthy report.

    More long long hours of tedium. And a new learning experience for me, absolutely.

  5. those equity curves growth looks unsustainable to me ;)

    good results though!

  6. If I understand correctly you just create a vector when the TSI crosses 0 from the zeroline with a defined slope. One question is how do you determine the slope. The second question is if that is the entry the exit is when TSI crosses over the vector line? Please let me know if I am mis-understanding something here. Also let me know if you would want to/ would need help running these tests on a intraday basis using something like quantivity or quantconnect?


  7. R.Trader - I purposely avoided the intraday issue altogether. The system, by design, only trades a market order on the open - either a buy or a sell. There are profit targets and stop losses built into the code and tested, but for back testing and real time use no trades are triggered intraday, whatsoever.

    The entry and exits, of course, can work as you described, or they can be reversed.
    That is, the buy signal is used to sell and the sell signal is used to buy. Or the number of bars after the vector begins or ends can trigger a signal. Actually, a somewhat infinite number of other variations are possible. One variation that I think is kinda fun is what I call 'ping-pong'. This bounces the signals off one vector to a second vector, then back to the first vector, and so on. The slope(s) used are determined by trail and error, back testing.

    1. My only comment is when you do all these backtests all you are doing is curve fitting the data. If you have to change parameters for it to work well chances are it wont work in real time in the dynamic environment of the market especially with such a small sample size

  8. Hi John

    These are fabulous and very encouraging results! Congratulations!

    However, experience has taught me that real life trading however tends to be more modest - that slippage tends to rear its ugly head and that the official opening prices and closing prices may not be the same as the charts suggests and may significantly affect performance. A few cents slippage here and there don't seem like much, but over time, fractally, can make a vast difference in performance.

    Also, charts don't unfortunately show the spread between the bid/ask price, only the mid-price. Again, this will have a significant effect over time in Tradestation between theoretical and real life trading.

    It's great though that you're being prudent in your approach and analysis so I expect your continued outstanding performance to continue nonetheless!

    I also admire your very clear and concise explanations of all your trials and tribulations! Although I don't usually comment much here, I do enjoy regularly reading your blog! You're probably my favourite 'guru'!

    All the best

  9. Thanks Greg for taking the time to share your thoughts. Maybe now that you have written one comment the experience will have been OK and you will write again, but sooner than later.

    Teaching public school for 31 years has probably helped me with the clear and concise thing.

    Trading in real-time and making these strategies are two different animals. No disagreement there, whatsoever. I first invented this strategy in ThinkScript on Think or Swim and was pleased that when I finally figured out how to write the code in EasyLanguage for TradeStation I got the identical trades, the identical entries and exits, the identical win/loss ratios, and so on. I appreciate your thoughts about slippage etc., but hope I have taken all of that nonsense off the table. If this strategy exited at a particular stop loss amount or targeted percent profit then that issue would possibly be a problem. By the way, apparently that is how most people try to do this.

    The computer back tests and gives you those loss/target prices when they occur - but if one is trading a lot of money there may well not be enough liquidity to give you that price. So the back test results are, in my mind, forever suspect. My system is exclusively based on entry and exit on the NYSE open with a plain old vanilla market order. Simple. And the back test figures give me the price and date each trade executed and sure enough, it is ALWAYS the opening price.

  10. R.Trader - your skepticism is justified and welcomed. If my system works, it will be plain for all to see. If it does not work, it will be plain for all to see. I enter into sharing my journey with you and other readers knowing full well this could go either way. And I am absolutely OK with that.

    What I think you may have meant to say was that optimization of the variables used is curve fitting, not running the back tests. The back tests just do what they are told and have no idea whether they are doing as the master wishes. However, asking the computer to run through a trillion numbers to find the best combinations is indeed curve fitting - pure and simple.

    This morning I concluded my first walk-through analysis of the SPY-1 strategy. I am just learning how to do this correctly - reading everything I can - and following the directions given.

    The 'book' suggests the range for each variable to be tested based largely on the number of variables in the strategy. It also details the % to be used as out-of-sample, the number of test considered the minimum for statistical reliability, and so on - even the number of days until the strategy should statistically be reoptimized.

    So I followed the directions and the system passed. Some of the various cells passed 'with distinction', so it tells me. So that's encouraging .... but just the beginning of more work.