以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]后台程序不平仓  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=77840)

--  作者:渴望知识
--  发布时间:2015/4/21 14:31:14
--  [求助]后台程序不平仓
请教一个问题啊,我是用图表程序直接改成了后台程序,里面的什么BUY\\SELL、HODING、LIM啥的也都按照后台的语句更改完了,编译也通过了,但是为什么在图表上有平仓的,而后台里没平仓呢?
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20150421142754.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20150421142831.png
图片点击可在新窗口打开查看

--  作者:jinzhe
--  发布时间:2015/4/21 14:35:43
--  

http://www.weistock.com/bbs/dispbbs.asp?BoardID=4&ID=1246&replyID=&skin=1

图表和后台不一样,不要有“图表有信号为什么后台没有信号”的思想

上面的链接是金字塔的调试方式,把所需要的信息调试出来,看看后台信号是不是真的成立了


--  作者:渴望知识
--  发布时间:2015/4/21 15:01:48
--  

是这样的,我没用那么太复杂的东西,下面是我控制单元的源码,请帮忙看看有什么问题吗?为什么在监控里会出现连续开仓呢?我的策略包括这个控制开仓的都用THOLDING的控制了啊。


tbuy(tholding=0 and (szkc or xdhckc)  ,1,lmt,intpart(gpx)),ORDERQUEUE; //开多
tbuySHORT(tholding=0  and (xdkc or szhckc)  ,1,lmt,intpart(gpx)),ORDERQUEUE;//开空

 

kcwzl:=ref(low,typebar(1,1));//开多单时的最低价
kcwzh:=ref(high,typebar(1,3));//开空单时的最高价

kdzsjg:=kcwzl-zs*a,COLORRED;//多单止损价格
kkzsjg:=kcwzh+zs*a,COLORBLACK;//空单止损价格

kdzs1:=C<kdzsjg  and abb and tholding>0;//多单止损条件
kkzs1:=c>kkzsjg  and abb and tholding<0;//空单止损条件
kdzs2:=cross(qsx,c) and abb and tholding>0;//多单止损条件2
kkzs2:=cross(c,qsx) and abb and tholding<0;//空单止损条件2

  
 
qsdzs:=kdzs1 and abb;//趋势多单止损条件
qskzs:=kkzs1 and abb;//趋势空单止损条件

tsell(qsdzs or kdzs2 and tholding>0,0,lmt,c),ORDERQUEUE;//平多止损
tsellshort(qskzs or kkzs2 and tholding<0,0,lmt,c),ORDERQUEUE;//平空止损

 

//多单止盈、保本计算
HH:=HHV(H,enterbars+1);    //买开仓位置到现在最高价
A1:=ENTERPRICE+zy*A;       //止盈点差起始位置
A2:=A1+zzdc*A;              //追踪点差起始位置
A3:=A1-2*A;                //最小止盈位置(止盈的数值要大于这行的系数最小2.5倍)
A4:=HH-zzdc*A;              //以上为根据止赢点差计算多单追踪止赢位置||

if ((HH>=A1 && HH<=A2 && C<=A3 && c<=o)||(HH>A2 && C<=A4) and abb)
    && c>(enterprice+a) && tholding>0  then
    tsell(1,0,lmt,c),ORDERQUEUE ; //多单止盈和追踪止盈
   
if hh<=a1 and hh>=(enterprice+n*a) and c<=a4 and abb
      && tholding>0 then tsell(1,0,lmt,a4),ORDERQUEUE; //多单保本
 {   
if hh>=(enterprice+4*a) and c=(enterprice+2*a) 
      && tholding>0 then tsell(1,0,lmt,(enterprice+2*a)),ORDERQUEUE; //多单保本
}
if   c>=(enterprice+2*a) and hh<=(enterprice+n*a) and c<=a4
      && tholding>0 then tsell(1,0,lmt,a4),ORDERQUEUE; //多单保本     
   
//空单止盈、保本计算
LL:=LLV(L,enterbars+1);    //卖开仓位置到现在最低价
B1:=enterprice-zy*A;
B2:=B1-zzdc*A;
B3:=B1+2*A;
B4:=LL+zzdc*A;             //以上为根据止赢点差计算空单追踪止赢位置

if ((LL<=B1 && LL>=B2 && C>=B3 && c>=o )||(LL<B2 && C>=B4) and abb)
    && c<(enterprice-a) && tholding<0  then
       tsellshort(1,0,lmt,c),ORDERQUEUE;//空单止盈和追踪止盈

if B1<=LL and LL<(enterprice-m*a) && c>=b4 and abb
      && tholding<0 then tsellshort(1,0,lmt,b4),ORDERQUEUE; //空单保本
{    
if  LL<(enterprice-4*a) && c=(enterprice-2*a) and abb
      && tholding<0 then tsellshort(1,0,lmt,(enterprice-2*a)),ORDERQUEUE; //空单保本
}     
if    c<=(enterprice-2*a) and ll>=(enterprice-m*a) and c>=b4
      && tholding<0 then tsellshort(1,0,lmt,b4),ORDERQUEUE; //空单保本     
 
//收盘前1分钟,清仓
{
//if time0>=timetot0(closetime(0))-60 then begin
if time=145500 then begin
     tsellshort(1,0,lmt,c);
     tsell(1,0,lmt,c);
end
}
持仓:tholding,linethick0;
资产:asset;
//,noaxis
可用现金:cash(0),linethick0;

 cc812396:=tholding;     
drawtextex(1,1,800,0,\'虚拟持仓为:\'+numtostr(CC812396,0));//在图表上输出虚拟持仓以便监控

 


--  作者:jinzhe
--  发布时间:2015/4/21 15:06:34
--  

这个问题你问我,我也不知道,你所需要的是按照上面的内容,把你的下单条件和持仓信息都调试出来

这样就可以看到是下单条件不成立还是持仓条件不成立了

还有后台的是teneterprice,不是enterprice


--  作者:渴望知识
--  发布时间:2015/4/21 15:11:00
--  
另外,我的问题还有,就是为啥在监控里看不到平仓呢?是没平还是没显示呢?相同的方向没平仓就又开仓了,这有点不理解。
--  作者:jinzhe
--  发布时间:2015/4/21 15:17:05
--  
没平仓说明平仓条件不满足
--  作者:渴望知识
--  发布时间:2015/4/21 15:21:36
--  

哦,那我加入了tholding=0 这个条件,那就算不平仓,也不能再开仓吧。

谢谢你上面帮我找出的那个小问题。


--  作者:jinzhe
--  发布时间:2015/4/21 15:24:22
--  

tholding计算持仓是会对冲的,1手多1手空的情况下会返回0

有多有空推荐 tbuyholdingex 和tsellholdingex


--  作者:渴望知识
--  发布时间:2015/4/21 15:35:51
--  

哦,这个是这样的,我的策略里没有对锁的存在,必须是多开后平多才能开空。空平后再开多,这样也需要用到tbuyholdingex 和tsellholdingex吗?


--  作者:jinzhe
--  发布时间:2015/4/21 15:39:40
--  

也可以

[此贴子已经被作者于2015/4/21 15:40:28编辑过]