
以下内容为程序代码:
1 runmode:0;
2
3 input:n1(8,1,100,1);
4 input:n2(22,1,100,1);
5 input:n3(44,1,100,1);
6 input:n4(5,1,100,1);
7
8 ma1:=ma(close,n4);
9
10 zhx:=(hhv(high,n1)+llv(low,n1))/2;
11 jzx:=(hhv(high,n2)+llv(low,n2))/2;
12 yda:=ref((zhx+jzx)/2,n2);
13 ydb:=ref((hhv(high,n3)+llv(low,n3))/2,n2);
14
15 if holding=0 then begin
16 if cross(zhx,jzx) then
17 buy(1,1,limitr,close);
18 end
19
20 if holding=0 then begin
21 if cross(jzx,zhx) then
22 buyshort(1,1,limitr,close);
23 end
24
25 if holding>0 then begin
26 if cross(jzx,zhx) then begin
27 sell(1,holding,limitr,close),orderqueue;
28 buyshort(1,1,limitr,close),orderqueue;
29 end
30 end
31
32 if holding<0 then begin
33 if cross(zhx,jzx) then begin
34 sellshort(1,holding,limitr,close),orderqueue;
35 buy(1,1,limitr,close),orderqueue;
36 end
37 end
38
39 资产:asset,noaxis,colormagenta;
40 次数:totaltrade,linethick0;
41 收益:(asset-40000)/40000,linethick0;
42 胜率:percentwin,linethick0;
43 出击:totaltrade/(count(date<>ref(date,1),0)+1),linethick0;
44 连亏:maxseqloss,linethick0;
45 连赢:maxseqwin,linethick0;
46
[此贴子已经被作者于2011-10-3 11:30:29编辑过]
15行提示 cross 函数在逐k线模式下不能直接在if控制语句之内引用。
请斑竹看看如何解决。
以下是引用kk031007在2012-9-2 22:44:49的发言:
15行提示 cross 函数在逐k线模式下不能直接在if控制语句之内引用。
请斑竹看看如何解决。
把cross分解为后大于与前小于。