设为首页收藏本站

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

关于论坛中R-Break策略中全局变量的几点疑问 [复制链接]

Rank: 1

精华
0
UID
237191
积分
10
帖子
6
主题
4
阅读权限
10
注册时间
2016-7-18
最后登录
2016-7-29
跳转到指定楼层
1#
发表于 2016-7-25 20:46:10 |只看该作者 |倒序浏览
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);
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[1])
{
          SetGlobalVar(0,0);
          SetGlobalVar(1,0);
          startnow=startnow+1;
          ssetup=hitoday[1]+f1*(Close[1]-ltoday[1]);
          senter=((1+f2)/2)*(hitoday[1]+Close[1])-(f2)*ltoday[1];
          benter=((1+f2)/2)*(ltoday[1]+Close[1])-(f2)*hitoday[1];
          bsetup=ltoday[1]-f1*(hitoday[1]-Close[1]);
          bbreak=ssetup+f3*(ssetup-bsetup);
          sbreak=bsetup-f3*(ssetup-bsetup);

         hitoday=High;
          ltoday=Low;

         rfilter=(hitoday[1]-ltoday[1])>=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);
          }

}
End
我想问下
ssetup=hitoday[1]+f1*(Close[1]-ltoday[1]);
           senter=((1+f2)/2)*(hitoday[1]+Close[1])-(f2)*ltoday[1];
           benter=((1+f2)/2)*(ltoday[1]+Close[1])-(f2)*hitoday[1];
           bsetup=ltoday[1]-f1*(hitoday[1]-Close[1]);
           bbreak=ssetup+f3*(ssetup-bsetup);
           sbreak=bsetup-f3*(ssetup-bsetup);
hitoday=High;
           ltoday=Low;
if(High>hitoday)
{
           hitoday=High;
}
if(Low<ltoday)
{
           ltoday=Low;
}
其中的hitoday和ltoday代表着什么 是High和Low吗?那为什么不直接替换掉,我替换掉了 而六个变量的值也因此发生改变?
还有一个问题就是后面的两个if循环,为什么hitoday和ltoday赋值后,还与low和high比较。两者不是一样的了吗?我也试过,如果不加上这句,答案还是不一样。
本人是菜鸟,不懂TB的一些关键的思想,请求大神解答。
您需要登录后才可以回帖 登录 | 注册

bottom

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

GMT+8, 2024-4-27 05:26

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部