Sleep

在当前执行的EA交易或脚本中,该函数是指在指定的时间间隔内暂停交易业务。

void  Sleep(
   int  milliseconds      // 间隔
   );

参量

milliseconds

[in]  毫秒之内的内部延期

返回值

没有返回值

注释

The Sleep()函数不能被自定义指标调用,因为指标是以界面线路通过并不能够放慢速度,智能交易每0.1 second秒会检测。

示例:

//+------------------------------------------------------------------+
//| 脚本程序起始函数                                                   |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 在图表评论区显示从10到1的倒计时
   for(int i=10i>0 && !IsStopped(); i--)
     {
      Comment(StringFormat("Wait %u seconds",i));
      Sleep(1000);
     }
//--- 在“到达”评论中编辑一段文字,描述脚本的目的
   string text="This was a test showing how the Sleep() function works";
   string mess="";
   for(int i=0i<(int)text.Length(); i++)
     {
      mess+=ShortToString(text.GetChar(i));
      Sleep(100);
      Comment(mess);
     }
//--- 再见...
   Sleep(1000);
   for(int i=0i<6i++)
     {
      mess=(i % 2 == 0 ? "" : "  Bye!");
      Comment(mess);
      Sleep(300);
     }
//--- 删除图表上的文本
   Comment("");
  }