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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → 和风版海龟源码 支持多空

   

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


  共有38253人关注过本帖树形打印复制链接

主题:和风版海龟源码 支持多空

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


加好友 发短信
等级:新手上路 帖子:37 积分:189 威望:0 精华:0 注册:2010/12/24 12:56:02
和风版海龟源码 支持多空  发帖心情 Post By:2011/6/8 20:52:25 [显示全部帖子]

支持多空双向开仓,到价开仓(非收盘开仓)

 


 回到顶部
帅哥哟,离线,有人找我吗?
jim5jim
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:37 积分:189 威望:0 精华:0 注册:2010/12/24 12:56:02
  发帖心情 Post By:2011/6/8 20:53:35 [显示全部帖子]

以下内容为程序代码:

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:asset*risk*0.01/(n*2*multiplier),linethick0;
14 lots:=if(risk=0,1,lotst); //如果risk取0,表示固定开1手
15 tbc:=h<>l;//判断是否停板
16 partline(holding>0,enterprice-2*n);
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+n*0.5 and times<4 do
26 begin
27 buyp:=max(o,enterprice+n*0.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-n*0.5 and times<4 do
38 begin
39 sellp:=min(o,enterprice-n*0.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-2*n,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+n*0.5 and times<4 do //开多
58 begin
59 buyp:=max(o,enterprice+n*0.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+2*n,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-n*0.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
87
88
89

版主评定:好评,获得5个金币奖励好评,获得5个金币奖励
(理由:好文章)
 回到顶部