设为首页收藏本站

 找回密码
 注册
查看: 1530|回复: 1
打印 上一主题 下一主题

序列变量存在严重BUG [复制链接]

Rank: 1

精华
0
UID
243793
积分
13
帖子
9
主题
4
阅读权限
10
注册时间
2016-11-28
最后登录
2017-11-30
跳转到指定楼层
1#
发表于 2017-11-26 02:31:58 |只看该作者 |倒序浏览
Params
    Numeric Para1(15);
    Numeric Para2(5);
Vars
    NumericSeries ma15;
        NumericSeries ma5;
        NumericSeries x(0);
        Bool Condition1;
        Bool Condition2;
       
        Bool BuySign;
        Numeric SignLength;
       
       
        NumericSeries My_Sign(10000);        // 买入信号 0 无信号 1有信号
        NumericSeries My_Price(10000);        // 买入价格 0 无价   >0 有价
        NumericSeries My_Index(10000);        // Bar索引
        NumericSeries My_State(10000);        // 买入状态 0 初始化 1 挂单  2 成交
       

       
        // 数组测试 - 无数据
        //NumericArray My_Sign[10000];        // 买入信号 0 无信号 1有信号
        //NumericArray My_Price[10000];        // 买入价格 0 无价   >0 有价
        //NumericArray My_Index[10000];        // Bar索引
        //NumericArray My_State[10000];        // 买入状态 0 初始化 1 挂单  2 成交
       

        Numeric iCount;
        Numeric i;
        Numeric j;
       
        String DisplayMsg;
Begin
    BuySign = false;
        SignLength = 10000;
       
       
    ma15 = Average(o,para1);
        ma5 = Average(o,para2);
        Condition1 = CrossOver(ma5,ma15);
        Condition2 = CrossUnder(ma5,ma15);
        if (Condition1)
        {
                Buy(1,Open);
                x = x + 1;
                BuySign = true;
        }
        if (Condition2)
        {
                Sell(1,Open);
        }
               
        if (CurrentBar == 0)
        {
            x = -1;
                for i=0 to SignLength-1
                {
                        My_Sign[i] = 0;
                        My_Price[i] = 0;
                        My_State[i] = 0;       
                        My_Index[i] = -1;
                       
                        PlotString("CurBars", "开始");
                }
        }
        Else
        {
                if (BuySign)
                {       
                        BuySign = False;
                        DisplayMsg =  " 买入信号次数= [ " + Text(x) + " ]" +
                                                  " 买入价格: [ " + Text(low) + " ], ";          
                                               
                        // 不用CurrentBar
                        My_Sign[x] = 1;
                        My_State[x] = 1;
                        My_Index[x] = CurrentBar;
                        My_Price[x] = low;       
                        PlotString("CurBar", Text(CurrentBar));
                               
                       
                        DisplayMsg =  "买入信号:[ " + Text(x) + " ]" +
                                                                                                "My_Sign= [ " + Text(My_Sign[x]) + " ]" +
                                                                                                "My_State= [ " + Text(My_State[x]) + " ]" +
                                                                                                "My_Price= [ " + Text(My_Price[x]) + " ]" +
                                                                                                "My_Index= [ " + Text(My_Index[x]) + " ]" +
                                                                                                "CurrentBar= [ " + Text(CurrentBar) + " ]";
                }       

        }       
       
        // 刷单成交  
        if (BarStatus == 2)
        {
                for i=0 To CurrentBar
                {
                        if ( (My_Sign[i] == 1) And (My_State[i] == 1) and (My_Index[i]>0) )
                        {        
                                My_State[i] = 2;                       
                                DisplayMsg =  "信号I合乎要求:[ " + Text(i) + " ]" +
                                                          "原始索引= [ " +    Text(My_Index[i]) + " ]";
                                FileAppend("J:\\Formula.log",  DisplayMsg);
                               
                                 
                        }
                }       
        }
       
        Commentary(DisplayMsg);  
End

My_Index[i]值飘乎不定, 而且不同的TB版本, 编译出来结果都不同. 这么大的BUG,都没有发现?

Rank: 1

精华
0
UID
243793
积分
13
帖子
9
主题
4
阅读权限
10
注册时间
2016-11-28
最后登录
2017-11-30
2#
发表于 2017-11-26 02:34:02 |只看该作者
还有数组值, 非序列变量, 在每一根BAR下都要初始化. 这样的BUG, TB工程师有没有发现.

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-4-20 07:54

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部