您现在的位置:程序化交易>> 期货公式>> 金字塔等>> 金字塔模型>>正文内容

金字塔不平今控制日交易次数。[金字塔模型]

这个程序自己读取图表程序中的holding,这样就不要修改程序了。可以达到以下目的:

1.不平今;
2.控制日内开仓次数不超过10次;
3.在一定程度上突破了日开仓10手限制(靠解锁,需要的资金要大一些);
 
//不平日内开仓,且控制日内开仓不超过10手。
r1:=todaybar-1;
tn:=1;//每次交易手数,要和主程序的一致
 
r4:=stkindiex(\'if00\',\'qq24xz.持仓(2)\',0,21,5,0),linethick0;//
 
r6:r4,linethick0;
rr:r6-ref(r6,1),noaxis;
 
//re:sum(abs(rr),r1+1),noaxis;
 
k1:=tbuyholding(0)=0;
k2:=tsellholding(0)=0;
 
r10:=tbuyholding(1);
r11:=abs(tsellholding(1));
 
//********************
GLOBALVARIABLE:a1=0;
if r1=0 then a1:=0;
 
//********************
if rr>0 and k2 then 
begin
if r11>=rr then 
begin
tsellshort(1,rr,lmt,c);
end
if r11<rr and r11>0 then
begin
tsellshort(1,r11,lmt,c);
tbuy(1,rr-r11,lmt,c);
a1:=a1+rr-r11;
end
if r11=0 then
begin
tbuy(1,rr,lmt,c);
a1:=a1+rr;
end
end
if rr<0 and k1 then
begin
if r10>=abs(rr) then
begin
tsell(1,abs(rr),lmt,c);
end
if r10<abs(rr) and r10>0 then
begin
tsell(1,r10,lmt,c);
tbuyshort(1,abs(rr)-r10,lmt,c);
a1:=a1+abs(rr)-r10;
end
if r10=0 then
begin
tbuyshort(1,abs(rr),lmt,c);
a1:=a1+abs(rr);
end
end
 
//************************
if rr>0 and not(k2) and a1<10-rr then
begin
tbuy(1,rr,lmt,c);
a1:=a1+rr;
end
if rr>0 and not(k2) and a1>=10-rr and a1<10 then
begin
r13:=max(10-a1,1);
tbuy(1,r13,lmt,c);
a1:=10;
end
 
//---------------------------
if rr<0 and not(k1) and a1<10-abs(rr) then
begin
tbuyshort(1,abs(rr),lmt,c);
a1:=a1+abs(rr);
end
if rr<0 and not(k1) and a1>=10-abs(rr) and a1<10 then
begin
r14:=max(10-a1,1);
tbuyshort(1,r14,lmt,c);
a1:=10;
end
 
 //------每天将10限制交易完(这个可以不做)----------------
 r20:=intpart((10-a1)/2);
 
 if currenttime>145955 and r20>0 then
 begin
 tbuy(1,r20,mkt);
 tbuyshort(1,r20,mkt);
 a1:=10;
 end

 

{别忘了将本网告诉您身边的朋友,向朋友传达有用资料,也是一种人情,你朋友会感谢你的。}

 

 

有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友

可联系技术人员 QQ: 511411198  有需要帮忙请点击这里留言!!!进行 有偿 编写!不贵!点击查看价格!

 


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容