You lacks a lot of ;
For example after that
string CurrentSymbol=Symbol()
after each RefreshRates(), and after the latest "return"
Also this:
bool OrderSelect(ticket,SELECT_BY_TICKET);
and this:
for (CurrentSymbol)
has a totally wrong syntax.
Maybe you can start to read better your code (and command documentation for syntax) instead of asking for help.
There is so much wrong with your code that I wouldn't know where to start.
There are many examples in the Codebase and you should start by studying some of them carefully and make sure that you can understand what is happening.
Make sure that you study code which uses OnInit() and OnTick() instead of the outdated init and start.
-
#property strict int Open_High=iHighest(NULL,PERIOD_D1,MODE_HIGH,20,1),
Global and static variables work exactly the same way in MT4/MT5/C/C++.- They are initialized once on program load.
- They don't update unless you assign to them.
- In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants.
There is no default in
MT5 (or MT4
with strict which you should always use.)
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
- Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
external static variable - Inflation - MQL4 programming forum
- On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you
must handle 4066/4073
errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 -
if (CurrentSymbol!= //If symbol is not one of the following stop EA execution ("EURUSD", "GBPUSD", ⋮
Bogus. if(x!="a" && x!="b"…) -
for (CurrentSymbol)
Bogus. Perhaps you should read the manual. There is only one current symbol — Why do you need a loop?
Thanks for the help and the harsh words, I know I still have a long way to go.
I will definitely read through source code to get a better understanding, are there any other suggestions in terms of resources I can use to better understand syntax?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all I am new to coding in MQL4
I recently coded my first EA. After compiling several errors were returned due to syntax, that I managed to fix. However several errors still remain.
After searching the compilation errors, I am still left confused as to how they relate to the lines of code that have returned errors.
Any help in helping me understand/fixing this will be much appreciated.
Above is the code and i have attached a file containing the errors returned. Thanks