Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Momentum & Keltner Stochastic Combo
- //
- //kjtradingsystems.com
- //
- Inputs: UsePositionSizing(1),MomLengthL(60), MomLengthS(150), Threshold(90);
- Var: ncons(1), KeltnerLength(5), KeltATRs(.5);
- Vars: KeltnerStochastic(0),UpperKeltner(0),LowerKeltner(0);
- var:NetEquity(0);
- NetEquity=15000+NetProfit+OpenPositionProfit; //assume $15K start account size
- UpperKeltner=keltnerChannel( C, KeltnerLength, +KeltATRs );
- LowerKeltner=keltnerChannel( C, KeltnerLength, -KeltATRs );
- KeltnerStochastic = 0;
- if UpperKeltner <> LowerKeltner then KeltnerStochastic = 100*(Close - LowerKeltner) / (UpperKeltner - LowerKeltner);
- ncons=1; //baseline case (no position sizing)
- //entries
- if C > c[MomLengthL] and KeltnerStochastic < Threshold then begin
- //NOTE: For MES, 15000 should be changed to 1500
- if UsePositionSizing=1 then ncons=.33*round(NetEquity/15000,0)+1;
- if ncons>15 then ncons=15;
- Buy ncons contracts next bar at market;
- end;
- if C < c[MomLengthS] and KeltnerStochastic > Threshold then Begin
- //NOTE: For MES, 15000 should be changed to 1500
- if UsePositionSizing=1 then ncons=.33*round(NetEquity/15000,0)+1;
- if ncons>15 then ncons=15;
- SellShort ncons contracts next bar at market;
- end;
- //exits
- if MarketPosition = 1 and KeltnerStochastic > Threshold then
- Sell next bar at Market;
- if MarketPosition = -1 and KeltnerStochastic < Threshold then
- BuyToCover next bar at market;
- //stoploss
- setstopcontract;
- If MarketPosition=-1 then SetStopLoss(1.0*AvgTrueRange(15)*BigPointValue);
- If MarketPosition=1 then SetStopLoss(4.0*AvgTrueRange(15)*BigPointValue);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement