Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共6 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[原创]后台策略自动撤单与条件追单模板

1楼
z7c9 发表于:2011/1/9 11:36:47

阅读版:

以下内容为程序代码:

1 myaccount:='666666';
2 sleeptime:=1000*3;
3
4 if tbuyholdingex(myaccount,stklabel,0)=0 then begin
5     if true then begin
6         tbuy(1,1,lmt,close,0,myaccount,stklabel),allowrepeat;
7         sleep(sleeptime);
8         if tisremainex(1,myaccount,stklabel) then begin
9             tcancelex(1,1,myaccount,stklabel);
10             exit;
11         end
12     end
13 end
14
15 if tsellholdingex(myaccount,stklabel,0)=0 then begin
16     if true then begin
17         tbuyshort(1,1,lmt,close,0,myaccount,stklabel),allowrepeat;
18         sleep(sleeptime);
19         if tisremainex(3,myaccount,stklabel) then begin
20             tcancelex(1,3,myaccount,stklabel);
21             exit;
22         end
23     end
24 end
25
26 if tbuyholdingex(myaccount,stklabel,0)>0 then begin
27     if true then begin
28         tsell(1,tbuyholdingex(myaccount,stklabel,0),close,0,myaccount,stklabel),allowrepeat;
29         sleep(sleeptime);
30         if tisremainex(2,myaccount,stklabel) then begin
31             tcancelex(1,2,myaccount,stklabel);
32             exit;
33         end
34     end
35 end
36
37 if tsellholdingex(myaccount,stklabel,0)>0 then begin
38     if true then begin
39         tsellshort(1,tsellholdingex(myaccount,stklabel,0),close,0,myaccount,stklabel),allowrepeat;
40         sleep(sleeptime);
41         if tisremainex(4,myaccount,stklabel) then begin
42             tcancelex(1,4,myaccount,stklabel);
43             exit;
44         end
45     end
46 end
47

 

拷贝版:

myaccount:='666666';
sleeptime:=1000*3;

if tbuyholdingex(myaccount,stklabel,0)=0 then begin
if true then begin
tbuy(1,1,lmt,close,0,myaccount,stklabel),allowrepeat;
sleep(sleeptime);
if tisremainex(1,myaccount,stklabel) then begin
tcancelex(1,1,myaccount,stklabel);
exit;
end
end
end

if tsellholdingex(myaccount,stklabel,0)=0 then begin
if true then begin
tbuyshort(1,1,lmt,close,0,myaccount,stklabel),allowrepeat;
sleep(sleeptime);
if tisremainex(3,myaccount,stklabel) then begin
tcancelex(1,3,myaccount,stklabel);
exit;
end
end
end

if tbuyholdingex(myaccount,stklabel,0)>0 then begin
if true then begin
tsell(1,tbuyholdingex(myaccount,stklabel,0),close,0,myaccount,stklabel),allowrepeat;
sleep(sleeptime);
if tisremainex(2,myaccount,stklabel) then begin
tcancelex(1,2,myaccount,stklabel);
exit;
end
end
end

if tsellholdingex(myaccount,stklabel,0)>0 then begin
if true then begin
tsellshort(1,tsellholdingex(myaccount,stklabel,0),close,0,myaccount,stklabel),allowrepeat;
sleep(sleeptime);
if tisremainex(4,myaccount,stklabel) then begin
tcancelex(1,4,myaccount,stklabel);
exit;
end
end
end

[此贴子已经被作者于2011-1-9 12:00:55编辑过]
2楼
admin 发表于:2011/1/9 11:46:19
楼主可否将使用方法和原理介绍一下
3楼
z7c9 发表于:2011/1/9 11:58:12
以下是引用admin在2011-1-9 11:46:19的发言:
楼主可否将使用方法和原理介绍一下

下单后,睡眠3秒钟,然后判断是否存在未成交委托单,如果存在,撤销未成交委托单并退出。如果不存在,继续向下执行。退出后再次进入时,如果下单条件成立,重新下单。

 

这种追单是条件追单,也就是说只要下单条件成立,就会不断的追单。

[此贴子已经被作者于2011-1-9 11:59:38编辑过]
4楼
msedu 发表于:2011/1/9 13:11:29
多用注释啊,写代码要让人看得懂,也要让自己时隔一段时间后还能了解清楚自己当时的思路,而且写注释本身也是整理自己的思维和理念啊。。。
5楼
guotx2010 发表于:2011/1/9 18:37:43
值得学习一下
6楼
szstock2002 发表于:2011/1/11 18:35:43
学习了!
共6 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.02344 s, 3 queries.