KING KELTER system code

Hi guys , i was reading building winning trading sytems with tradestationbook there a code is given for King Kelter system but the code is not working can any body tell me why?
{King Keltner by George Pruitt?based on trading system presented by Chester
Keltner}
Inputs: avgLength(40), atrLength(40);
Vars: upBand(0),dnBand(0),liquidPoint(0),movAvgVal(0);
movAvgVal = Average((High + Low + Close),avgLength);
upBand = movAvgVal + AvgTrueRange(atrLength);
dnBand = movAvgVal - AvgTrueRange(atrLength);
if(movAvgVal > movAvgVal[1]) then Buy ("KKBuy") tomorrow at upBand stop;
if(movAvgVal < movAvgVal[1]) then Sell Short("KKSell") tomorrow at dnBand stop;
liquidPoint = movAvgVal;
If(MarketPosition = 1) then Sell tomorrow at liquidPoint stop;
If(MarketPosition = -1) then Buy To Cover tomorrow at liquidPoint stop;
 
Quote from Rajatheroyal:

Hi guys , i was reading building winning trading sytems with tradestationbook there a code is given for King Kelter system but the code is not working can any body tell me why?
{King Keltner by George Pruitt?based on trading system presented by Chester
Keltner}
Inputs: avgLength(40), atrLength(40);
Vars: upBand(0),dnBand(0),liquidPoint(0),movAvgVal(0);
movAvgVal = Average((High + Low + Close),avgLength);
upBand = movAvgVal + AvgTrueRange(atrLength);
dnBand = movAvgVal - AvgTrueRange(atrLength);
if(movAvgVal > movAvgVal[1]) then Buy ("KKBuy") tomorrow at upBand stop;
if(movAvgVal < movAvgVal[1]) then Sell Short("KKSell") tomorrow at dnBand stop;
liquidPoint = movAvgVal;
If(MarketPosition = 1) then Sell tomorrow at liquidPoint stop;
If(MarketPosition = -1) then Buy To Cover tomorrow at liquidPoint stop;


Attempted corrections below:

Code:
Inputs: avgLength(40), atrLength(40);
Vars: upBand(0),dnBand(0),liquidPoint(0),movAvgVal(0);
movAvgVal = Average((High + Low + Close),avgLength);
upBand = movAvgVal + AvgTrueRange(atrLength);
dnBand = movAvgVal - AvgTrueRange(atrLength);
if(movAvgVal > movAvgVal[1]) then Buy ("KKBuy") Next Bar at upBand stop;
if(movAvgVal < movAvgVal[1]) then Sell Short("KKSell") next bar at dnBand stop;
liquidPoint = movAvgVal;
If(MarketPosition = 1) then Sell next bar at liquidPoint stop;
If(MarketPosition = -1) then Buy to cover next bar at liquidPoint stop;
 
Quote from intradaybill:

Attempted corrections below:

Code:
Inputs: avgLength(40), atrLength(40);
Vars: upBand(0),dnBand(0),liquidPoint(0),movAvgVal(0);
movAvgVal = Average((High + Low + Close),avgLength);
upBand = movAvgVal + AvgTrueRange(atrLength);
dnBand = movAvgVal - AvgTrueRange(atrLength);
if(movAvgVal > movAvgVal[1]) then Buy ("KKBuy") Next Bar at upBand stop;
if(movAvgVal < movAvgVal[1]) then Sell Short("KKSell") next bar at dnBand stop;
liquidPoint = movAvgVal;
If(MarketPosition = 1) then Sell next bar at liquidPoint stop;
If(MarketPosition = -1) then Buy to cover next bar at liquidPoint stop;

The only problem is with the calculation of the moving average. Here is the corrected line.

movAvgVal = Average((High + Low + Close)/3,avgLength);
 
Back
Top