admin管理员组文章数量:1291260
I am trying to develop an Expert Advisor (EA) for MetaTrader 5 using MQL5, but I keep encountering the error '(<) - open parenthesis expected' for the following:
if (Bars < 3)
Here is a snippet of my code where the error occurs:
bool CheckBuyCondition()
{
if (Bars < 3)
return false;
double prevClose1 = iClose(Symbol(), PERIOD_M5, 1);
double prevClose2 = iClose(Symbol(), PERIOD_M5, 2);
double prevHigh1 = iHigh(Symbol(), PERIOD_M5, 1);
double prevHigh2 = iHigh(Symbol(), PERIOD_M5, 2);
double currClose = iClose(Symbol(), PERIOD_M5, 0);
double prevOpen1 = iOpen(Symbol(), PERIOD_M5, 1);
double prevOpen2 = iOpen(Symbol(), PERIOD_M5, 2);
if ((prevClose1 < prevOpen1) && (prevClose2 < prevOpen2) && (currClose > prevHigh1) && (currClose > prevHigh2) && (currClose > ema10))
return true;
return false;
}
bool CheckSellCondition()
{
if (Bars < 3)
return false;
double prevClose1 = iClose(Symbol(), PERIOD_M5, 1);
double prevClose2 = iClose(Symbol(), PERIOD_M5, 2);
double prevLow1 = iLow(Symbol(), PERIOD_M5, 1);
double prevLow2 = iLow(Symbol(), PERIOD_M5, 2);
double currClose = iClose(Symbol(), PERIOD_M5, 0);
double prevOpen1 = iOpen(Symbol(), PERIOD_M5, 1);
double prevOpen2 = iOpen(Symbol(), PERIOD_M5, 2);
if ((prevClose1 > prevOpen1) && (prevClose2 > prevOpen2) && (currClose < prevLow1) && (currClose < prevLow2) && (currClose < ema10))
return true;
return false;
}
I have tried adding parentheses around each comparison, and I have made sure the syntax follows the correct structure for conditional statements in MQL5. Despite these efforts, I still receive the same errors. I expect the code to compile without syntax errors and the EA to work as intended.
本文标签: syntax error39lt39open parenthesis expectedStack Overflow
版权声明:本文标题:syntax error - '<' - open parenthesis expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741529940a2383694.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论