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

 

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
 
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++!
 
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.
 
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
 

hellow friends how to fix this error?

 
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                                                            |...
 
Keith Watford:

Read the topic!

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

thank you sir

 
'do' - expressions are not allowed on a global scope   EXcuseme what this is? please help me
 
MANIGHORBANPOUR #:
'do' - expressions are not allowed on a global scope   EXcuseme what this is? please help me

read above.... you have exactly the same issue as already answered in this thread.

 
Paul Anscombe #:

read above.... you have exactly the same issue as already answered in this thread.

i don`t reallly anderstand and ican`t find topic this  about i need more support7


 

 
MANIGHORBANPOUR #:

i don`t reallly anderstand and ican`t find topic this  about i need more support7


 

The answer is already on this thread:

Keith Watford:

Read the topic!

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

Reason: