简单的代码,求高手看看错在哪里,谢谢!

要添加评论,请登录注册
cheneric
42
cheneric  

做个测试脚本,只要算出连续亏损多少单,怎么也算不出来,错在哪里?

void OnStart()

  {

  int j=OrdersHistoryTotal();

  int beishu=1;

   if(OrderSelect((j-1),SELECT_BY_POS,MODE_HISTORY)==true)

    {

    Print("j=",j,"  profit=",OrderProfit(),"  ticket=",OrderTicket());

    if (OrderProfit()<0)

    {

      j--;

      beishu++;

    }

    }

   Print("beishu=",beishu,"  j=",j);

  }

Ziheng Zhuang
30892
Ziheng Zhuang  
   int cnt = 0;
   int total = OrdersHistoryTotal();
   for(int i=total-1; i>=0; i--)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
      {
         if(OrderProfit()<0)cnt++;
         else break;
      }
   }
要添加评论,请登录注册