以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  程序化交易实盘俱乐部  (http://222.73.7.161/bbs/list.asp?boardid=9)
----  [分享]打破股指交易限制  (http://222.73.7.161/bbs/dispbbs.asp?boardid=9&id=95768)

--  作者:qwer123
--  发布时间:2016/4/2 14:12:14
--  [分享]打破股指交易限制
股指交易限制让人很无语。现在搞了一个小程序,看看能不能用,希望大家一起来完善。同时希望金字塔官方参与进来,谢谢大家。

//不平日内开仓,且控制日内开仓不超过10手。
//如果资金比较大,且仓位不重的账户,可无视股指交易限制。技巧:多开一些对锁仓,交易结束前把10手开仓用完。
r1:=todaybar-1;
tn:=1;//每次交易手数,要和主程序的一致

r4:=stkindiex(\'ic00\',\'qq24xz.持仓(1)\',0,21,3,0),linethick0;//
//r5:=stkindiex(\'ic00\',\'qq24.持仓(1)\',0,21,3,0);

r6:=r4{+r5},linethick0;//可以进行多程序组合交易,后面的东西要做相应的改变
rr:r6-ref(r6,1),linethick1,noaxis;

r10:=TBUYHOLDING(1)-TBUYHOLDING(0);
r11:=abs(TSELLHOLDING(1))-abs(tsellholding(0));

//----------------------
GLOBALVARIABLE:a1=0;//用变量以前吃过亏,按下面使用a1能不能得到正确的值?
if r1=0 then a1:=0;

//*********************
if rr=-tn and r10>=tn then tsell(1,tn,lmt,c);//平仓或开空情况;
if rr=-tn and r10<tn and a1<=10-tn then 
begin
tbuyshort(1,tn,lmt,c);
a1:=a1+tn;
end
if rr=tn and r11>=tn then tsellshort(1,tn,lmt,c);//平仓或开多情况
if rr=tn and r11<tn and a1<=10-tn then 
begin
tbuy(1,tn,lmt,c);
a1:=a1+tn;
end

//------------平仓反手----------
if rr=-2*tn and r10>=tn then
begin
tsell(1,tn,lmt,c);
if a1<=10-tn then
begin
tbuyshort(1,tn,lmt,c);
a1:=a1+tn;
end
end
if rr=-2*tn and r10<tn and a1<=10-2*tn then
begin
tbuyshort(1,2*tn,lmt,c);
a1:=a1+2*tn;
end

if rr=2*tn and r11>=tn then
begin
tsellshort(1,tn,lmt,c);
if a1<=10-tn then
begin
tbuy(1,tn,lmt,c);
a1:=a1+tn;
end
end
if rr=2*tn and r11<tn and a1<=10-2*tn then
begin
tbuy(1,2*tn,lmt,c);
a1:=a1+2*tn;
end

//----------日内开仓次数超10次--------------如果对锁单不足,就要平日内单了。
if rr=tn and a1>10-tn then tsellshort(1,tn,lmt,c);
if rr=-tn and a1>10-tn then tsell(1,tn,lmt,c);

if rr=2*tn and a1>10-2*tn then tsellshort(1,2*tn,lmt,c);
if rr=-2*tn and a1>10-2*tn then tsell(1,2*tn,lmt,c);

//----------用光当天10次开仓次数--------------
rr2:=intpart((10-a1)/2);//这部分最好是手工开进去,要不然很容易自成交。手工开进去,TBUYHOLDING(1)能识别吗?
if currenttime>145955 and rr2>0 and rr=0 then
begin
tbuy(1,rr2,mkt);
tbuyshort(1,rr2,mkt);
end
 


--  作者:qwer123
--  发布时间:2016/4/2 14:15:10
--  
//不平日内开仓,且控制日内开仓不超过10手。
//如果资金比较大,且仓位不重的账户,可无视股指交易限制。技巧:多开一些对锁仓,交易结束前把10手开仓用完。
r1:=todaybar-1;
tn:=1;//每次交易手数,要和主程序的一致

r4:=stkindiex(\'ic00\',\'qq24xz.持仓(1)\',0,21,3,0),linethick0;//
//r5:=stkindiex(\'ic00\',\'qq24.持仓(1)\',0,21,3,0);

r6:=r4{+r5},linethick0;//可以进行多程序组合交易,后面的东西要做相应的改变
rr:r6-ref(r6,1),linethick1,noaxis;

r10:=TBUYHOLDING(1)-TBUYHOLDING(0);
r11:=abs(TSELLHOLDING(1))-abs(tsellholding(0));

//----------------------
GLOBALVARIABLE:a1=0;//用变量以前吃过亏,按下面使用a1能不能得到正确的值?
if r1=0 then a1:=0;

//*********************
if rr=-tn and r10>=tn then tsell(1,tn,lmt,c);//平仓或开空情况;
if rr=-tn and r10<tn and a1<=10-tn then 
begin
tbuyshort(1,tn,lmt,c);
a1:=a1+tn;
end
if rr=tn and r11>=tn then tsellshort(1,tn,lmt,c);//平仓或开多情况
if rr=tn and r11<tn and a1<=10-tn then 
begin
tbuy(1,tn,lmt,c);
a1:=a1+tn;
end

//------------平仓反手----------
if rr=-2*tn and r10>=tn then
begin
tsell(1,tn,lmt,c);
if a1<=10-tn then
begin
tbuyshort(1,tn,lmt,c);
a1:=a1+tn;
end
end
if rr=-2*tn and r10<tn and a1<=10-2*tn then
begin
tbuyshort(1,2*tn,lmt,c);
a1:=a1+2*tn;
end

if rr=2*tn and r11>=tn then
begin
tsellshort(1,tn,lmt,c);
if a1<=10-tn then
begin
tbuy(1,tn,lmt,c);
a1:=a1+tn;
end
end
if rr=2*tn and r11<tn and a1<=10-2*tn then
begin
tbuy(1,2*tn,lmt,c);
a1:=a1+2*tn;
end

//----------日内开仓次数超10次--------------如果对锁单不足,就要平日内单了。
if rr=tn and a1>10-tn then tsellshort(1,tn,lmt,c);
if rr=-tn and a1>10-tn then tsell(1,tn,lmt,c);

if rr=2*tn and a1>10-2*tn then tsellshort(1,2*tn,lmt,c);
if rr=-2*tn and a1>10-2*tn then tsell(1,2*tn,lmt,c);

//----------用光当天10次开仓次数--------------
rr2:=intpart((10-a1)/2);//这部分最好是手工开进去,要不然很容易自成交。手工开进去,TBUYHOLDING(1)能识别吗?
if currenttime>145955 and rr2>0 and rr=0 then
begin
tbuy(1,rr2,mkt);
tbuyshort(1,rr2,mkt);
end
 


--  作者:qwer123
--  发布时间:2016/4/2 14:58:49
--  
不好意思,股指没有今仓和昨仓的问题。只要今天开仓,那么平仓全按平今算,所以上面的程序没有意义了。
--  作者:qwer123
--  发布时间:2016/4/3 17:55:50
--  
程序最了修改,发表在“交易策略发布区”,有兴趣的去那里看看吧。感觉不错。