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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 日内满仓交易时,平仓反手的实现方法

   

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


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

主题:日内满仓交易时,平仓反手的实现方法

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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
日内满仓交易时,平仓反手的实现方法  发帖心情 Post By:2011/7/13 22:43:44    Post IP:120.42.45.130[显示全部帖子]

日内满仓交易时,平仓反手的时候,有个问题要特别注意,就是在平仓单未成交前如果发出开仓委托单会出现保证金不足的情况造成无法自动开仓

这个问题是众所周知的

 

1,一般的处理方法是在每个下单指令的最后面加一个顺序下单控制符,如下:

hi:=ref(hhv(h,20),1);
lo:=ref(llv(l,20),1);
entertime:=time<=144500;
exittime:=time>=145700;
buycond:=c>hi;
sellcond:=c<lo;
if holding>0 and (sellcond or exittime) then sell(1,1,market),orderqueue;
if holding<0 and (buycond or exittime) then sellshort(1,1,market),orderqueue;
if holding=0 and entertime and buycond then buy(1,1,market),orderqueue;
if holding=0 and entertime and sellcond then buyshort(1,1,market),orderqueue;

 

这种方法基本上可以解决问题。orderqueue顺序下单的意思是委托单按先后顺序排队等待,依次处理

但也有不足的地方,就是在平仓单未及时成交时,依然会出现保证金不足的错误。如 A(平多)、B(开空),A未及时成交自动撤单后追单

自动追单的委托就排在后面了,也就是下单顺序就为 B、A 。B发送时就会提示错误,因为保证金并未释放。

 

2,现提出另一处理方法

问题的关键,就是要等平仓单完全成交后再发开仓单,这样才能避免出现保证金不足的情况

反手模型有个特点,就是平仓单成交后,仓位为0,而后台的tholding2这个函数就是表示实际持仓

于是:

hi:=ref(hhv(h,20),1);
lo:=ref(llv(l,20),1);
entertime:=time<=144500;
exittime:=time>=145700;
buycond:=ref(c>hi,1);
sellcond:=ref(c<lo,1);
abb:=not(islastbar) or (islastbar and tholding2=0);//这里要这样处理,否则tholding2会影响前面得信号
if holding>0 and (sellcond or exittime) then sell(1,1,market);
if holding<0 and (buycond or exittime) then sellshort(1,1,market);
if holding=0 and entertime and buycond and abb then buy(1,1,market);
if holding=0 and entertime and sellcond and abb then buyshort(1,1,market);

程序执行过程:1,平仓单发出后,不发开仓单,因为tholding2不为0.如果平仓单没及时成交,自动撤单后追单直至成交 

                    2,平仓单成交后,tholding2=0,此时开仓指令条件成立,发出开仓单。不会出现保证金不足的情况

                    3,注意,用的是tholding2,而非tholding,tholding会受未成交委托单影响。

以上适用的条件 :1,需要平仓委托在信号成立的K线内成交,才能发出开仓委托。模型基本符合这个条件

                        2,固定时间间隔或者高频。如果是K线走完模式,还需稍作修改为固定时间间隔模式

[此贴子已经被作者于2011-7-14 9:58:39编辑过]

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


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

以上适用的条件 :1,需要平仓委托在信号成立的K线内成交,才能发出开仓委托。

 

风险我们自然要考虑,但也不能太钻牛角尖。

比如:多单一成交,突然跳水跌停,空单一成交拉升涨停。这种可能性也是有的

你要是天天想着这种风险,保证你一单都不敢下单,何谈做期货。回家抱老婆实在


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
如何通过金字塔 在宽带不正常时切换到无线网络  发帖心情 Post By:2011/7/14 21:22:27    Post IP:121.207.189.198[显示全部帖子]

尽管用。不用理会提示。


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


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

日内满仓反手 升级版

 

//使用环境逐K线模式,固定时间轮询
variable:cc=0;
runmode:0;
entertime:=time<closetime(0) and time>opentime(1)+100;
exittime:=time>=closetime(0);
buycond:=ref(count(c>o,2)=2,1);
sellcond:=ref(count(c<o,2)=2,1);
acc:=not(islastbar);
if holding>0 and (sellcond or exittime) then begin
 sell(1,5,limitr,o);
 cc:=0;
end

if holding<0 and (buycond or exittime) then begin
 sellshort(1,5,limitr,o);
 cc:=0;
end

if holding=0 and entertime and buycond then begin
 buy(acc or tbuyholding(1)>0,5,limitr,o);
 if islastbar then extgbdataset('isbook',0);
 cc:=5;
end

if holding=0 and entertime and sellcond then begin
 buyshort(acc or tsellholding(1)>0,5,limitr,o);
 if islastbar then extgbdataset('isbook',0);
 cc:=-5;
end

if not(islastbar and workmode=3) then exit;

if tholding2=0 and cc>0 and extgbdata('isbook')=0 then begin
 buy(1,5,limitr,o);
 extgbdataset('isbook',1);
end

if tholding2=0 and cc<0 and extgbdata('isbook')=0 then begin
 buyshort(1,5,limitr,o);
 extgbdataset('isbook',1);
end

[此贴子已经被作者于2011-9-8 8:28:48编辑过]

 回到顶部