日内MACD模型,当今日macd第一次金叉时买入,死叉时卖出,止损10点,止损的同时反手。反手后止损依然是10点,连续止损3次的话就不反手了。等下一次macd金叉或死再入场,同样止损10点,止损后反手,反手次数为3次。收盘前平仓。
谢谢老师,帮我写一下!!!
处理中,请稍等
DIFF := EMA(CLOSE,12) - EMA(CLOSE,26);
DEA := EMA(DIFF,9);
MACD1 := 2*(DIFF-DEA);
variable:a=0,b=0;
if cross(diff,dea) then begin
buy(holding=0,1,market);
ENd
if cross(dea,diff) then BEGIN
buyshort(holding=0,1,market);
end
if enterprice-c>10*mindiff and holding>0 and a<3 then BEGIN
sell(holding>0,0,market);
buyshort(holding=0,1,market);
a:=a+1;
end
if c-enterprice>10*mindiff and holding<0 and a<3 then BEGIN
sellshort(holding<0,0,market);
buy(holding=0,1,market);
a:=a+1;
end
if a=3 and enterprice-c>10*mindiff and holding>0 then begin
sell(holding>0,0,market);
a:=0;
end
if a=3 and c-enterprice>10*mindiff and holding<0 then begin
sellshort(holding<0,0,market);
a:=0;
end
if time>145800 and time<=150000 then BEGIN
sell(1,0,market);
sellshort(1,0,market);
a:=0;
end
老师,止损改为20点的浮动止损。上面这个模型要怎么写呢?