源码:
DIFF := EMA(CLOSE,S) - EMA(CLOSE,P);
DEA := EMA(DIFF,M);
MACD := 2*(DIFF-DEA);
MA1 := ema(close,N);
MACD5 := REF(MACD,5);
long:= close>MA1 and MACD>0 and MACD5<0 ;
if long then
begin
if not (HOLDING > 0) then
buy(1,1,thisclose);
end;
if MA1> close +20*mindiff THEN
BEGIN
BUYSHORT(holding>0,holding,thisclose);
END
---------------------------------------------------------------------------
大概 思路就是
当K线穿越移动平均线,macd从下方向上穿越0轴的时候,做多。
当 K线向下穿越移动平均线+20点时,平仓。
一个很简单的策略模型,可是为什么测试的时候只做了一个单子,且一直没有平仓.
求解答,
个人认为 是 最后几行的平仓策略写错了,请教。
是的,有错误
BUYSHORT(holding>0,holding,thisclose);-----改为SELL
if long and holding=0 then
begin
buy(1,1,thisclose);
end;