hxh989898 发表于 2016-4-24 18:56:53

R-Break公式中bbreak、ssetup、Senter的逻辑关系

老师,您好。我在R-Break公式中加了一段程序测试bbreak、ssetup、Senter的逻辑关系,程序如下:
if (bbreak>ssetup and ssetup>senter+(hitoday-ssetup)/div)
{  
ncount1=ncount1+1;

}else
{
ncount2=ncount2+1;
}

测试以IF000为商品,5分钟K线图,时间从2010年1月1日至2016年4月23日,结果显示,ncount2的次数为2692次,也就是说,有2692次不符合“(bbreak>ssetup and ssetup>senter+(hitoday-ssetup)/div)”的情况。如果是这样,岂不是说,R-Break公式的中轨上部,中轨顶部的逻辑有问题?

---------------------源码如下:

//------------------
// 简称: R_Breaker
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出: 穿堂风
//------------------------




Params
Numeric notbef(9.00);
Numeric notaft(14.55);
Numeric f1(0.35);
Numeric f2(0.07);
Numeric f3(0.25);
Numeric reverse(1.00);
Numeric rangemin(0.2);
Numeric xdiv(3);

Vars
NumericSeries ssetup(0);
NumericSeries bsetup(0);
NumericSeries senter(0);
NumericSeries benter(0);
NumericSeries bbreak(0);
NumericSeries sbreak(0);
NumericSeries ltoday(0);
NumericSeries hitoday(9999);
NumericSeries startnow(0);
NumericSeries div(0);
NumericSeries ncount1(0);
NumericSeries ncount2(0);
BoolSeries rfilter(false);
Numeric i_reverse;
Numeric i_rangemin;
Numeric i_vB;
Numeric i_vS;

Begin
i_reverse = reverse*(OpenD(0)/100);
i_rangemin = rangemin*(OpenD(0)/100);
if(BarStatus==0)
{
        startnow=0;
        div=max(xdiv,1);
}

if(Date != Date)
{
        SetGlobalVar(0,0);
        SetGlobalVar(1,0);
        startnow=startnow+1;
        ssetup=hitoday+f1*(Close-ltoday);
        senter=((1+f2)/2)*(hitoday+Close)-(f2)*ltoday;
        benter=((1+f2)/2)*(ltoday+Close)-(f2)*hitoday;
        bsetup=ltoday-f1*(hitoday-Close);
        bbreak=ssetup+f3*(ssetup-bsetup);
        sbreak=bsetup-f3*(ssetup-bsetup);

        hitoday=High;
        ltoday=Low;

        rfilter=(hitoday-ltoday)>=i_rangemin;
}

if(High>hitoday)
{
        hitoday=High;
}
if(Low<ltoday)
{
        ltoday=Low;
}
if(Time*100>=notbef and Time*100<notaft and startnow>=2 and rfilter)
{

        if(Time != GetGlobalVar(1) and GetGlobalVar(1) != 0)
        {
                SetGlobalVar(1,10000);
        }
        if(hitoday>=ssetup and marketposition>-1 and GetGlobalVar(1)<1)
        {
                If(Low<=(senter+(hitoday-ssetup)/div))
                {
                        SellShort(1,senter+(hitoday-ssetup)/div);
                        SetGlobalVar(1,Time);
                        Return;
                }
        }
        if(ltoday<=bsetup and marketposition<1  and GetGlobalVar(1)<1)
        {
                If(High>=(benter-(bsetup-ltoday)/div))
                {
                        Buy(1,benter-(bsetup-ltoday)/div);
                        SetGlobalVar(1,Time);
                        Return;
                }
        }

        if(marketposition==-1)
        {
                SetGlobalVar(0,1);
                if(High-EntryPrice>=i_reverse)
                {
                        BuyToCover(1,entryprice+i_reverse);
                        Return;
                }
        }
        if(marketposition==1)
        {
                SetGlobalVar(0,1);
                if(EntryPrice-Low>=i_reverse)
                {
                        Sell(1,entryprice-i_reverse);
                        Return;
                }
        }

        if(marketposition==0)
        {
                if(High>=bbreak and GetGlobalVar(0) == 0)
                {
                        Buy(1,bbreak);
                        Return;
                }
        }
        if(marketposition==0)
        {
                if(low<=sbreak  and GetGlobalVar(0) == 0)
                {
                        SellShort(1,sbreak);
                        Return;
                }
        }

}

if(Time*100>=notaft and Time<0.1600)
{

        if(marketposition==-1)
        {
                BuyToCover(1,Open);
        }
        if(marketposition==1)
        {
                Sell(1,Open);
        }

}

if (bbreak>ssetup and ssetup>senter+(hitoday-ssetup)/div)
{  
ncount1=ncount1+1;

}else
{
ncount2=ncount2+1;
}

Commentary("ncount1:"+Text(ncount1));
Commentary("ncount2:"+Text(ncount2));

End

//-----------
// 编译版本        GS2010.12.08
// 用户版本        2011/06/27 14:29
// 版权所有        
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TrabeBlazer公式修改和重写的权利
//---
页: [1]
查看完整版本: R-Break公式中bbreak、ssetup、Senter的逻辑关系