KING KELTER system code

Discussion in 'Strategy Development' started by Rajatheroyal, Jul 21, 2009.

  1. 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;
     
  2. I believe this is code for an older version of Easylanguage used by TS2000.
     

  3. 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; 
    
    
     
  4. Thanks bill ,its just giving the first signal and it was it giving even before changing "tomorrow"to" next bar".
     
  5. The only problem is with the calculation of the moving average. Here is the corrected line.

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