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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [原创]多策略多账户下单阿火版_续集(可扩展成无人值守)

   

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


  共有9955人关注过本帖平板打印复制链接

主题:[原创]多策略多账户下单阿火版_续集(可扩展成无人值守)

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


加好友 发短信
等级:论坛游侠 帖子:252 积分:1001 威望:0 精华:0 注册:2010/2/15 16:47:58
[公告]上海中期北京营业部与金字塔合作  发帖心情 Post By:2011/8/16 23:29:52    Post IP:121.195.55.179[只看该作者]

[原创]多策略多账户下单阿火版_续集(可扩展成无人值守)  图片点击可在新窗口打开查看 Post By:2011-8-5 10:13:01

上次发表了一个 多策略多账户的下单方法

大家知道,一根K线图一个方向只允许下单一次,如果一个K线图内,不同策略前后分别产生信号呢?

举个例子:

//策略1:连续2阳,下一根开盘买入 2阴下一根开盘卖出
//策略2:价格突破前1根高点即买入,前1根低点立即卖出

假如以上2个策略组合,连续2个阳线条件成立,新的K线产生时开盘买入1手,之后又突破前一根K线高点,需再买1手。

 

这个时候,如何组合起来?用allowrepeat,允许重复下单。

 

主要问题:

1,下单后,委托单产生前,有一个小时间差的控制。tolding=0则下单。下单后,tholding依然为0,还会再下单

     因为我们采用的是加减仓的组合手法,信号并非前后分别对应,无法用ttype

     举个例子解释一下加减仓手法的特点:一开始A模型多单3手,B模型出现信号“空2手”。表现在操作上就是:平仓2手。
                                                    之后B模型出现信号“空单平仓2手”,操作上表现就是 买入开仓2手。

 

2,下单瞬间,网络刚好中断。后面网络恢复,也要自动补回正确的持仓。

3,不管什么原因造成的重复下单(比如堵单,以为没成交再次发单成交,之后发现这个堵单也成交了),希望补回正确持仓

 

解决方法如下:

variable:cc1=0,cc2=0,cc3=0;
entertime:=time<150000;
exittime:=time>=150000;
buycond1:=ref(c,1)>ref(o,1) and ref(c,2)>ref(o,2);
sellcond1:=ref(c,1)<ref(o,1) and ref(c,2)<ref(o,2);

buycond2:=h>ref(hhv(h,1),1);
sellcond2:=l<ref(llv(l,1),1);

buycond3:=ref(c>o,1);
sellcond3:=ref(c<o,1);

if cc1>0 and (sellcond1 or exittime) then cc1:=0;
if cc1<0 and (buycond1 or exittime) then cc1:=0;
if cc1=0 and buycond1 and entertime then cc1:=1;
if cc1=0 and sellcond1 and entertime then cc1:=-1;

if cc2>0 and (sellcond2 or exittime) then cc2:=0;
if cc2<0 and (buycond2 or exittime) then cc2:=0;
if cc2=0 and buycond2 and entertime then cc2:=1;
if cc2=0 and sellcond2 and entertime then cc2:=-1;

if cc3>0 and (sellcond3 or exittime) then cc3:=0;
if cc3<0 and (buycond3 or exittime) then cc3:=0;
if cc3=0 and buycond3 and entertime then cc3:=1;
if cc3=0 and sellcond3 and entertime then cc3:=-1;

cc800043:=2*cc1 + 1*cc2 + 2*cc3;//账户的下单系数
cc800167:=3*cc1 + 2*cc2 + 4*cc3;

if not(islastbar) or dynainfo(207)<91500 then exit;

///////////////////////////////////////////////////以下是账户800043的下单语句,其他账户下单,修改800043为相应账户,接在程序后面即可
lcc800043:=tbuyholdingex('800043','',1)-tsellholdingex('800043','',1);
xiadan800043:=cc800043-lcc800043;
if lcc800043<>extgbdata('lcc800043') then begin//有单子成交,则下单开关设为0,允许下单 extgbdataset('abb800043',0);
 extgbdataset('lcc800043',lcc800043);
end

if tremainqty(0,'800043',stklabel)>=1 or (cc800043<>lcc800043 and time0-extgbdata('abb800043')>10) then begin

//下单后10秒内仍发现委托单,则允许下单。可能是堵单,可能是交易账户网络暂时中断
 extgbdataset('abb800043',0);
end

if xiadan800043>0 then begin
 if lcc800043<0 and extgbdata('abb800043')=0 and tremainqty(0,'800043',stklabel)=0 then begin
  tsellshort(1,min(xiadan800043,abs(lcc800043)),mkt,0,0,'800043'),allowrepeat;
  extgbdataset('abb800043',time0);
 end
 
 if tsellholdingex('800043','',1)=0 and tremainqty(4,'800043',stklabel)=0 and tremainqty(1,'800043',stklabel)=0 and extgbdata('abb800043')=0 then begin
  tbuy(xiadan800043+min(lcc800043,0)>0,xiadan800043+min(lcc800043,0),mkt,0,0,'800043'),allowrepeat;
  extgbdataset('abb800043',time0);
 end
end

if xiadan800043<0 then begin
 if lcc800043>0 and extgbdata('abb800043')=0 and tremainqty(0,'800043',stklabel)=0 then begin
  tsell(1,min(abs(xiadan800043),abs(lcc800043)),mkt,0,0,'800043'),allowrepeat;
  extgbdataset('abb800043',time0);
 end
 
 if tbuyholdingex('800043','',1)=0 and tremainqty(2,'800043',stklabel)=0 and tremainqty(3,'800043',stklabel)=0 and extgbdata('abb800043')=0 then begin
  tbuyshort(abs(xiadan800043)-max(lcc800043,0)>0,abs(xiadan800043)-max(lcc800043,0),mkt,0,0,'800043'),allowrepeat;
  extgbdataset('abb800043',time0);
 end
end


 回到顶部
总数 12 1 2 下一页