这都被你发现了,太强了!
不过这不是一个bug。通过文档我们知道,double类型的数值不能直接比较,而应该使用NormalizeDouble之后比较。
试试 NormalizeDouble(fullLots,2)再与数值相比。
https://docs.mql4.com/basis/operations/relation
Two unnormalized floating-point numbers cannot be linked by == or != operations. That is why it is necessary to subtract one from another, and the normalized outcome needs to be compared to null.
楼上的,你也很强啊,我帮我解决了一个疑问
十分感谢你的热心,希望跟你交个朋友,我的qq号:17952140
不客气。我的是30707772
wwww_wu:
楼上的,你也很强啊,我帮我解决了一个疑问
十分感谢你的热心,希望跟你交个朋友,我的qq号:17952140
double fullLots=0,addLots=0.01;
int start()
{
for(int i=1;i<=20;i++)
{
sellAddOrder();
}
return(0);
}
void sellAddOrder()
{
if(fullLots<0.16)
{
fullLots=fullLots+addLots;
Alert(fullLots);
if(fullLots==0.09 || fullLots==0.1 || fullLots==0.11 || fullLots==0.12 || fullLots==0.13 || fullLots==0.14 || fullLots==0.15)
Alert("侦测到:",fullLots);
}
}
以上程序运行结果
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.16
用if语句无法侦测到fullLots等于0.1至0.14,这是mt4的bug吗2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 侦测到:0.15
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.15
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.14
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.13
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.12
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.11
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.1
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 侦测到:0.09
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.09
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.08
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.07
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.06
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.05
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.04
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.03
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.02
2012.11.12 10:48:33 2012.09.02 14:35 test EURUSD,M30: Alert: 0.01