-- 作者:COMBOY
-- 发布时间:2015/7/23 9:53:55
-- 大佬帮我
大佬帮我,思路是设置一条均线,触及均线开仓,n个点即止盈或止损,采用固定轮询模式,下面的如何优化?如何最大限度减少滑点?
input:n(10,1,100,1);//盈利止损点数 input:m(2,2,60,1);//均线周期
ma5:ma(close,m); if cross(c,ma5) and time>091500 and time<151300 and holding=0 then buy(1,1,limitr,ma5),IGNORECHECKPRICE; if cross(ma5,c) and time>091500 and time<151300 and holding=0 then buyshort(1,1,limitr,ma5),IGNORECHECKPRICE; if holding<0 and enterprice-l>=mindiff*n then sellshort(1,1,limitr,enterprice-mindiff*n),IGNORECHECKPRICE; if holding>0 and enterprice-h<=mindiff*n then sell(1,1,limitr,enterprice+mindiff*n),IGNORECHECKPRICE ;
//止损模块 多头损失点数:=c-enterprice; 空头损失点数:=enterprice-c; if 空头损失点数<0 and abs(空头损失点数)>2*mindiff*n and holding<0 and enterbars>1 then 空头止损:sellshort(1,0,marketr),IGNORECHECKPRICE; if 多头损失点数<0 and abs(多头损失点数)>2*mindiff*n and holding>0 and enterbars>1 then 多头止损:sell(1,0,marketr),IGNORECHECKPRICE; 止损点数:abs(多头损失点数);
//收盘前清仓 if time>=151400 then begin sellshort(holding<0,0,thisclose); sell(holding>0,0,thisclose); end
持仓:holding,linethick0; 资产:asset,noaxis,linethick2,coloryellow; 可用现金:cash(0),linethick0;
[此贴子已经被作者于2015/7/23 9:55:16编辑过]
|
-- 作者:COMBOY
-- 发布时间:2015/7/23 9:57:41
--
这样是否可以?
input:n(7,1,100,1);//盈利止损点数 input:m(2,2,60,1);//均线周期
ma5:ma(close,m);
variable:n1=0; variable:n2=0;
if cross(c,ma5) and time>091500 and time<151300 and holding=0 then begin buy(n1=0,1,limitr,ma5),IGNORECHECKPRICE; n1=1; end if cross(ma5,c) and time>091500 and time<151300 and holding=0 then begin buyshort(n2=0,1,limitr,ma5),IGNORECHECKPRICE; n2=1; end
if holding<0 and enterprice-l>=mindiff*n then sellshort(1,1,limitr,enterprice-mindiff*n),IGNORECHECKPRICE; if holding>0 and enterprice-h<=mindiff*n then sell(1,1,limitr,enterprice+mindiff*n),IGNORECHECKPRICE ;
if minute<>ref(minute,1) then begin n1:=0; n2:=0;
end
//止损模块 多头损失点数:=c-enterprice; 空头损失点数:=enterprice-c; if 空头损失点数<0 and abs(空头损失点数)>mindiff*n and holding<0 and enterbars>1 then 空头止损:sellshort(1,0,marketr),IGNORECHECKPRICE; if 多头损失点数<0 and abs(多头损失点数)>mindiff*n and holding>0 and enterbars>1 then 多头止损:sell(1,0,marketr),IGNORECHECKPRICE; 止损点数:abs(多头损失点数);
//收盘前清仓 if time>=151400 then begin sellshort(holding<0,0,thisclose); sell(holding>0,0,thisclose); end
持仓:holding,linethick0; 资产:asset,noaxis,linethick2,coloryellow; 可用现金:cash(0),linethick0;
|