Posts Tagged ‘backtesting’

Improved Generalized Trailing Stop Strategies for Think or Swim

October 31, 2010

With the latest release, we now have a TOS function in our strategies called “entryprice()”. It returns the price of the most recent entry while using strategies. This is great news for us, because it means we no longer have to reproduce our entry signals in a trailing stop strategy like I described in my earlier post! While it doesn’t make a trailing stop strategy any easier to code, it does make them universal instead of entry specific.

I have created two strategy files for my Donors that use this function to approximate having a trailing stop in the market. There’s one for long exits and one for short exits. Here’s a picture of one in action:

The way this works on the long side is this: after entry, a stop is placed x points (or percent, there is an input) below the entry price. As we make new highs, the stop loss is trailed up x points/percent below that high. It’s the opposite for shorts. In the picture, we didn’t get a big enough retracement from each subsequent low to trigger our trail. It just kept getting moved down until it finally hit.

With these files, you just add them to any chart that you are running any entry strategies on, and they will just work, no other coding required. These strategies are available to blog donors. You can download “TrailingStopStrategies.zip” which contains the strategy files from the Donors Only folder at “Released Thinkscript Strategies” from my Google site. If you are trying to do it yourself, leave a comment and I can answer questions or give some pointers.

Testing a New Trading Strategy

February 6, 2009

I’m starting to look at some different things for my trading plan. I have the beginnings of a strategy starting to come together. With my emotional makeup and out-of-phase intuition, a mechanical system, even if I am manually executing it, is absolutely essential to me at this time.

I have a simple mechanical entry indicator, a mechanical trailing stop, and a situationally-based pre-emptive profit target exit. I ran a study on NQ 5 minute charts over the last 20 days, long side only so far. Here’s the intital results for one contract:

Strategy Report
Symbol: /NQ
Work Time: 2009-01-08 – 2009-02-06

Max trade P/L: 684.00
Total P/L 2,751.00
Total 142 order(s)

Win rate was around 50%.

On 142 orders, that would be $497 in commissions, so net $2,254.00 on one contract. This tells me that my strategy has merit, at least for the market environment that we have had. I’ll report more on the exact strategy, along with Think or Swim strategy files, later on as things get more concrete. Plus, I’ll have more detailed reports after I get something that automatically parses the ToS strategy output.