以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  盈利后不再开仓,有地方不对,请高手,使用金字塔的全局变量数据库修改下  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=547)

--  作者:toby907
--  发布时间:2009/12/22 15:25:55
--  盈利后不再开仓,有地方不对,请高手,使用金字塔的全局变量数据库修改下

IF (DAY()<>REF(DAY(),1)) THEN BEGIN
BWINCOUNT:=0;
SWINCOUNT:=0;
END;


IF BWINCOUNT=0 THEN BEGIN
    IF BWINCOUNT=0 THEN BEGIN
       TBUY(CLOSE>HH2 AND TTYPE(1)<>1 AND TIME<145901 AND TEXITBARS<>0,N,LMT,CLOSE+MINDIFF);
         END
      
    IF TTYPE(1)=1 THEN BEGIN
     TSELL((CLOSE<LL1 OR TIME>145900 OR CLOSE>(TENTERPRICE+20) OR CLOSE<(TENTERPRICE-5)),N,LMT,CLOSE-MINDIFF);
        END
    
    IF (TTYPE(1)=2 AND TENTERPRICE<TEXITPRICE) THEN BEGIN
     BWINCOUNT:=1;
     END
    
 END

 


     IF SWINCOUNT=0  THEN BEGIN
    IF SWINCOUNT=0 THEN BEGIN
       TBUYSHORT(CLOSE<LL2 AND TTYPE(1)<>3 AND TIME<145901 AND TEXITBARS<>0,N,LMT,CLOSE-MINDIFF);
    END
      
    IF TTYPE(1)=3 THEN BEGIN
     TSELLSHORT((CLOSE>HH1 OR TIME>145900 OR CLOSE>(TENTERPRICE+5) OR CLOSE<(TENTERPRICE-5)),N,LMT,CLOSE+MINDIFF);
     END
    
    IF (TTYPE(1)=4 AND TENTERPRICE>TEXITPRICE) THEN BEGIN
     SWINCOUNT:=1;
     END
    
     END

[此贴子已经被admin于2009-12-22 15:28:08编辑过]

--  作者:admin
--  发布时间:2009/12/22 15:34:19
--  

IF (DAY()<>REF(DAY(),1)) THEN BEGIN
EXTGBDATASET(\'BWINCOUNT\',0);
EXTGBDATASET(\'SWINCOUNT\',0);
END;

BWINCOUNT:=EXTGBDATA(\'BWINCOUNT\');
SWINCOUNT:=EXTGBDATA(\'SWINCOUNT\');

IF BWINCOUNT=0 THEN BEGIN
    IF BWINCOUNT=0 THEN BEGIN
       TBUY(CLOSE>HH2 AND TTYPE(1)<>1 AND TIME<145901 AND TEXITBARS<>0,N,LMT,CLOSE+MINDIFF);
         END
      
    IF TTYPE(1)=1 THEN BEGIN
     TSELL((CLOSE<LL1 OR TIME>145900 OR CLOSE>(TENTERPRICE+20) OR CLOSE<(TENTERPRICE-5)),N,LMT,CLOSE-MINDIFF);
        END
    
    IF (TTYPE(1)=2 AND TENTERPRICE<TEXITPRICE) THEN BEGIN
     EXTGBDATASET(\'BWINCOUNT\',1);
     END
    
 END

 


     IF SWINCOUNT=0  THEN BEGIN
    IF SWINCOUNT=0 THEN BEGIN
       TBUYSHORT(CLOSE<LL2 AND TTYPE(1)<>3 AND TIME<145901 AND TEXITBARS<>0,N,LMT,CLOSE-MINDIFF);
    END
      
    IF TTYPE(1)=3 THEN BEGIN
     TSELLSHORT((CLOSE>HH1 OR TIME>145900 OR CLOSE>(TENTERPRICE+5) OR CLOSE<(TENTERPRICE-5)),N,LMT,CLOSE+MINDIFF);
     END
    
    IF (TTYPE(1)=4 AND TENTERPRICE>TEXITPRICE) THEN BEGIN
     EXTGBDATASET(\'SWINCOUNT\',1);
     END
    
     END


--  作者:admin
--  发布时间:2009/12/22 15:49:44
--  

对于多品种交易,因为全局变量使用一个索引会导致不同品种之间的相互干扰,例如

BWINCOUNT:=EXTGBDATA(\'BWINCOUNT\');
SWINCOUNT:=EXTGBDATA(\'SWINCOUNT\');

 

因为所有的索引都用\'BWINCOUNT\'索引,所以后面的品种会把前面覆盖掉.解决办法是使用每个品种的代码加以区分,使他们相互不受干扰

EXTGBDATASET(STKLABEL&\'BWINCOUNT\',0);
EXTGBDATASET(STKLABEL&\'SWINCOUNT\',0);

&符号表示两个字符串相加