MQ代码每次只开仓一次,哪里出了错误呢? (文华财经wh9)

投资者咨询:MQ代码每次只开仓一次,哪里出了错误呢? (文华财经wh9)
来源:文华财经  日期:2018-5-4 13:47
 老师能帮忙看一下吗?

Setting
 SetTickData:1,60;
Vars
Numeric kjttj;
Numeric voltj;
Numeric beishu;
  NumericSeries anm;
  NumericSeries ancj;
  NumericSeries k1;
  NumericSeries d1;
  Global_Numeric BEGIN_SIG_k;
  Global_Numeric BEGIN_SIG_d;
   Global_Numeric Time_sig;

Begin
beishu = 0.0;

Time_sig = 1; //Time > 0.09 && Time < 0.15;
anm = (hhv(new,2) + llv(new,2))/2;
ancj = (Tick_Vol+ref(Tick_Vol,1));

k1 = anm < ref(anm,2)-beishu*MinPrice;
d1 = anm > ref(anm,2)+beishu*MinPrice;
kjttj = (Count(k1, 10)>=2 And Count(d1,10) == 0) && Time_sig ==1;
voltj = (ancj > ma(ancj,60)) && Time_sig ==1;
If(kjttj Or voltj)
{
BEGIN_SIG_k = 1;
}
If(Time_sig == 0)
{
BEGIN_SIG_k = 0;
}

if(BEGIN_SIG_k ==1)
{
If(anm<ref(anm,1)-beishu*MinPrice && ref(BarsLast(anm<ref(anm,1)-beishu*MinPrice),1)<10)
{
SellShort;
}
}

If(anm>(ref(anm,1)+beishu*MinPrice))
{
If(A_SellPosition > 0)
{
BuyToCover;
}
BEGIN_SIG_k=0;
}



End
技术人员回复
日期:2018-5-4 13:58
如下修改,您试下

Setting
   SetTickData:1,60;
Vars
    Numeric kjttj;
    Numeric voltj;
    Numeric beishu;
    NumericSeries anm;
    NumericSeries ancj;
    NumericSeries k1;
    NumericSeries d1;
    Global_Numeric BEGIN_SIG_k;
    Global_Numeric BEGIN_SIG_d;
    Global_Numeric Time_sig;
Begin
beishu = 0.0;
Time_sig = 1; //Time > 0.09 && Time < 0.15;
anm = (hhv(new,2) + llv(new,2))/2;
ancj = (Tick_Vol+ref(Tick_Vol,1));
k1 = anm < ref(anm,2)-beishu*MinPrice;
d1 = anm > ref(anm,2)+beishu*MinPrice;
kjttj = (Count(k1, 10)>=2 And Count(d1,10) == 0) && Time_sig ==1;
voltj = (ancj > ma(ancj,60)) && Time_sig ==1;
If(anm<ref(anm,1)-beishu*MinPrice && ref(BarsLast(anm<ref(anm,1)-beishu*MinPrice),1)<10)
{
SellShort;
}
If(anm>(ref(anm,1)+beishu*MinPrice))
        {
  If(A_SellPosition > 0)
 {
    BuyToCover;
  }
        }
End

投资者咨询:MQ代码每次只开仓一次,哪里出了错误呢? (文华财经wh9)
来源:文华财经  日期:2018-5-4 13:47
 您好老师,我这边加载后发现还是只开仓一次,不知道原因在哪儿。。
技术人员回复
日期:2018-5-4 14:32
 请参考:

Setting
 SetTickData:1,60;
Vars
Numeric kjttj;
Numeric voltj;
Numeric beishu;
  NumericSeries anm;
  NumericSeries ancj;
  NumericSeries k1;
  NumericSeries d1;
Begin
beishu = 0.0;
anm = (hhv(new,2) + llv(new,2))/2;
ancj = (Tick_Vol+ref(Tick_Vol,1));
k1 = anm < ref(anm,2)-beishu*MinPrice;
d1 = anm > ref(anm,2)+beishu*MinPrice;
kjttj = (Count(k1, 10)>=2 And Count(d1,10) == 0) ;
voltj = (ancj > ma(ancj,60));
If(anm<ref(anm,1)-beishu*MinPrice && ref(BarsLast(anm<ref(anm,1)-beishu*MinPrice),1)<10)
{
SellShort;
}
If(anm>(ref(anm,1)+beishu*MinPrice))
{
   BuyToCover;
}

End