All posts by George Pruitt

George Pruitt - Author - Blogger - Programmer - Technician Bachelor of Science in Computer Science from UNC-Asheville Levo Oculos Meos In Montes

Replicate Turtle Trading by Creating Virtual Trade Functionality

My next little project is to create an EasyLanguage extender by creating a virtual trading function. The Turtle System always waits until a losing trade prior to taking a new trade. In EasyLanguage this doesn’t exist. This is similar to my Ghost Trader in Building Winning Trading Systems with TradeStation (1st and 2nd edition.)

In order to virtualize theoretical positions you must have the ability to enter/exit long/short positions. To carry this out we will create four functions:


Information will need to be passed back and forth between the call program and the functions. Here is the template of the virtualBuy:

 Inputs: price(numericSimple),orderType(numericSimple),fillPrice(numericRef);
{Function to see if a virtual buy order was filled - we are passing the entry price, orderType
[stop,limit,market] and we will reply with with true or false and the fill price.
1 - Stop
2 - Limit
3 - Market}

VirtualBuy = 0;
Case 1:
	If high >= price then
		fillPrice = maxList(open,price); {check for gap open}
		VirtualBuy = 1;
Case 2:
	If low < price then
		fillPrice = minList(open,price); {check for gap open}
		VirtualBuy = 1;
Case 3:
		fillPrice = open;
		VirtualBuy = 1;
	fillPrice = 999999;
	VirtualBuy = 0;

Using CMI with Turtle Approach

Here is a nice little function that helps determine market choppiness. This function measures the actual distance the market moves against the total distance traveled. If the market starts in the lower left of your chart and moves, without much gyrations, to the upper right then the CMI will reflect a higher value. However if the market moves frantically around the chart and doesn’t achieve a great distance from the initial to the end points then the CMI will reflect a lower number.

Inputs: periodLength(NumericSimple);
Vars: num(0),denom(1);

	denom = Highest(High,periodLength) - Lowest(Low,periodLength);
	num =Close[periodLength - 1]- Close;
		num = AbsValue(num);
	if (denom <> 0) then ChoppyMarketIndex = num/denom * 100;

You can use the CMI function to help determine when you should follow a Turtle style break out. If the market has been trading in a range and you get a break out it might just carry a little more validity. Buying/Selling at really high/low prices may lead to false break outs.