Unexpected end of program and unbalanced parentheses

To add comments, please log in or register
Bismark Tenkorang
265
Bismark Tenkorang  
I am a newbie learning how to develop an Expert Advisor but i keep getting these two errors when i debug. I really need help. Please find attach the Script.
Files:
BGL_FUND.mq4 19 kb
lippmaje
1041
lippmaje  
Bismark Tenkorang:
I am a newbie learning how to develop an Expert Advisor but i keep getting these two errors when i debug. I really need help. Please find attach the Script.

You can use the styler to fix the indentation of nested blocks (MetaEditor - Tools - Styler)

Scroll down until you see the function definitions start to skip right. This is not correct since function definitions always have to occur outside if blocks. So your missing brace is somewhere up from this point.

This is your code after application of Styler:

void prepare_symbols()
  {
// variable for temporary storage of a symbol name
   string name;
...
...
               if(atr>0 && atr<hideATRcents)
                 {
                  continue;
                 }
              }
           }

        }
     }



//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
   void OnDeinit(const int reason)
^^
  Badly indented function definition here, so check somewhere above for missing brace.

     {
      if(reason!=REASON_CHARTCHANGE)
        {
         ObjectsDeleteAll(0,exprefix);
John Davis
11938
John Davis  
Bismark Tenkorang:
I am a newbie learning how to develop an Expert Advisor but i keep getting these two errors when i debug. I really need help. Please find attach the Script.

Here is a good tip that I use till today to avoid this problem. Always, always, always create parentheses in pairs. If you write one "(" go ahead and write the other one ")", then just backspace and fill in the content. If you are using a bracket I usually create the ending bracket on the line below like this.

void SomeCoolFunction(){

}

or 

int DifferentCoolFunction()
{

return 0; <-- filled in later 
}

then I just place my cursor between the brackets and fill it with data.

Bismark Tenkorang
265
Bismark Tenkorang  
lippmaje:

You can use the styler to fix the indentation of nested blocks (MetaEditor - Tools - Styler)

Scroll down until you see the function definitions start to skip right. This is not correct since function definitions always have to occur outside if blocks. So your missing brace is somewhere up from this point.

This is your code after application of Styler:

I applied the Styler, Code looking much more properly arranged but the problem persist and where ever I put a parentheses creates more errors rather than the two i currently have. Thanks for your effort Lippmaje.

Bismark Tenkorang
265
Bismark Tenkorang  
John Davis:

Here is a good tip that I use till today to avoid this problem. Always, always, always create parentheses in pairs. If you write one "(" go ahead and write the other one ")", then just backspace and fill in the content. If you are using a bracket I usually create the ending bracket on the line below like this.

then I just place my cursor between the brackets and fill it with data.

I appreciate your effort to help John Davis. Thanks for the information.

lippmaje
1041
lippmaje  
Bismark Tenkorang:

I applied the Styler, Code looking much more properly arranged but the problem persist and where ever I put a parentheses creates more errors rather than the two i currently have. Thanks for your effort Lippmaje.

It looks like some code is missing in prepare_symbols(), because the body of the for loop ends with several 'continue;' without any more instructions.

void prepare_symbols()
  {
// variable for temporary storage of a symbol name
   string name;
...
...
               if(atr>0 && atr<hideATRcents)
                 {
                  continue;   <-- this means 'skip the rest of the loop body and go ahead with the next iteration'
                 }
  ????    but the loop body has no instruction left that could be skipped
              }
           }
        }
     }
     ^^ and the last brace does not close the function body which causes compiler errors

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
...
Bismark Tenkorang
265
Bismark Tenkorang  
lippmaje:

It looks like some code is missing in prepare_symbols(), because the body of the for loop ends with several 'continue;' without any more instructions.

It worked Lippmaje. Thank you very much. But i am having some other issue if you can help me rectify that. The prepare_symbols() function has to select stocks or instruments with  daily ATR > or = 50pips and also Spread < or = 50points(5pips). All other pairs which does not meet this criteria must not appear on my chat but unfortunately when i run the program i find some pairs which does not qualify to appear on my chart appear. Please find attach the current working script.
Files:
BGL_FUND.mq4 22 kb
lippmaje
1041
lippmaje  
Bismark Tenkorang:
It worked Lippmaje. Thank you very much. But i am having some other issue if you can help me rectify that. The prepare_symbols() function has to select stocks or instruments with  daily ATR > or = 50pips and also Spread < or = 50points(5pips). All other pairs which does not meet this criteria must not appear on my chat but unfortunately when i run the program i find some pairs which does not qualify to appear on my chart appear. Please find attach the current working script.

Add more details on this. What symbol fails to be discarded, time and date, the inputs you have used to define your criterion. Could be you just missed out a magnitude (500 instead of 50 like this).

To add comments, please log in or register