I still use the build 509 compiler, where the "unbalanced left parenthesis" error can be a real nuisance, by forcing the programmer to search the entire source program to find the rogue bracket. Especially if your EAs have several hundred lines of code. If this is no longer a problem in build 600+, then this app might still be useful for quickly finding unmatched round brackets, square brackets, curly braces or angle brackets in your code. Otherwise, ignore this post.
Unzip and install this little program in your Experts or Indicators folder. Then run it, and select the file (e.g. MyEA.mq4) you want it to search, and the left character (round bracket, square bracket, left curly brace or angle bracket) you want it to report on. Click OK, and it will generate a file (e.g. MyEA.out) in the same folder as the .mq4 file, that highlights any mismatches. The output file prints 5 additional columns to the left of the source code:
Unzip and install this little program in your Experts or Indicators folder. Then run it, and select the file (e.g. MyEA.mq4) you want it to search, and the left character (round bracket, square bracket, left curly brace or angle bracket) you want it to report on. Click OK, and it will generate a file (e.g. MyEA.out) in the same folder as the .mq4 file, that highlights any mismatches. The output file prints 5 additional columns to the left of the source code:
- Column 2: the number of left brackets in each line of code
- Column 3: the number of right brackets in each line of code
- If the number of left brackets does not equal the number of right brackets, three asterisks (***) are printed in Column 1, highlighting a possible cause of the problem
- Column 4: this is a running total of the excess of left brackets over right brackets throughout the program, positive if left > right, and negative if right > left. This is useful for finding matching braces that start/end blocks of code (it should always return to 0 at the end of each function/subroutine)
- Column 5: line/row number.
As always, the app is offered free on an 'as is' basis. Download and use at your own risk.
Below is a code fragment from an EA that I wrote, after it's been annotated by the app. You can see how it has highlighted the missing bracket in line #371.
Inserted Code
Diff ( ) +/- Line Program code 1 1 354 for (oper=OP_BUY; oper<=OP_SELL; oper++) { 1 1 355 buy_ok = (oper==OP_BUY); // default = assume true until proven otherwise 2 2 356 if (StringFind(PullbackRequirements,"P")>=0 && High1>=High2) buy_ok = false; // required pullback means lower high 2 2 357 if (MA7>0 && Low1>MA7) buy_ok = false; // required pullback to EMA(7) 3 3 358 if (MA7>0 && MA20>0 && MA7<=MA20) buy_ok = false; // MA alignment, EMA(7) must be higher than EMA(20) 3 3 359 if (MA20>0 && MA50>0 && MA20<=MA50) buy_ok = false; // MA alignment, EMA(20) must be higher than EMA(50) 3 3 360 if (StringFind(EntryType,"M")>=0 && Close1<=Open1) buy_ok = false; // not the required momentum (green) candle 3 3 361 if (StringFind(EntryType,"R")>=0 && Close1>=Open1) buy_ok = false; // not the required pullback/reversal (red) candle 362 1 1 363 sell_ok = (oper==OP_SELL); // default = assume true until proven otherwise 2 2 364 if (StringFind(PullbackRequirements,"P")>=0 && Low1<=Low2) sell_ok = false; // required pullback means higher low 2 2 365 if (MA7>0 && High1<MA7) sell_ok = false; // required pullback to EMA(7) 3 3 366 if (MA7>0 && MA20>0 && MA7>=MA20) sell_ok = false; // MA alignment, EMA(7) must be lower than EMA(20) 3 3 367 if (MA20>0 && MA50>0 && MA20>=MA50) sell_ok = false; // MA alignment, EMA(20) must be lower than EMA(50) 3 3 368 if (StringFind(EntryType,"M")>=0 && Close1>=Open1) sell_ok = false; // not the required momentum (red) candle 3 3 369 if (StringFind(EntryType,"R")>=0 && Close1<=Open1) sell_ok = false; // not the required pullback/reversal (green) candle 370 *** 3 2 +1 371 if (PostDiagnosticInfo >= 3) dump(NumberToStr(oper,"1' about to test buy_ok/sell_ok'"); // Post Diagnostic Info !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2 2 +1 372 if (!buy_ok && !sell_ok) return(0); +1 373 +1 374 order_type = -1; // set default values: -1 = no order; 0=BUY; 1=SELL; 2=BUY LIMIT; 3=SELL LIMIT; 4=BUY STOP; 5=SELL STOP +1 375 dir = 0; // order polarity: 0 = no order; +1 = buy order; -1 = sell order +1 376 int magic = 0; +1 377 color arrow_color = CLR_NONE;
Attached File(s)
Find 'unbalanced left parenthesis'.zip
318 KB
|
817 downloads