Turtle System for Tradestation 9 Easy Language

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
Post Reply
highbrid
Contributor
Contributor
Posts: 1
Joined: Sat Oct 15, 2011 6:44 pm

Turtle System for Tradestation 9 Easy Language

Post by highbrid »

Hello all,

My background is in trading, predominantly in equities and equity options, but to date have only applied the rules of various trading systems manually without the aid of system testing software.

I am in the process of putting together an investment fund for close friends and family and will be using the turtle method of trend following with a few alterations of my own that have proven successful over the years.

I am currently using Tradestation 9 and admittedly foresee a huge learning curve ahead of me in being able to code the strategy I have been using to date.

To make things easier I thought I might ask if anyone has successfully coded the turtle rules into easy language and whether they would be kind enough to share it with me so that I can use it as a base to work from.

The rules I am referring to are not only the entry and exit signals but also, and more importantly, the position sizing and pyramiding parameters.

Please excuse me if it is considered inappropriate to be asking for this kind of information - but I thought it wouldn't hurt to throw it out there.

In return I will be happy to share the alterations I currently work with that have proven to minimize the drawdown of the turtle sysstem in sideways markets.

Thanking you all in advance,

h.
stopsareforwimps
Roundtable Knight
Roundtable Knight
Posts: 199
Joined: Sun Oct 10, 2010 1:47 am
Location: Melbourne Australia

Re: Turtle System for Tradestation 9 Easy Language

Post by stopsareforwimps »

highbrid wrote:...will be using the turtle method of trend following with a few alterations of my own that have proven successful over the years...
You might want to read this and related threads.

viewtopic.php?t=7301&highlight=turtle

I have a variant of Turtle but it is written in lisp so I don't think it would help you.
Ted Annemann
Roundtable Knight
Roundtable Knight
Posts: 118
Joined: Tue Apr 15, 2003 7:44 pm
Location: Arizona

Post by Ted Annemann »

Another useful post is HERE. It ran the exact backtesting software program written by an Original Turtle, to test the Turtle System One over a long period of time, including the "historical data" used by Dennis and Eckhardt to develop the Turtle System, and also the actual Turtle trading years (1981-1984) when they traded it with real money, and afterwards. The figure is copied below.
Attachments
Turtle System One
Turtle System One
TS_one_since_1970.png (17.73 KiB) Viewed 12841 times
Bravochico
Full Member
Full Member
Posts: 24
Joined: Wed Sep 14, 2011 11:46 pm
Location: Southern California, Ca

Post by Bravochico »

Easy language code is very simple for this. What part you need?

Why wouldn't you use TB? TS has no portfolio level testing unlike TB which was built with portfolio level testing as a priority? Extreme diversification is a must for turtles who want to survive over the long term.

I hope you aware of dangers of testing continous contracts on markets versus raw contracts. Usually continous contracts inflate back test results.
babelproofreader
Roundtable Knight
Roundtable Knight
Posts: 138
Joined: Wed Nov 10, 2004 4:36 pm

Post by babelproofreader »

Usually continous contracts inflate back test results.
Would you care to explain why this is so?
Bravochico
Full Member
Full Member
Posts: 24
Joined: Wed Sep 14, 2011 11:46 pm
Location: Southern California, Ca

Post by Bravochico »

Good question. As I stated it usually inflates back test results, but not always. It depends on the strategy itself and it's look back and holding periods. I've seen many examples of this phenomena, particularly in smaller markets.
I'd never trade any backtested strategy on continous data without looking at raw contracts for signal discrepancy.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

Bravochico wrote: I'd never trade any backtested strategy on continous data without looking at raw contracts for signal discrepancy.
The Turtle System has a 50 day break out back up mechanism. Assume we are 10 days into a new contract and that the instrument concerned is in a period of considerable backwardation or contango. There is a sizable gap between the price at expiry of the prior contract and the first price of the current contract. Assume this results in a signal discrepancy. What is the procedure for resolving that discrepancy?
Bravochico
Full Member
Full Member
Posts: 24
Joined: Wed Sep 14, 2011 11:46 pm
Location: Southern California, Ca

Post by Bravochico »

Good question again. There is more than one method. It depends on the strategy specifics. I'm not a lttf.

The point being that if one assumes continous data gives the same result as using raw data for backtesting, I've seen cases where that was both true and false. It's not a forgone conclusion.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

Bravochico wrote: The point being that if one assumes continous data gives the same result as using raw data for backtesting.
It very much depends what you mean by "raw data". If a back testing engine requires a concatenated price series then I suggest the use of "raw data" will give you highly misleading results. If a back testing engine has the ability to test on individual contracts then the results are going to be accurate. Either way, you will be faced with a decision as to how to generate signals and on the basis of what price series.

Turtle is a trend following system - whether you define it as short or medium term does not really matter.

The real point in all this is:

1. Contango.
2. Backwardation; and
3. Price gaps on rollovers.

To fail to account for these will give back tested results which are, for all reasonable purposes, completely useless.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

