'\end_of_program' - unbalanced left parenthesis error

 

Hi,


Having already searched this forum for other people having the same issue as me, it has become evident that this error is simply due to a missing ( { or [ and vice-versa.

But when I double-click the error in the compiler error pane, the cursor moves to a large section of greyed out code using /* */, containing an operator which is also greyed out?

Not sure why.

Has anyone else experienced this phenomenon?


Regards,


Wilbur.

 
wilbur:

Hi,


Having already searched this forum for other people having the same issue as me, it has become evident that this error is simply due to a missing ( { or [ and vice-versa.

But when I double-click the error in the compiler error pane, the cursor moves to a large section of greyed out code using /* */, containing an operator which is also greyed out?

Not sure why.

Has anyone else experienced this phenomenon?


Regards,


Wilbur.

Try roaming around with Page Up/Page Down.

 

Or post your code.


CB

 

The compiler (and the editor too) is useless when it comes to telling you where the error is.


One thing you can do is to copy and paste your code into an editor which can find and highlight matching brackets.

 

This kind of thing never happens with neatly written code.. And I really mean never. Clean your code up! ;)

Jon

 
Archael:

This kind of thing never happens with neatly written code.. And I really mean never. Clean your code up! ;)

Jon

Archael:

This kind of thing never happens with neatly written code.. And I really mean never. Clean your code up! ;)

Jon

Whilst I was still in my infancy of writing MQL4 code and programming at a junior level, yes you're exactly right, this kind of never did happen, but those days have since passed and the challenge of writing more complex code still eludes me.


Regards,


Wilbur

 

The only tip that is worth gold in this case is that, if nothing else, you should always keep the same indentation style flowing throughout your code. Here are basic rules I choose to follow for myself:

1. My condition is always always in this format: if(a < b){.

2. I always indent the next line since it's a new block.

3. Inside the block, I always have an empty line separating different sets of conditions.

4. I always close the block at the same indentation level at which it started.

.

Here's an example of 1 function and see for yourself how impossible it would be to forget a squiggly bracket:

void ModeChange()
{
   int i;
   int total = OrdersTotal();
   
   for(i=total-1;i>=0;i--){
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber){
            if(OrderType() == OP_BUY)
               CloseTrades(false, true);
            else if(OrderType() == OP_SELL)
               CloseTrades(true, false);
            else
               continue;
            
            break;
         }
      }
   }
}

Hope this points you in the right direction. Remember that cleanly written code and well established pseudo-code before writing are probably the most important things that will save you time and useless errors during development. Also, if you forget a semi-colon (;) somewhere -- which is another common syntax error, it's usually very very easy to track down when code is written like this.

Jon