标签:sse tst 内容 put 代码 while 交易 lsh time
以下内容为程序代码:1 
2 input:inb(20,1,500,1),outb(10,1,500,1),risk(2,0,10,0.1); 
3 //和风版海龟源码 
4 variable:times=0,i=0,n=0; 
5 rn:=ema(ref(tr,1),20); 
6 n:=valuewhen(holding=0,rn); 
7 rh:=ref(h,1); 
8 rl:=ref(l,1); 
9 h1:hhv(rh,inb); 
10 h2:hhv(rh,outb),linedot; 
11 l1:llv(rl,inb); 
12 l2:llv(rl,outb),linedot; 
13 lotst:assetrisk0.01/(n2multiplier),linethick0; 
14 lots:=if(risk=0,1,lotst); //如果risk取0,表示固定开1手 
15 tbc:=h<>l;//判断是否停板 
16 partline(holding>0,enterprice-2n); 
17 if barpos<inb+1 then exit; 
18 if holding=0 and tbc then //不是停板才可以交易 
19 begin 
20 if h>h1 then //开多 
21 begin 
22 buyp:=max(o,h1); 
23 buy(1,lots,limitr,buyp); 
24 times:=1; 
25 while h>enterprice+n0.5 and times<4 do 
26 begin 
27 buyp:=max(o,enterprice+n0.5); 
28 buy(1,lots,limitr,buyp); 
29 times:=times+1; 
30 end;//连续开仓 
31 end;//开多结束 
32 else if l<l1 then //开空 
33 begin 
34 sellp:=min(o,l1); 
35 buyshort(1,lots,limitr,sellp); 
36 times:=1; 
37 while l<enterprice-n0.5 and times<4 do 
38 begin 
39 sellp:=min(o,enterprice-n0.5); 
40 buyshort(1,lots,limitr,sellp); 
41 times:=times+1; 
42 end;//连续开仓 
43 end; 
44 end;//holding=0 
45 
46 if holding>0 and tbc then //已有多仓 
47 begin 
48 exitlongp:=max(enterprice-2n,l2); 
49 if l<exitlongp and enterbars<>0 then //出场 
50 begin 
51 exitp:=min(o,exitlongp); 
52 sell(1,0,limitr,exitp); 
53 times:=0; 
54 end;//出场 
55 else 
56 begin 
57 while h>enterprice+n0.5 and times<4 do //开多 
58 begin 
59 buyp:=max(o,enterprice+n0.5); 
60 buy(1,lots,limitr,buyp); 
61 times:=times+1; 
62 end;//连续开仓 
63 end;//else 
64 
65 
66 end;//holding>0 
67 
68 if holding<0 and tbc then //已有空仓 
69 begin 
70 exitlongp:=min(enterprice+2n,h2); 
71 if h>exitlongp and enterbars<>0 then //出场 
72 begin 
73 exitp:=max(o,exitlongp); 
74 sellshort(1,0,limitr,exitp); 
75 times:=0; 
76 end;//出场 
77 else 
78 begin 
79 while l<enterprice-n0.5 and times<4 do //开多 
80 begin 
81 sellp:=min(o,enterprice-n*0.5); 
82 buyshort(1,lots,limitr,sellp); 
83 times:=times+1; 
84 end;//连续开仓 
85 end;//else 
86 end;//holding<0 
标签:sse tst 内容 put 代码 while 交易 lsh time
原文地址:https://blog.51cto.com/14661216/2473974