Anyone with serious interest needs also to consider the special case of back testing LME forwards. "Ecritt" made a thoughtful post on this.
Bravochico
Full Member
Full Member
Posts: 24
Joined: Wed Sep 14, 2011 11:46 pm
Location: Southern California, Ca

Post by Bravochico »

AFJ:
Good points.

By raw contracts, I'm referring to the PnL report being derived from the contract that one would have had to have traded at the point in time.
When I traded for Man London there, they would test on raw data.
Eventhorizon
Roundtable Knight
Roundtable Knight
Posts: 229
Joined: Thu Jul 08, 2010 2:36 pm
Location: Boulder, CO
Contact:

Post by Eventhorizon »

I think there are two approaches to this ...

1) If you run a back-test today and get a certain set of trades, then run a back-test at a later date after the current set of front-month contracts have expired then the back-adjusted contract values will have changed due to the rolls taking place between the back tests. If you get the exact same trades and equity curve then you have handled the back-adjustment process appropriately.

2) Provide TB with the raw contract data - in time spliced fashion moving from one contract to the next per your rolling philosophy. Load from file whatever continuous contract data you need for trading decisions. Drive the trading decisions off the continuous and trade the raw. You should still see the exact same equity curve as in (1).

EDIT: it occurs to me that using method 2 you might have to think carefully about the P&L in TB - never tries it so I don't know!
Chuck B
Roundtable Knight
Roundtable Knight
Posts: 481
Joined: Thu Apr 17, 2003 6:34 am

Post by Chuck B »

AFJ Garner wrote:
The real point in all this is:

1. Contango.
2. Backwardation; and
3. Price gaps on rollovers.

To fail to account for these will give back tested results which are, for all reasonable purposes, completely useless.
Don't forget liquidity (lack thereof) in the non-front-month contract. For example, if you are sampling volatility or highs/lows within some system (let's say a 50-day breakout to make this simple), you can't depend (in numerous markets) on the out-month contract to actually have had a continuous trading market at those past points in time. Hence what you think is a 50-day high looking at individual contract data right after you roll into it, could be significantly different. Similarly if you use any volatility measure that depends on lows and highs, using illiquid out-month contract data can and will provide misleading calculations.

As mentioned just above, if you are holding a continuous position in a futures market, the roll-over transaction you do in real trading (i.e. Sell USZ11, buy USH12) is exactly equivalent to the calculation you do in a typical continuous contract. A proper continuous contract reflects exactly the result from holding a continuous position in a market (if you properly factor in your rollover commission, fees and bid/offer spread on the roll).
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

Chuck B wrote: Don't forget liquidity (lack thereof) in the non-front-month contract. For example, if you are sampling volatility or highs/lows within some system (let's say a 50-day breakout to make this simple), you can't depend (in numerous markets) on the out-month contract to actually have had a continuous trading market at those past points in time. Hence what you think is a 50-day high looking at individual contract data right after you roll into it, could be significantly different. Similarly if you use any volatility measure that depends on lows and highs, using illiquid out-month contract data can and will provide misleading calculations.

As mentioned just above, if you are holding a continuous position in a futures market, the roll-over transaction you do in real trading (i.e. Sell USZ11, buy USH12) is exactly equivalent to the calculation you do in a typical continuous contract. A proper continuous contract reflects exactly the result from holding a continuous position in a market (if you properly factor in your rollover commission, fees and bid/offer spread on the roll).
Couldn't agree with you more, including on liquidity. Unfortunately, it may take years of fiddling around with back adjusting and considering it in great depth before you come to this conclusion. There are still people on this forum who deny the accuracy of back testing using gap adjusted price series (leaving aside the question of ratio dependent calculations). Until these guys have actually gone through the matter in enough depth, the penny will not drop.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

Incidentally, Sluggo had mentioned on a different thread the name of software which enables testing on individual contract data rather than a concatenated series (back adjusted or otherwise). I had assumed such software enables rolling on some trigger such as OI or volume (or fixed date) as with the production of continuous contracts; without which it would indeed be useless. I can't believe that isn't the case. In which case the results should of course equate to tests using back adjusted data. In the case of such software there is no "gap" to beware of.
Last edited by AFJ Garner on Fri Oct 21, 2011 2:20 pm, edited 1 time in total.
Chuck B
Roundtable Knight
Roundtable Knight
Posts: 481
Joined: Thu Apr 17, 2003 6:34 am

Post by Chuck B »

AFJ Garner wrote:There are still people on this forum who deny the accuracy of back testing using gap adjusted price series (leaving aside the question of ratio dependent calculations). Until these guys have actually gone through the matter in enough depth, the penny will not drop.
I suppose the market will help them come to that realization at some point in the future if they're still around? :)
Chuck B
Roundtable Knight
Roundtable Knight
Posts: 481
Joined: Thu Apr 17, 2003 6:34 am

Post by Chuck B »

BTW, I should mention to those others that ages ago I settled on specific roll date criteria by market to build proper continuous contracts. The specific reasons for a given market's roll date vary depending on said market, but I've never built or used continuous contracts that depend on volume or OI rollovers (for whatever that's worth).
Post Reply