欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 一个简单的系统 没有信号 请帮我修改一下

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有2185人关注过本帖平板打印复制链接

主题:一个简单的系统 没有信号 请帮我修改一下

帅哥哟,离线,有人找我吗?
seemsgood
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:168 积分:210 威望:0 精华:0 注册:2013/2/20 21:47:04
一个简单的系统 没有信号 请帮我修改一下  发帖心情 Post By:2014/8/23 9:10:27    Post IP:60.166.208.126[只看该作者]

参考系统自带的系统编了一个多头海龟系统 抱着学习测试的目的只写了多头的进场加仓离场和止损
代码

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;

运行在图标后 无信号 请问哪里有问题?


 回到顶部