- ago
Hello, has someone operated the Turtle strategy from WL4/5 to WL8 and would be willing to share the source code? Thank you.
0
621
Solved
23 Replies

Reply

Bookmark

Sort
- ago
#1
Hi,

We don't have it yet but for now you can try to use Building Blocks to get the core (Donchian channel breakout) working.

It's this rule that currently cannot be implemented using Blocks, but we should think about adding it - if possible:

"If the last trade in the same instrument had been a winner, we would skip the 20-day breakout. Instead, we wait for a longer-term 55-day breakout to enter again."
0
- ago
#2
I just quickly converted and published the Turtle Trader strategy. Restart WL8 and check it out under "WL.com Published Strategies"!

https://www.wealth-lab.com/Strategy/DesignPublished?strategyID=25
2
Best Answer
- ago
#3
Thank you so much for the fast and very helpful port!
1
- ago
#4
Hi again Eugene. The following questions are arguably not specific to this strategy, but rather more related to me being absolutely new to writing strategies in WL :)

I would like to better understand the need and reasoning for these 2 code blocks:

QUOTE:
if (GetPositions().Count == 0)
{
L1 = Highest.Series(bars.High, ChannelUp)[bar];
S1 = Lowest.Series(bars.Low, ChannelDn)[bar];
L2 = L1 + 0.5 * N;
S2 = S1 - 0.5 * N;
L3 = L1 + 1.0 * N;
S3 = S1 - 1.0 * N;
L4 = L1 + 1.5 * N;
S4 = S1 - 1.5 * N;
PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, L1, "L1");
PlaceTrade(bars, TransactionType.Short, OrderType.Stop, S1, "S1");
}


and

QUOTE:
if (OpenPositions.Count == 0)
{
...
{
L1 = Highest.Series(bars.High, ChannelUp)[bar];
S1 = Lowest.Series(bars.Low, ChannelDn)[bar];
L2 = L1 + 0.5 * N;
S2 = S1 - 0.5 * N;
L3 = L1 + 1.0 * N;
S3 = S1 - 1.0 * N;
L4 = L1 + 1.5 * N;
S4 = S1 - 1.5 * N;
PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, L1, "L1");
PlaceTrade(bars, TransactionType.Short, OrderType.Stop, S1, "S1");
}
...
}


To me, the essentially do the same thing, enter System 1 breakout trades. I know that the 2nd code block also checks for the Skipped/Fake trade condition, but why the need for the first block?

I assume there is an intrinsic difference between GetPositions().Count ==0 vs. OpenPositions.Count == 0 ?

Thanks for any insight you can provide.
0
- ago
#5
In the screenshot below, I see five Stop-Sell lines plotted, but the tabular Positions list is trying to place eight positions to sell. Is this by design, or should I be looking for a problem?

I'm not even sure the strategy is holding five or eight positions to sell for the off-the-Chart bar, but that's another issue. Should it be?

This is an interesting strategy so I'm willing to troubleshoot it some. Right now I'm just trying to figure out how it should be working in the first place.

0
Glitch8
 ( 10.94% )
- ago
#6
Several of the stop orders have exactly the same price. that’s why you see a fewer number of lines.
1
- ago
#7
QUOTE:
Several of the stop orders have exactly the same price.

Thanks for noticing that. So the method used to determine whether or not to include a stop order is flawed. Interesting. I'll need to study it in depth to try to fix that. It creates eight stop sell orders, but I'm not sure it owns that many positions in the first place (but I could be wrong).

I appreciate the need to take "some" off/on the position as prices change. I don't trade that way, but Jim Cramer (of Mad Money) recommends it since one can't time the entry and exit precisely.

I did "attempt" to rewrite it to make it "simpler". And although adding the child class makes to code shorter, it also adds some complexity for the non-C# programmer. I can post that solution (with optimizing parameters). But its main redeeming value is that it looks more like a traditional C# program.
0
- ago
#8
QUOTE:
I did "attempt" to rewrite it to make it "simpler". And although adding the child class makes to code shorter, it also adds some complexity for the non-C# programmer.

Published Strategies is rather about the performance and evolution of strategies than the code purity.
0
- ago
#9
QUOTE:
Strategies are rather about the performance

Well, it might execute "slightly" faster (execution performance), but the solution performance is exactly the same, and that was intentional for now. I did add optimizing parameters, which would help with profit performance. But I'm not sure I like how it behaves from a design prospective. Setting eight stops positions for the off-the-Chart bar (with duplicate Stop prices) is bad behavior in my opinion. I think it needs fixing.

And honestly, one Stop-sell position per bar makes better sense to me. I can't imagine "The Turtles" would place multiple Stop-sell orders per bar (but I could be wrong).
0
- ago
#10
@pixbroker

QUOTE:
I assume there is an intrinsic difference between GetPositions().Count ==0 vs. OpenPositions.Count == 0 ?

The difference between GetPositions vs OpenPositions here is that when GetPositions().Count ==0 this means there are no positions i.e. the system is about to make its very first trade. OpenPositions is dynamic, it reflects how many positions the system has open on the current bar.
0
- ago
#11
Is there an article available discussing the intended method used by this strategy?
0
- ago
#12
Of course, if you search for 'Turtle trading'. As for this strategy, I simply converted the WL6 code written 10+ years ago 🤷‍♂️ https://wl6.wealth-lab.com/Strategy/Details/146
0
- ago
#13
@superticker:

Original Turtle Rules: https://oxfordstrat.com/coasdfASD32/uploads/2016/01/turtle-rules.pdf

A related blog post, which interesting added detail, although I question some of the accuracy in this post: https://www.financialwisdomforum.org/gummy-stuff/turtle-trading.htm

