"<" - open parenthesis expected on line 85 – can't find the cause

 

Message:

Hi everyone,
I'm developing an Expert Advisor in MQL5 and I'm getting this compilation error:

'<' - open parenthesis expected v1.mq5 85 12

The problem persists even though I've double-checked the syntax, parentheses, and braces. The error seems to be related to the following portion of the code, but I can't figure out the real cause:

mql5
void OnTick() { if(Bars < 3) return; double open_prev = iOpen(_Symbol, TimeframeToUse, 1); double close_curr = iClose(_Symbol, TimeframeToUse, 0); double openPrice; // The error appears shortly after this line }

The compiler points to a later line, such as:

mql5
if(close_curr < open_prev)

But even when I properly complete the logic with the expected parentheses and blocks, the error still shows up.


What I've already tried:

  • Verified all parentheses and braces are balanced

  • Added the missing variables: ulong ticket; and bool isOpen = GetOpenPositionDetails(...);

  • Reviewed the entire OnTick() function for logic issues or missing brackets


Question:
What is the real cause of this error, and how can I fix it?
Any suggestions on where else to look?

Thanks in advance for any support!

 
Michele Bordi: '<' - open parenthesis expected v1.mq5 85 12

  1. Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
          General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
              Messages Editor
          Forum rules and recommendations - General - MQL5 programming forum (2023)

  2.     if(Bars < 3) return;
    There is no predefined variable name Bars.