Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 2,010
Thanks: 99 times Was thanked: 163 time(s) in 158 post(s)
|
Perry Kaufman’s article, “Gap Momentum,” introduced his new Gap Momentum Indicator and a trading system based on it. Below are the MetaStock formulas for the indicator and system test. The system test formulas could also be used in an expert advisor. Gap Momentum Indicator:
Code:mpds:= Input("Gap Momentum Periods", 2, 500, 40);
spda:= Input("Signal Line Periods", 2, 200, 20);
gap:= OPEN - Ref(CLOSE, -1);
upgap:= Sum( If( gap > 0, gap, 0), mpds);
dngap:= Sum( If( gap < 0, Neg(gap), 0), mpds);
denom:= If(dngap = 0, -1, dngap);
gapratio:= If(denom = -1, 1, 100 * (upgap / denom));
sig:= Mov(gapratio, spda, S);
gapratio;
sig
Gap Momentum System Test:
Buy Order:
Code:mpds:= 40;
spda:= 20;
gap:= OPEN - Ref(CLOSE, -1);
upgap:= Sum( If( gap > 0, gap, 0), mpds);
dngap:= Sum( If( gap < 0, Neg(gap), 0), mpds);
denom:= If(dngap = 0, -1, dngap);
gapratio:= If(denom = -1, 1, 100 * (upgap / denom));
sig:= Mov(gapratio, spda, S);
dir:= roc(sig, 1, $);
cross(dir, 0)
Sell Order:
Code:mpds:= 40;
spda:= 20;
gap:= OPEN - Ref(CLOSE, -1);
upgap:= Sum( If( gap > 0, gap, 0), mpds);
dngap:= Sum( If( gap < 0, Neg(gap), 0), mpds);
denom:= If(dngap = 0, -1, dngap);
gapratio:= If(denom = -1, 1, 100 * (upgap / denom));
sig:= Mov(gapratio, spda, S);
dir:= roc(sig, 1, $);
cross(0, dir)
|