以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 一个简单的系统 没有信号 请帮我修改一下 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=69151) |
-- 作者:seemsgood -- 发布时间:2014/8/23 9:10:27 -- 一个简单的系统 没有信号 请帮我修改一下 参考系统自带的系统编了一个多头海龟系统 抱着学习测试的目的只写了多头的进场加仓离场和止损 代码 runmode:0; input :duan(20,10,30,1); input:chang(55,40,70,1); //计算atr variable :atr=0; m:=ma(tr,20); if barpos>=20 then atr:=m;
else atr:=(19*atr+tr)/20; sysatr:ma(tr,20),linethick0; variable: shortlow=close;
//短期低点 variable: shorthigh=close; //短期高点 variable: longlow=close; //长期低点 variable: longhigh=close; //长期高点 shortlow:=llv(low,duan); shorthigh:=hhv(high,duan); longlow:=llv(low,chang); longhigh:=hhv(high,chang); day10low:=llv(low,10); day20low:=llv(low,20); day20high:=hhv(high,20); day10high:=hhv(high,10); variable: positionstatus=0; //初始化 if barpos=1 then begin end; //无持仓 if positionstatus=0 and barpos>chang then
begin
//多头进场条件
enterlongrule1:=h>shorthigh;
enterlongrule2:=h>longhigh;
if enterlongrule2 then
begin
unit:=(cash(0)*0.01)/atr;{一单位头寸规模}
myenterprice:=if(open>longhigh+mindiff,open,longhigh+mindiff);
buy(1,unit,limitr,myenterprice);
positionstatus:=1;{头寸为多头头寸}
longpositionunit:=1;{多头头寸单位累计1个}
end;
//空头进场条件
{entershortrule1:=l<shortlow;
entershortrule2:=l<longlow;
if entershortrule2 then
begin
unit:=(cash(0)*0.01)/atr;
short2:buyshort(1,unit,market);
positionstatus:=-1;
shortpositionunit:=1;
end;}
end; //持有多头仓位 if positionstatus>0 then
begin
//多头加仓
if (high>myenterprice+0.5*atr) && (longpositionunit<4) then
begin
unit:=(cash(0)*0.01)/atr;{一单位头寸规模}
myenterprice:=myenterprice+0.5*atr;
myenterprice:= ceiling(myenterprice/mindiff)*mindiff;
buy(1, unit, limitr, myenterprice);
longpositionunit := longpositionunit+1 ;
end;
//多头离场
exitlongrule1:=low<day10low;
exitlongrule2:=low<day20low;
if exitlongrule1 then
begin
sell(1,0,market);
positionstatus:=0;
longpositionunit:=0;
end;
//多头止损
longstopcond:=low<myenterprice-2*atr;
if longstopcond and positionstatus>0 then
begin
sell(1,0,market);
positionstatus:=0;
longpositionunit:=0;
end;
end; //持有空头仓位 if positionstatus<0 then
begin
//空头加仓
//空头离场
//空头止损
end; 资产:asset,linethick0; 可用现金:cash(0),linethick0; pos:holding,linethick0; 交易次数:totaldaytrade, linethick0 ; 当前持仓:holding,colorgray,linethick0; 当前资产:asset,noaxis,colorgray; 运行在图标后 无信号 请问哪里有问题? |
-- 作者:jinzhe -- 发布时间:2014/8/25 8:59:11 -- 没有开仓信号是因为下单条件不成立, |