King Keltner Source Code

Looking for a trend follower – give this one a try!

 [LegacyColorValue = true]; 

{King Keltner Program
King Keltner by George Pruitt -- based on trading system presented by Chester Keltner
 -- an example of a simple, robust and effective strategy}

Inputs: avgLength(40),atrLength(40);
Vars: upBand(0),dnBand(0),liquidPoint(0),movAvgVal(0);

movAvgVal = Average((High + Low + Close)/3.0,avgLength);
upBand = movAvgVal + AvgTrueRange(atrLength);
dnBand = movAvgVal - AvgTrueRange(atrLength);

{Remember buy stops are above the market and sell stops are below the market
 -- if the market gaps above the buy stop, then the order turns into a market order
 vice versa for the sell stop}

if(movAvgVal > movAvgVal[1]) then Buy ("KKBuy") tomorrow at upBand stop;
if(movAvgVal < movAvgVal[1]) then Sell("KKSell")tomorrow at dnBand stop;

liquidPoint = movAvgVal;

if(MarketPosition = 1) then Sell tomorrow at liquidPoint stop;
if(MarketPosition =-1) then BuyTocover tomorrow at liquidPoint stop;
Please follow and like us:

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;
Please follow and like us: