如何检查哪个是最早的物品或价格?

时间:2018-12-16 05:39:35

标签: mql4

enter image description here

在上图中,蓝色水平线对象是最旧的对象,如何获取?

类似:

if (blue < yellow) &&  (blue < pink) &&  (blue < red)) { printf ("blue is the oldest object"); }

我需要使用ibarshift吗?我可以举代码示例吗?

1 个答案:

答案 0 :(得分:1)

string oldestObjectName="", name;
datetime oldestObjectDate=INT_MAX, tmpDate;
for(int i=ObjectsTotal()-1;i>=0;i--)
{
   name=ObjectName(i);
   tmpDate=ObjectGetInteger(0,name,OBJPROP_TIME1);
   if(tmpDate<oldestObjectDate)
   {
      oldestObjectDate=tmpDate;
      oldestObjectName=name;
   }
}
printf("oldest object is %s, its time1=%s",oldestObjectName,TimeToString(oldestObjectDate));