The Infamous Unbalanced left parenthesis!

 

Hi, I can't seem to find the solution to this!! I've checked forums and stuff, but I can't find an answer to my problem.

I've made an attachment of my entire work. If you can help to make this better, please do! And then tell me of course =)

I just started learning MQL4 3 days ago and I'm still experimenting, but have been so frustrated with this last error!

Files:
test3.mq4  13 kb
 
It means you forgot to close a parenthesis at some point. This is an extremely frustrating error because it could be anywhere. Whenever i get it I start commenting out different functions and seeing what compiles. That way you can find it by process of elimination. I'd start with the last thing you changed since you last successful compile.
 
   if(IsFractalLower() && WasDemarkerHigh()
   if(IsFractalUpper() && WasDemarkerLow()
 
FappingForex:

Hi, I can't seem to find the solution to this!! I've checked forums and stuff, but I can't find an answer to my problem.

I've made an attachment of my entire work. If you can help to make this better, please do! And then tell me of course =)

I just started learning MQL4 3 days ago and I'm still experimenting, but have been so frustrated with this last error!


In a lot of code coming from old C programmers, you will see code like this:

if (condition){

// do something

}

Notice the brace is at the end of the if condition. This situation you are in is the reason why I like to code like this:

if (condition)
{
   // do something
}

You can see clearly that I have matching curly braces under the condition that owns it. So when you get to doing a lot of this:

   if ((IsGreenCandle(Open[3], Close[3])) && (IsGreenCandle(Open[2], Close[2])) && (IsRedCandle(Open[1], Close[1])))
   {
      if (Open[1] > Close[2] && Close[1] <= Open[2])
      {
         if ((Open[1] - Close[1]) > ((Open[2] - Close[2])*2))
         {
            if ((Open[1] - Close[1]) > 5*PipPoints)
            {
               return (true);
            }
         }
      }
   }

It is real easy to see just where you lost that curly brace. If it is more than a screen full then you can trace each curly brace by resting your mouse in the known location of each opening brace and scroll the page with up and down to find it's matching close curly brace. If you come to a non match, boom, you found your problem.

A second method of preventing this problem is to compile frequently and save smalll changes. Build a condition, compile it, build a condition, compile it. If you build a condition and it does not compile, you know the problem was in the last condition you built. Although copy and paste of other code can cause this issue as well. The point to this one is to track what you modified last and verify the code has matching braces and paranthesis before moving on to add more code. This is also why it is handy to keep your functions small. More little functions will actually help you to reduce the number of problem areas for the missing brace, bracket or paranthesis.

 

Alternatively you can open the whole file in an editor that is able to highlight matching braces.


There are also editors that are able to format your source code, if one of the curly braces is missing this will immediately mess up the formatting at the place where the closing brace should have been.

If I get source code from somebody else that does not meet my favored formatting rules the first thing I do is to run it through the AStylePlugin of the JEdit text editor.


@LEHayes: I don't believe the bracing style you propose should be recommended. It might help in some rare cases to find a missing brace but the same is true with other styles too and it can also be achieved by running it through an automatic formatter, IMHO it has more disadvantages than advantages and its consumption of screen space that are filled with almost empty lines is enormous. I usually recommend using the 1TBS (aka K&R or "west coast") style which is compact and also always leads to the closing brace of any block without having any opening braces in the way. It is also the most commonly used style in the Java world (and rightly so).

 
You can also try my basic syntax checker ref. https://www.mql5.com/en/code/9852
 
LEHayes:


It is real easy to see just where you lost that curly brace. If it is more than a screen full then you can trace each curly brace by resting your mouse in the known location of each opening brace and scroll the page with up and down to find it's matching close curly brace. If you come to a non match, boom, you found your problem.


If it was that curly brace He wouldn'n get an error:

 
I only edit with notepad2 (with code folding option) The C++ highlighting shows almost like the SRC button. Putting the cursor on a paren or brace (like from a search) highlights the corresponding closing one. Quick and easy. (^L) loads the file in to the compiler.
 

Here is a nice formatter that formats in real time while you are editing: http://universalindent.sourceforge.net/

 

Thanks guys! It all really helped, especially qjol who pinpointed the error, however, I just received more problems... I give up. Lol, I need to actually study for something else. I really want to learn more, but as of right now, it's too much.

I actually found some codes on the internet and thought I give it a try to see if I can make it work. As you can see, I didn't do a very good job... I wanted to see if I can work with it to improve my MQL4 learning process. But I just can't make this work =(. I fused it with the basics that I know from this manual.

My problem now

With the actual code,

I attached the file of the codes I found. As of right now, the StopTime, TakeProfit, StopLoss, Trailing Stop, and probably more, but I'm not too sure.. The problem is that the StopTime = 1 seems to be actually equal to 0.5. I mean I can simply just put 2... anyway, the TakeProfit = 25 is translated into 1.5 pips... The others are the same. I can basically do the math for them.

Another thing, I also want to put in Large and small MA and their respected shifts. The code has a MA already, but only one... =(

Thanks =) PLEASE HELP!! If you take a good look at it, it looks like a commercial EA. it's a very interesting code. I promise!

Files:
test3_1.mq4  22 kb
Reason: