首页 > 解决方案 > MT4 Expert Advisor EA 更新离线图表价格的问题

问题描述

以下脚本使用计时器,在正常图表中运行良好,每 1 秒在图表上评论当前蜡烛收盘价。但是,在离线图表上,它只加载一次收盘价,并且不会每秒更新一次。这是代码:

void OnTimer()
  {
  int m=TimeSeconds(TimeLocal());


  double CloseValue = Close[0]; //Current Candle Close Value
  string CloseValueString = DoubleToString(CloseValue,5); //Current price 


  Comment(
  "Current value :",CloseValueString,"\n",
  "Candle time :",m
  );
}

在此处输入图像描述

标签: mql4mt4

解决方案


通过添加 Refreshrates() 函数来解决,该函数在我的函数末尾更新离线图表的数据:

void OnTimer()
{
 int m=TimeSeconds(TimeLocal());


  double CloseValue = Close[0]; //Current Candle Close Value
  string CloseValueString = DoubleToString(CloseValue,5); //Current price 


  Comment(
  "Current value :",CloseValueString,"\n",
  "Candle time :",m
  );
RefreshRates();
}

推荐阅读