-- 作者:pyd
-- 发布时间:2015/5/13 13:17:48
--
VARIABLE:x=0,y=0; MID : MA(CLOSE,26); UPPER: MID + 2*STD(CLOSE,26); LOWER: MID - 2*STD(CLOSE,26);
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100; K:SMA(RSV,3,1); D:SMA(K,3,1);
sc:cross(d,k); jc:cross(k,d); n1:barslast(h>upper)+1; n2:barslast(l<lower); hh:hhv(h,enterbars+1); ll:llv(l,enterprice+1);
if n1<=n and sc=1 then begin sell(holding>0,holding,market); buy(holding=0,1,market); end
if n2<=n and jc=1 then begin sellshort(holding<0,holding,market); buy(holding=0,1,market); end //止损 if h-enterprice>=50 then sell(holding>0,holding,market); if enterprice-l>=50 then sellshort(holding<0,holding,market); //盈利80点后设30点保本。 if hh-enterprice>=80 then x:=1; if x=1 and hh-l>=50 then begin sell(holding>0,holding,market); x:=0; end if enterprice-ll>=80 then y:=1; if y=1 and h-ll>=50 then begin sellshort(holding<0,holding,market); y:=1; end
|
-- 作者:muxia5568
-- 发布时间:2015/5/13 15:05:36
--
请教老师;模型中标红的n是不是我的开仓条件中的n?;(1,从距离当前K线最近的那根大于布林带上轨的K线开始计算(包括那根K线)在N根K线内出现KD死叉。平多开空;)
sc:cross(d,k); jc:cross(k,d);
n1:barslast(h>upper)+1; n2:barslast(l<lower); hh:hhv(h,enterbars+1); ll:llv(l,enterprice+1);
if n1<=n and sc=1 then begin sell(holding>0,holding,market); buy(holding=0,1,market); end
if n2<=n and jc=1 then begin sellshort(holding<0,holding,market); buy(holding=0,1,market); end
|