-- 作者:gsqh_zyp
-- 发布时间:2014/1/10 16:32:34
--
//参数设置: INPUT:M(26,5,300,30),N(2,0.1,10,1),S(9,2,60,6),P(14,1,100,1);
RUNMODE:0;
mid : ma(close,M); upper := mid + N*STD(close,M); lower := mid - N*STD(close,M);
//平多开空 if close<mid then begin sell(holding>0,0,limitr,close); buyshort(holding=0,1,limitr,close); end
//平空开多 if close>mid then begin sellshort(holding<0,0,limitr,close); buy(holding=0,1,limitr,close); end
//移动止赢,出现最高赢利后,回落到赢利的70%平仓出场
en:=enterbars;//开仓以来的周期数 enlv:=llv(l,en+1);//开仓以来的最低值 enhv:=hhv(h,en+1);//开仓以来的最高值
//初始化变量,持仓状态下的最大赢利 win:=0;//最大获利 win2:=0;//最大获利幅度 win3:=0;//最大获利后的最大回调幅度
if holding>0 and enterbars>0 then begin win:=enhv-enterprice; win2:=(enhv-enterprice)/enterprice*100; win3:=(enhv-c)/win*100; end
if holding<0 and enterbars>0 then begin win:=enterprice-enlv; win2:=(enterprice-enlv)/enterprice*100; win3:=(c-enlv)/win*100; end
//出现最高赢利后,获利在300点以上,按回撤70%止赢 if win>300 and win3>=30 then begin 多头止赢:sell(openprofit>0 and holding>0,0,limitr, close); buyshort(1,1,limitr,close); end
if win>300 and win3>=30 then begin 空头止赢:sellshort(openprofit>0 and holding<0,0,limitr, close); buy(1,1,limitr,close); end
//账户信息: 资产:ASSET,PRECISION0,NOAXIS,COLORFF00FF; 可用现金:CASH(0),PRECISION0,NOAXIS,LINETHICK0; 持仓:HOLDING,LINETHICK0; 胜率:PERCENTWIN,LINETHICK0; 交易次数:TOTALTRADE,LINETHICK0;
这个是代码,麻烦老师帮忙看看,不太明白开平那个顺序的机制
|
-- 作者:jinzhe
-- 发布时间:2014/1/13 14:17:49
--
希望开仓后过个一根k线再出信号?要这样改
INPUT:M(26,5,300,30),N(2,0.1,10,1),S(9,2,60,6),P(14,1,100,1);
RUNMODE:0;
mid : ma(close,M); upper := mid + N*STD(close,M); lower := mid - N*STD(close,M);
variable:kk=0; //平多开空
if close<mid and kk=0 then begin
buyshort(holding=0,1,limitr,c);
kk:=1;
end
if close>mid and kk=0 then begin
buy(holding=0,1,limitr,close);
kk:=1;
end
if close<mid and kk=1 and enterbars>1 then begin sell(holding>0,0,limitr,close); buyshort(holding=0,1,limitr,close); end
//平空开多 if close>mid and kk=1 and enterbars>1 then begin sellshort(holding<0,0,limitr,close); buy(holding=0,1,limitr,close); end
//移动止赢,出现最高赢利后,回落到赢利的70%平仓出场
en:=enterbars;//开仓以来的周期数 enlv:=llv(l,en+1);//开仓以来的最低值 enhv:=hhv(h,en+1);//开仓以来的最高值
//初始化变量,持仓状态下的最大赢利 win:=0;//最大获利 win2:=0;//最大获利幅度 win3:=0;//最大获利后的最大回调幅度
if holding>0 and enterbars>0 then begin win:=enhv-enterprice; win2:=(enhv-enterprice)/enterprice*100; win3:=(enhv-c)/win*100; end
if holding<0 and enterbars>0 then begin win:=enterprice-enlv; win2:=(enterprice-enlv)/enterprice*100; win3:=(c-enlv)/win*100; end
//出现最高赢利后,获利在300点以上,按回撤70%止赢 if win>300 and win3>=30 then begin 多头止赢:sell(openprofit>0 and holding>0,0,limitr, close); buyshort(1,1,limitr,close); end
if win>300 and win3>=30 then begin 空头止赢:sellshort(openprofit>0 and holding<0,0,limitr, close); buy(1,1,limitr,close); end
//账户信息: 资产:ASSET,PRECISION0,NOAXIS,COLORFF00FF; 可用现金:CASH(0),PRECISION0,NOAXIS,LINETHICK0; 持仓:HOLDING,LINETHICK0; 胜率:PERCENTWIN,LINETHICK0; 交易次数:TOTALTRADE,LINETHICK0;
|