
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
h
What part of Count your brackets "(" - ")" and "{" - "}" was unclear to you?
The question has been answered five (5) times.
We can't see your broken code.
Fix your broken code.
Just make sure you don't have anything like this in your code
You can see there's a conditional statement outside of any function.
And yes, make sure you have matching brackets. One misplaced bracket can give lots of error messages which often don't help tracking down the error.
please help me to correct this error 'for' - expressions are not allowed on a global scope
also find the code where this error is occurs
Please don't post code with so much white-space. It makes it hard to read.
Every second line was empty, so I've edited your post and removed the extra white-space in your code.
In MQL, all logical code must be inside a function block. Only variable declarations are allowed in the global scope.
Was your code generated by ChatGPT?
Do you understand the basics of coding in C/C++ like languages?
Leaning the basics will help you immensely.
i don`t reallly anderstand and ican`t find topic this about i need more support7
You can't just put it in the global scope meaning it must be in the OnTick{ if something } function or somewhere.
Or within another function you created where it returns a value or bool or something such as MYfunction() { {if(0) Print("OK);} etc or some such thing.
You can't just throw it in there at the beginning or end of your code or even after the last } bracket. This would take you back to global scope again and MQL4 does not want to see this.
Remember these closing brackets { } start and stop a control of things. { bracket gets read, } then returns control to wherever it came from. Could be the previous { bracket or back to global scope.
Remember the code reads top to bottom and the bracket } ends your function control to giving control back to global scope or a previous controlled function or could just end. Then it reads the code continuing down giving or taking control to and from global scope, to functions to other functions and back again.
If your brackets release control back to global scope you have to do something else or write a function. You can't just write if / comparison codes in there. Global doesn't want to see this.
It keeps going until it reaches another Function and then exits/returns control back to global again or back to a previous control bracket etc.
Read the MQL4 book to see some illustrations at the very beginning of the book you will see it there too as well as the information that others posted.
Hope this helps.