'if' - expressions are not allowed on a global scope

Bassey Edet
1338
Bassey Edet  

Hi Coders,

I have issues with this compile error,

 

'if' - expressions are not allowed on a global scope

 

see attachment added 

 

can any one help?

Files:
Error_Code.png  193 kb
Carl Schreiber
Moderator
12093
Carl Schreiber  
Bassey Edet:

Hi Coders,

I have issues with this compile error,

 

'if' - expressions are not allowed on a global scope

 

see attachment added 

 

can any one help?

Count your brackets "(" - ")" and "{" - "}". If you code is too long I would use notepad++!
Fernando Carreiro
6432
Fernando Carreiro  
Bassey Edet: Hi Coders, I have issues with this compile error, 'if' - expressions are not allowed on a global scope, see attachment added. can any one help?
All executable code must be within a function (or class methods), such as the Event Handling functions. You cannot have "if()" statements outside of functions in the "global scope".

If it is indeed within functions, then check for mismatching brackets and braces, just as @Carl Schreiber has suggested.
Mladen Rakic
222262
Mladen Rakic  
Bassey Edet:

Hi Coders,

I have issues with this compile error,

 

'if' - expressions are not allowed on a global scope

 

see attachment added 

 

can any one help?

Starting from line 264 (and quite a lot more code after that) your code is not a part of any function.
Move that part to it's logical place within the function where it is supposed to do the desired job or, as Carl told : check all your brackets for a missing one
Chalin Saranga Jayathilake
4909
Chalin Saranga Jayathilake  

hellow friends how to fix this error?

Keith Watford
Moderator
31035
Keith Watford  
Chalin Saranga Jayathilake:

hellow friends how to fix this error?

Read the topic!

Move your code so that it is inside a function (OnInit() , OnCalculate() or OnTick() )

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
Chalin Saranga Jayathilake
4909
Chalin Saranga Jayathilake  
Keith Watford:

Read the topic!

Move your code so that it is inside a function (OnInit() , OnCalculate() or OnTick() )

thank you sir