FWIW, I am in the process to fully understand this rule and extend @Eugene's strategy implementation to handle the volatility based unit risk sizing.

I created a spreadsheet trying to model the Turtle System described in the original PDF. For anyone familiar with the Turtle System or anyone who is interested to help, I would appreciate feedback. Only look at the "HO03H" sheet (the others are work in progress).

https://docs.google.com/spreadsheets/d/1QbQjAJgEDvk8QXIlypQaT-K5WjthoEtx3jQ90cpged4/edit?usp=sharing

I used the HLC values of the HO02H contract given in the paper and tried to match their calculation of TR, ATR (N) and unit size. This seems to look right. However, where things fall apart for me is if one considers the max $ amount of a potential 2N stop loss. It's seems incredibly high.

Any feedback welcome.
2
- ago
#14
QUOTE:
I used the HLC values of the HO02H contract

Who is your data feed provider for this? My current IQFeed subscription doesn't include it.

I don't trade options and commodities so my data feed providers aren't including this data. But I would like to pull this example into WL to see if I can get the same numbers. Perhaps I should just read it in as an ASCII file.
0
- ago
#15
I just used the HO prices shown in the original Turtle rules pdf and brought them into my spreadsheet (and WL) via CSV file.

I don't trade HO but since this is the only concrete example (with actual numbers to follow the math) in the original rules pdf, I wanted to verify my calculation and code with them.

I even coded my own TR and ATR (N) to make sure its the exact math described in the document.
1
- ago
#16
I'm just now looking at the original WL8 code for this Turtle Trader strategy with greater scrutiny. Here is an example where this code is placing two separate Stop-Sell orders on the same position. My broker won't let me place conflicting stop orders. (Some of the variables have been renamed.)
CODE:
   for (int posIdx = OpenPositions.Count-1; posIdx >= 0; posIdx--)    {       Position pos = OpenPositions[posIdx];       if (pos.PositionType == PositionType.Long)       {          double LS = pos.EntryPrice - 2*atrBar;          ClosePosition(pos, OrderType.Stop, LS, "LongStop");          ClosePosition(pos, OrderType.Stop, LE, "LongExit");       }       else
My point is the original Turtle Trader WL8 code in its current form is broken and requires some reworking.

Also, regarding the gummy-stuff link in Reply# 13, I've use Professor "Gummy's" stuff to write some indicators of my own. And although I haven't looked at his Turtle Trader pages, I can say what he has posted (which I have used in the past) is good stuff. Also, he's retired now, but I suspect his students would have corrected any mistakes he might have made in his webpages by now. Hats off to him.
0
- ago
#17
You could just place one stop order, the one that is closer to the entry price of the open position. It would be the first order filled anyways so the one that is further away from the position would remain unfilled. So this code you point out could do the check and place either but not both.
1
Glitch8
 ( 10.94% )
- ago
#18
If you are auto-trading this in WL8, WL8 will intelligently submit only the stop order that is closer, the other one will be ignored. This is part of its "order pruning" logic.
2
- ago
#19
Regarding Gummy, I am curious about this line from his GE example:

CODE:
Then Dollar Volatility = N D = (1.45)(18.86) = $27.35 per share.


He is multiplying the share price with N. This results in an exceptionally large dollar volatility. In fact, larger than the share price itself.

The point of dollar volatility in the Turtle strategy is to control risk. But in his example, he is estimating the risk to be greater than the stock price itself. In other words, he is modeling the worst case of GE not only going to $0, but actually going negative :) GE loosing more than 100% of value in one day (ATR, N).

The original paper uses N*DollarsPerPoint. DollarsPerPoint of regular stocks like GE is 1. One dollar is one point. So in his example, dollar volatility is $1.45. Worst case, GE will loose $1.45 in a single day.

The rest of his blog post about the Turtle strategy makes sense.
0
- ago
#20
QUOTE:
He is multiplying the share price with N. This results in an exceptionally large dollar volatility .... larger than the share price itself.....

The original paper uses N*DollarsPerPoint. DollarsPerPoint of regular stocks like GE is 1. One dollar is one point.

I agree, the volatility shouldn't be larger than the share price itself. If Gummy wrote that, then he messed up.

I didn't know WL8 had purging logic to remove extraneous orders (when auto-trading). The Positions tab listed all orders (including the ones that would be purged), which seems confusing. I think the strategy itself should be doing the purging by only placing stop-sell orders with the highest (most conservative) price for long positions.
CODE:
   for (int posIdx = OpenPositions.Count-1; posIdx >= 0; posIdx--)    {       Position pos = OpenPositions[posIdx];       if (pos.PositionType == PositionType.Long)       {          double LS = pos.EntryPrice - 2*atrBar;          if (LS > LE)             ClosePosition(pos, OrderType.Stop, LS, "LongStop");          else             ClosePosition(pos, OrderType.Stop, LE, "LongExit");       }       else       {          double SS = pos.EntryPrice + 2*atrBar;          if (SS < SE)             ClosePosition(pos, OrderType.Stop, SS, "ShortStop");          else             ClosePosition(pos, OrderType.Stop, SE, "ShortExit");       }    }
0
- ago
#21
I know what you're thinking; Superticker isn't a Short trader. That's true. I don't think this strategy is going to agree with me.

0
- ago
#22
@superticker, it's a Stop order to take either side of the market when there are no open positions yet. What's weird in determining the direction of the market if the system would only go either long or short (and take subsequent trend trades in that direction then)?
0
- ago
#23
In my opinion the stop loss order and the exit stop orders are mutually exclusive. It is nice that WL will purge the one that is not needed, but for the sake of understanding, and clarity, i think the circled stop orders in the attached screenshot could be omitted by the strategy itself with the aforementioned if statement.


0

Reply

Bookmark

Sort