Advertisement
Maurizio-Ciullo

KJTradingFreeES04-25

May 11th, 2025
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Momentum & Keltner Stochastic Combo
  2. //
  3. //kjtradingsystems.com
  4. //
  5.  
  6.  
  7. Inputs: UsePositionSizing(1),MomLengthL(60), MomLengthS(150), Threshold(90);
  8. Var: ncons(1), KeltnerLength(5), KeltATRs(.5);
  9. Vars: KeltnerStochastic(0),UpperKeltner(0),LowerKeltner(0);
  10.  
  11.  
  12. var:NetEquity(0);
  13. NetEquity=15000+NetProfit+OpenPositionProfit; //assume $15K start account size
  14.  
  15.  
  16. UpperKeltner=keltnerChannel( C, KeltnerLength, +KeltATRs );
  17. LowerKeltner=keltnerChannel( C, KeltnerLength, -KeltATRs );
  18.  
  19. KeltnerStochastic = 0;
  20. if UpperKeltner <> LowerKeltner then KeltnerStochastic = 100*(Close - LowerKeltner) / (UpperKeltner - LowerKeltner);
  21.  
  22.  
  23. ncons=1; //baseline case (no position sizing)
  24.  
  25.  
  26. //entries
  27. if C > c[MomLengthL] and KeltnerStochastic < Threshold  then begin
  28. //NOTE: For MES, 15000 should be changed to 1500
  29. if UsePositionSizing=1 then ncons=.33*round(NetEquity/15000,0)+1;
  30. if ncons>15 then ncons=15;
  31. Buy  ncons contracts next bar at market;
  32. end;
  33.  
  34. if   C < c[MomLengthS] and KeltnerStochastic > Threshold then Begin
  35. //NOTE: For MES, 15000 should be changed to 1500
  36. if UsePositionSizing=1 then ncons=.33*round(NetEquity/15000,0)+1;
  37. if ncons>15 then ncons=15;
  38. SellShort  ncons contracts next bar at market;
  39. end;
  40.  
  41. //exits
  42. if MarketPosition = 1 and KeltnerStochastic > Threshold then
  43. Sell next bar at Market;
  44.  
  45. if MarketPosition = -1 and  KeltnerStochastic < Threshold then
  46. BuyToCover next bar at market;
  47.  
  48. //stoploss
  49. setstopcontract;
  50. If MarketPosition=-1 then SetStopLoss(1.0*AvgTrueRange(15)*BigPointValue);
  51. If MarketPosition=1 then SetStopLoss(4.0*AvgTrueRange(15)*BigPointValue);
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement