信号闪烁
2024-09-13 14:20

  Global Numeric high_profit(1800);

   Global Numeric close_position(0);

   Global Numeric short_build(0);

   Global Numeric long_build(0);

If(MarketPosition == -1 && (short_build - Close[1])*lots >= high_profit)

       {

        high_profit = (short_build - Close[1])*lots;

        close_position = high_profit * 0.5;

       }

       Else If(MarketPosition == 1 && (Close[1] - long_build)*lots >= high_profit)

       {

        high_profit = (Close[1] - long_build)*lots;

        close_position = high_profit * 0.5;

       }


If(MarketPosition == -1)

{

   If((short_build - Close[1])*lots < close_position && close_position > 0 && (short_build - Close[1]) > 0 )

  {

    If((short_build - Close[1])*lots <1800)

    {

  BuyToCover(shortposition , Close);

  shortposition = 0;

  close_position = 0;

  high_profit = profit;

  If(sign_ni == 1)

  {

   need_plus = 1;

  }

  Else If(Open_bar > 6000 && sign_ni == 0)

  {

    sign_ni = 1;

  }

}

Else If((short_build - Close[1])*lots >= 1800)

{

close_position = high_profit * 0.3;

}

 

   }


}

Else If(MarketPosition == 1)

{

  If((Close[1] - long_build)*lots < close_position && close_position > 0 && (Close[1] - long_build) > 0)

  {

      If((Close[1] - long_build)*lots < 1800)

      {

  Sell(longposition , Close);

  longposition = 0;

  close_position = 0;

  high_profit = profit;

  If(sign_ni == 1)

  {

   need_plus = 1;

  }

}

Else If((Close[1] - long_build)*lots >= 1800)

{

close_position = high_profit * 0.3;

}


  }

}


请问该段代码为什么会出现信号闪烁,我看了避免信号闪烁的视频,把可能会出现信号闪烁的问题给规避掉了,但还是出现了信号闪烁的问题。

评论区
SunnyChoni

使用全局变量是因为多个函数用到了该变量

2024-09-14 00:08
SunnyChoni

全局变量是每个tick都会重置变量的值吗

2024-09-14 00:06
SunnyChoni

这个代码的问题就是达到止盈条件之后,会平仓,但是在图表上不会显示,如果重新打开图表,他又准确的显示了

2024-09-13 15:23
SunnyChoni

这只是代码的一部分,long_build和short_build 分别是多单建仓价和空单建仓价,在建仓的时候将建仓价赋给这两个变量

2024-09-13 15:21
顶部