以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp) -- 公式模型编写问题提交 (http://222.73.7.161/bbs/list.asp?boardid=4) ---- 交易系统编译不通过怎么回事? (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=159431) |
-- 作者:tianjixuetu -- 发布时间:2017/11/12 14:01:49 -- 交易系统编译不通过怎么回事? 下面是交易系统,下面红色的一行代码出错,说后面没有分号,好奇怪。 VARIABLE:times:=0,p1:=0,p2:=0,p3:=0,p4:=0,p5:=0; INPUT:m(14,1,30,1); //cci指标 TYP := (HIGH + LOW + CLOSE)/3; cci:=(TYP-MA(TYP,M))/(0.015*AVEDEV(TYP,M)); //买入条件 lots:=cash(0)/(5-times); buy_con:=cross(cci,100); sell_con=cross(100,cci); sell_con1:=cross(100,cci) and c/ENTERPRICE>1.001; sell_con2:=cross(100,cci) and c/p1>1.001; sell_con3:=cross(100,cci) and times=5; if buy_con and times<=4 then begin BUY(1 ,lots,THISCLOSE); times:=times+1; if times=1 then begin p1:=close; end if times=2 then BEGIN p2:=p1; p1:=close; end if times=3 then begin p3:=p2; p2:=p1; p1:=close; end if times=4 then begin p4:=p3; p3:=p2; p2:=p1; p1:=close; end if times=5 then begin p5:=p4; p4:=p3; p3:=p2; p2:=p1; P1:=CLOSE; end end if sell_con and times>0 then begin if c>ENTERPRICE>1.001 then begin lots:=1/times sell(1,lots,THISCLOSE); times:=times-1; end if times=5 then begin sell(1,40%,THISCLOSE); times:=3; end if times>=2 and times<=4 then BEGIN if times=2 and c/p1>1.001 and c/p2>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end if times=3 and c/p1>1.001 and c/p2>1.001 and c/p3>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end if times=4 and c/p1>1.001 and c/p2>1.001 and c/p3>1.001 and c/p4>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end if times=5 and c/p1>1.001 and c/p2>1.001 and c/p3>1.001 and c/p4>1.001 and c/p5>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end end end |
-- 作者:pyd -- 发布时间:2017/11/12 18:41:20 -- sell_con后少了冒号,提示不准确,编译通不过时你可以分段编译 VARIABLE:times:=0,p1:=0,p2:=0,p3:=0,p4:=0,p5:=0; INPUT:m(14,1,30,1); //cci指标 TYP := (HIGH + LOW + CLOSE)/3; cci:=(TYP-MA(TYP,M))/(0.015*AVEDEV(TYP,M)); //买入条件 lots:=cash(0)/(5-times); buy_con:=cross(cci,100); sell_con:=cross(100,cci); sell_con1:=cross(100,cci) and c/ENTERPRICE>1.001; sell_con2:=cross(100,cci) and c/p1>1.001; sell_con3:=cross(100,cci) and times=5; if buy_con and times<=4 then begin BUY(1 ,lots,THISCLOSE); times:=times+1; if times=1 then begin p1:=close; end if times=2 then BEGIN p2:=p1; p1:=close; end if times=3 then begin p3:=p2; p2:=p1; p1:=close; end if times=4 then begin p4:=p3; p3:=p2; p2:=p1; p1:=close; end if times=5 then begin p5:=p4; p4:=p3; p3:=p2; p2:=p1; P1:=CLOSE; end end { if sell_con and times>0 then begin if c>ENTERPRICE>1.001 then begin lots:=1/times sell(1,lots,THISCLOSE); times:=times-1; end if times=5 then begin sell(1,40%,THISCLOSE); times:=3; end if times>=2 and times<=4 then BEGIN if times=2 and c/p1>1.001 and c/p2>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end if times=3 and c/p1>1.001 and c/p2>1.001 and c/p3>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end if times=4 and c/p1>1.001 and c/p2>1.001 and c/p3>1.001 and c/p4>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end if times=5 and c/p1>1.001 and c/p2>1.001 and c/p3>1.001 and c/p4>1.001 and c/p5>1.001 then BEGIN sell(1,100%,THISCLOSE); times:=0; end end end |
-- 作者:tianjixuetu -- 发布时间:2017/11/12 21:13:54 -- 谢谢,没搞明白怎么分段编译,后半段看着也没有啥错误啊 |
-- 作者:wenarm -- 发布时间:2017/11/13 8:34:13 -- 写代码,最好采用迭代的方式,由简到繁,从易到难。写一部分后就编译一下。而不是写完在编译,这种会对你调试增加难度
|
-- 作者:tianjixuetu -- 发布时间:2017/11/13 10:15:59 -- 请指点一下究竟哪里错了,该怎么改 |
-- 作者:FireScript -- 发布时间:2017/11/13 10:52:48 -- 代码行,第44行。 lots:=1/times
改下。
代码行,第9行。
sell_con=cross(100,cci);
改下,变量定义方式错误。 [此贴子已经被作者于2017/11/13 10:55:39编辑过]
|