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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [原创]提前N秒下单的方法,适用于各个周期

   

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


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

主题:[原创]提前N秒下单的方法,适用于各个周期

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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
[原创]提前N秒下单的方法,适用于各个周期  发帖心情 Post By:2011/11/17 10:55:20    Post IP:120.42.45.130[显示全部帖子]

老是有人希望提前N秒下单

在此提供一种自己编写的方法

适用于各个周期,注意:选用固定时间间隔模式

2011-12-26 做了更新,给出了不规律周期的K线结束时间

 

//这里以股指期货为例,商品原理类似:关键是找出K线结束的时间规律。

ma5:=ma(c,5);
ma10:=ma(c,10);
zq:=2;//周期类型,2分钟就填2,3分钟就填3 ,5分钟就填5
tq:=5;//提前的秒数,最多提前60秒
lastopentm:=if(date<>ref(date,1),0,ref(openminutes(time),1));//上一根K线的开盘分钟数
ticktm:=dynainfo(207);
abb:=(mod(ticktm,100)>=60-tq and (openminutes(ticktm)-lastopentm=zq-1 or (ticktm>=112900 and ticktm<=113000) or (ticktm>=151400 and ticktm<=151500))) or not(islastbar);

if abb then begin
  if holding>0 and ma5<ma10 then sell(1,1,thisclose);
  if holding<0 and ma5>ma10 then sellshort(1,1,thisclose);
  if holding=0 and ma5>ma10 then buy(1,1,thisclose);
  if holding=0 and ma5<ma10 then buyshort(1,1,thisclose);

end

 

大家注意了

2.80版本以上,time这个函数有所变化,直接可以直接获得K线结束的时间。提前下单更加方便了

ma5:=ma(c,5);
ma10:=ma(c,10);
input:tq(5,3,60,1);
abb:=(time0-timetot0(dynainfo(207))<=tq) or not(islastbar);

if abb then begin
  if holding>0 and ma5<ma10 then sell(1,1,thisclose);
  if holding<0 and ma5>ma10 then sellshort(1,1,thisclose);
  if holding=0 and ma5>ma10 then buy(1,1,thisclose);
  if holding=0 and ma5<ma10 then buyshort(1,1,thisclose);

end

[此贴子已经被作者于2012-2-9 10:20:04编辑过]

[本帖被加为精华]
 回到顶部
帅哥哟,离线,有人找我吗?
阿火
  2楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/11/17 11:18:17    Post IP:120.42.45.130[显示全部帖子]

time=113000 or time=151500 ,不同的品种收盘时间,这里自己要改一改。

还有商品在101500有休盘,这里的K线结束时间,也根据自己的周期相应修改

 

原理也很简单:就是找出每根K线结束的时间点,然后用currenttime或者dynainfo(207)去控制下单时机 

[此贴子已经被作者于2011-11-17 11:26:19编辑过]

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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/11/18 14:40:40    Post IP:120.42.45.130[显示全部帖子]

以下是引用tmxker在2011-11-17 13:48:28的发言:
 问题,我修改使用5分钟周期,每个5分钟K线都在下单,提前的时间限制1015、1130、1500不起作用。亲火哥亲自调试一下。

 

这就是你模型问题了。

一般下单只会在 holding变化时才下单,比如:由holding=0变化为holding=1 开多单

 

其它不规则的周期可能比较麻烦,但5分钟周期很有规律,不会有问题的


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/11/20 2:22:06    Post IP:121.204.187.151[显示全部帖子]

对于商品,60分钟K线结束的位置是以下几个 10:00  11:00  14:00 15:00

用一下即可:

ma5:=ma(c,5);

ma10:=ma(c,10);

abb:=(mod(dynainfo(207),100)>55 and islastbar and (time=100000 or time=110000 or time=140000 or time=150000)) or not(islastbar);

if holding>0 and ma5<ma10 and abb then sell(1,1,thisclose);

if holding<0 and ma5>ma10 and abb then sellshort(1,1,thisclose);

if holding=0 and ma5>ma10 and abb then buy(1,1,thisclose);

if holding=0 and ma5<ma10 and abb then buyshort(1,1,thisclose);


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/11/20 10:21:55    Post IP:121.204.187.151[显示全部帖子]

旧图标原理一样

exitlong:ma5<ma10 and abb,tfilter;

enterlong:ma5>ma10 and abb,tfilter;


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/11/29 22:14:12    Post IP:121.204.190.73[显示全部帖子]

以下是引用celuezuhe在2011-11-29 19:15:41的发言:

时间周期:=5;//交易运行于几分钟时间周期
提前秒数:=2;//提前几秒
tqsj:=59-提前秒数;
zq:=时间周期;

abb:=(mod(currenttime,100)>tqsj and islastbar and (mod(openminutes(time),zq)=0 or time=113000 or time=151500)) or not(islastbar);

 

修改了一下 以后要运行什么时间框架,要提前几秒,只要在开头改一下就可以,方便在各个系统之间进行标准化移植。

 

另外 括号中是否应该改为openminutes而不是opentimes??

 

嗯,细心啊。已改!~~


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/11/29 22:15:30    Post IP:121.204.190.73[显示全部帖子]

各种周期之间要标准移植还是不容易

有些周期不规则。或者 早上有休盘时间

 


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/12/1 11:03:04    Post IP:120.42.45.130[显示全部帖子]

095800 又不是100000 的最后提前秒数

各个周期都可以的。原理是 找出每根K线结束是的time

如果K线结束时间,openminutes(time)不是60的整数倍,那就要调整一下


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2011/12/21 16:33:26    Post IP:120.42.72.167[显示全部帖子]

不要埋头苦改

理解了原理之后,再改才不容易出错


 回到顶部