Yikes! You are mixing apples, oranges, carrots, tomatoes, turnips and anything else under the sun!
Before considering coding an EA, you need first decide which language you want to learn and use (either MQL4 or MQL5), and after that, at least learn the structure of the functionality of an EA by looking at examples and reading the documentation.
Currently, your code mixes elements from MQL4 (old style), MQL4+ (new style) and MQL5.
- ".mq5" extension - meaning you are targeting MQL5 for MetaTrader 5
- #include <Trade\Trade.mqh> - Using MQL5 classes for Trading Operations
- init(), deinit(), start() - Old Style MQL4
- OnInit(), OnTick() New Style MQL4+ or MQL5
- OnTrade() - MQL5 (but has nothing to do with OnTick)
- iMA() - the way you are using it is MQL4 (not MQL5)
- etc.
Suffice to say, that as it stands now, there is no correct basic skeleton structure, on which to build on!
Yikes! You are mixing apples, oranges, carrots, tomatoes, turnips and anything else under the sun!
Before considering coding an EA, you need first decide which language you want to learn and use (either MQL4 or MQL5), and after that, at least learn the structure of the functionality of an EA by looking at examples and reading the documentation.
Currently, your code mixes elements from MQL4 (old style), MQL4+ (new style) and MQL5.
- ".mq5" extension - meaning you are targeting MQL5 for MetaTrader 5
- #include <Trade\Trade.mqh> - Using MQL5 classes for Trading Operations
- init(), deinit(), start() - Old Style MQL4
- OnInit(), OnTick() New Style MQL4+ or MQL5
- OnTrade() - MQL5 (but has nothing to do with OnTick)
- iMA() - the way you are using it is MQL4 (not MQL5)
- etc.
Suffice to say, that as it stands now, there is no correct basic skeleton structure, on which to build on!
How about some books? Have a look at the following post from another thread:
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2017.09.09 08:47
I think you should first concentrate on learning the basics of the language, its structure, its syntax, code layout and readability, etc.
Then learn about the various functions that are available, how they work and how to use them properly.
The code you provided, will not even compile, because you are basically mixing apples, oranges, tomatoes, carrots, and anything else that fits in the basket.
For example, the OrderSelect() function is for selecting a particular Order either by Index or by Ticket Number. It does not by itself return the number of Orders of a certain type.
So, before you even think about "professional account management", first you need to learn the language, by reading the documentation and researching the example code in the CodeBase.
If you want or prefer, you can even get yourself a good book and follow it from start to end:
How about some books? Have a look at the following post from another thread:

- 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
My adviser does not want to trade. It compiles without errors but for the love of me doesn't open or close a trade.
What an i doing wrong.
Take note this is my first attempt so i might have missed some functionality.
Any advise would be appreciated.