I need some help here, I'm a novice at building EAs and I don't know, what I don't know.
I'm using: MetaTrader4 version:4.00 Build 1090 (19May2017) and MetaEditor version: 5.00 Build 1601 (19May 2017).
I've built the following, very simple EA, and can't figure out why I keep getting errors when compiling.
8 Errors, 0 Warnings:
Line 23, Column 5, 'OnInit' - unexpected token
Line 1, Column 1, some operator expected
Line 25, Column37, ';' - unexpected token
Line 25, Column 4, 'PlaySound' - constant expression required
Line 24, Column 3, '{' - some operator expected
Line 26, Column 4, 'return' - semicolon expected
Line 26, Column 4, 'return' - expressions are not allowed on a global scope
Line 27, Column 3, ')' - expressions are not allowed on a global scope
8
You did not build this EA yourself, at least not entirely and you are not "Stuart Harris", are you? You have copy/pasted sections from other sources and then probably made some changes without actually knowing what you are doing.
You can't just mix old style code with the newer MQL4+ code structures and then hope that it all works.
You did not build this EA yourself, at least not entirely and you are not "Stuart Harris", are you? You have copy/pasted sections from other sources and then probably made some changes without actually knowing what you are doing.
You can't just mix old style code with the newer MQL4+ code structures and then hope that it all works.
Fernando Carreiro,
First of all I am Stuart Harris, Enoch is a name I sometimes use online. Secondly I've already admitted I am a novice and don't know what I am doing. I learned to write some code from the jimdandy site. I think that is all old style code. And I have been studying whatever I find in various forums trying to learn. I'm not understanding why it won't recongize OnInit, My referrence say that init or OnInit will both work. I have written this EA as an "audio only" alert and it compiles and runs just fine. But when I have it send an order suddenly it won't complie.
As for mixing old and new ... to me everything is new, I am learning. I'm very coachable and want to learn please help.
Fernando Carreiro,
First of all I am Stuart Harris, Enoch is a name I sometimes use online. Secondly I've already admitted I am a novice and don't know what I am doing. I learned to write some code from the jimdandy site. I think that is all old style code. And I have been studying whatever I find in various forums trying to learn. I'm not understanding why it won't recongize OnInit, My referrence say that init or OnInit will both work. I have written this EA as an "audio only" alert and it compiles and runs just fine. But when I have it send an order suddenly it won't complie.
As for mixing old and new ... to me everything is new, I am learning. I'm very coachable and want to learn please help.
I will start with the first error:
extern int TrailingStop=0; extern int Slippage=3; // <-- Missing semicolon //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit()
It is not recognising the "OnInit" because you are missing a ";" after the "Slippage" declaration.
However, most of your errors are due to you not understanding the general structure and syntax of the coding language. Unless you learn and understand that first, you are going to have many more errors as you keep adding to your code.
So first, dedicate some time to first learning how the code is supposed to be structured and its syntax. Read the documentation and also look into "C" coding as an alternative to help you understand how it is structured.
PS! Also use "void OnTick()" instead of "int start()" which is the old obsolete code style.
The old tutorial that is still available on the MQL4 site is now completely outdated and obsolete.
There are also video tutorials on Udemy, but have no idea if they are any good.
As for books, have a look at these two suggestions:
- 2017.08.03
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I need some help here, I'm a novice at building EAs and I don't know, what I don't know.
I'm using: MetaTrader4 version:4.00 Build 1090 (19May2017) and MetaEditor version: 5.00 Build 1601 (19May 2017).
I've built the following, very simple EA, and can't figure out why I keep getting errors when compiling.
8 Errors, 0 Warnings:
Line 23, Column 5, 'OnInit' - unexpected token
Line 1, Column 1, some operator expected
Line 25, Column37, ';' - unexpected token
Line 25, Column 4, 'PlaySound' - constant expression required
Line 24, Column 3, '{' - some operator expected
Line 26, Column 4, 'return' - semicolon expected
Line 26, Column 4, 'return' - expressions are not allowed on a global scope
Line 27, Column 3, ')' - expressions are not allowed on a global scope
8