以文本方式查看主题

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

--  作者:系统使用者
--  发布时间:2017/3/27 22:03:58
--  后台交易问题
/平多空单
 if  Tholding>0 and tenterbars>1 and L<=zs then 
  BEGIN
   MyTPrice :=IF(OPEN<zs,OPEN,zs)-MINDIFF;
   TSELL(1,ss,LMT,MyTPrice,0); 
  END  
 if Tholding<0 and tenterbars>1 and H>=zs THEN 
  BEGIN
   MyTPrice :=IF(OPEN>zs,OPEN,zs)+MINDIFF;
   TSELLSHORT(1,ss,LMT,MyTPrice,0);
  END 
//开多单
 IF H>=UpperBand and BLIQCON and THOLDING=0 THEN 
 BEGIN
  MyPrice :=IF(OPEN>UpperBand,OPEN,UpperBand)+MINDIFF;
  TBUY(1,ss,LMT,MyPrice,0);
  zs:=Mdg;
  maxhl:=h;
 END
//开空单
 IF L<=LowerBand and SOPCON and THOLDING=0 THEN
  BEGIN
  MyPrice :=IF(OPEN<LowerBand,OPEN,LowerBand)-MINDIFF;
  TBUYSHORT(1,ss,LMT,MyPrice,0);
  zs:=Mdd;
  maxhl:=l;
 END
图表改后台交易的,出现平空就开空???

--  作者:系统使用者
--  发布时间:2017/3/27 22:52:51
--  
Globalvariable:hold=drawnull;
//平多空单
 if  holding>0 and enterbars>1 and L<=zs then 
  BEGIN
   MyTPrice :=IF(OPEN<zs,OPEN,zs);
   sell(1,ss,LIMIT,MyTPrice-MINDIFF); 
  END  
 if holding<0 and enterbars>1 and H>=zs THEN 
  BEGIN
   MyTPrice :=IF(OPEN>zs,OPEN,zs);
   sellshort(1,ss,LIMIT,MyTPrice+MINDIFF);
  END 
//开多单
 IF H>=UpperBand and BLIQCON and THOLDING=0 THEN 
 BEGIN
  MyPrice :=IF(OPEN>UpperBand,OPEN,UpperBand);
  buy(1,ss,LIMIT,MyPrice+MINDIFF);
  zs:=Mdg;
  maxhl:=h;
 END
//开空单
 IF L<=LowerBand and SOPCON and THOLDING=0 THEN
  BEGIN
  MyPrice :=IF(OPEN<LowerBand,OPEN,LowerBand);
  buyshort(1,ss,LIMIT,MyPrice-MINDIFF);
  zs:=Mdd;
  maxhl:=l;
 END

if Tholding<0 and l<maxhl then begin //重新定位离场实现浮动止损止盈
 zs:=Mdd;
end
if Tholding>0 and h>maxhl then begin 
 zs:=Mdg;
end

cc809008322:=holding;
if not(islastbar) or workmode<>1 then exit;
xiadan809008322:=cc809008322-hold;
if xiadan809008322>0.5 then begin
 cang:=min(xiadan809008322,abs(hold));
 if hold<0 then begin
  tsellshort(1,cang,LMT,0,0,\'809008322\');
 end
 cang:=xiadan809008322+min(hold,0);
 if cang>0 then begin
  tbuy(1,cang,LMT,0,0,\'809008322\');
 end
end
if xiadan809008322<-0.5 then begin
 cang:=min(abs(xiadan809008322),abs(hold));
 if hold>0 then begin
  tsell(1,cang,LMT,0,0,\'809008322\');
 end
 cang:=abs(xiadan809008322)-max(hold,0);
 if cang>0 then begin
  tbuyshort(1,cang,LMT,0,0,\'809008322\');
 end
end
hold:=cc809008322;
WARNING_DISABLE:9;


--  作者:系统使用者
--  发布时间:2017/3/27 22:54:36
--  
按阿火改的,但后面后台交易,限价应该使用前面的限价瑟
帮改改。

--  作者:系统使用者
--  发布时间:2017/3/27 22:58:15
--  
cc809008322:=holding;
if not(islastbar) or workmode<>1 then exit;
xiadan809008322:=cc809008322-hold;
if xiadan809008322>0.5 then begin
 cang:=min(xiadan809008322,abs(hold));
 if hold<0 then begin
  tsellshort(1,cang,LMT,MyTPrice+MINDIFF,0,\'809008322\');
 end
 cang:=xiadan809008322+min(hold,0);
 if cang>0 then begin
  tbuy(1,cang,LMT,MyPrice+MINDIFF,0,\'809008322\');
 end
end
if xiadan809008322<-0.5 then begin
 cang:=min(abs(xiadan809008322),abs(hold));
 if hold>0 then begin
  tsell(1,cang,LMT,MyTPrice-MINDIFF,0,\'809008322\');
 end
 cang:=abs(xiadan809008322)-max(hold,0);
 if cang>0 then begin
  tbuyshort(1,cang,LMT,MyPrice-MINDIFF,0,\'809008322\');
 end
end
hold:=cc809008322;

WARNING_DISABLE:9;

--  作者:jinzhe
--  发布时间:2017/3/28 9:10:38
--  
首先,这段代码你要干什么?
--  作者:系统使用者
--  发布时间:2017/3/28 9:38:15
--  
后台下单交易
[此贴子已经被作者于2017/3/28 9:38:26编辑过]

--  作者:jinzhe
--  发布时间:2017/3/28 9:44:38
--  
然后,问题出在哪里?
--  作者:系统使用者
--  发布时间:2017/3/28 10:17:07
--  
没有开空信号,也不段的开空。
--  作者:系统使用者
--  发布时间:2017/3/28 10:18:50
--  
如何编写才正确?
--  作者:jinzhe
--  发布时间:2017/3/28 10:19:07
--  
用当前的实际的交易情况说明下“没有信号也开空”