My First EA

Learn to develop an Simple EA

We will start our first material by creating a simple EA that displays our account information.

What we will learn are :
a. Retrieve data from Input
b. Convert Data Type Numbers to String
c. String Processing
d. Displaying Data

Create New EA

New EA

Next >
Expert Advisor (template)

Next >
EA Properties

click Next > to Finish.

Code


//+------------------------------------------------------------------+
//| MyFirstEA.mq4 |
//| Copyright 2018, AutoBotFx |
//| https://AutoBotFx.pro |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AutoBotFx"
#property link "https://AutoBotFx.pro"
#property version "1.00"
#property strict
//--- input parameters
input string namaEA="My First EA";
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---

//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---

}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---

}
//+------------------------------------------------------------------+

Retrieves Account data and displayed
Putting this code in OnInit ()

int OnInit()
{
//---

string namaAkun = "";
int noAkun = 0;
string server = "";
string namaBroker = AccountCompany();

namaAkun = AccountName();
noAkun = AccountNumber();
server = AccountServer();
string str = StringConcatenate("EA : ", namaEA, "\nBroker : ", namaBroker, "\nName : ", namaAkun, "\nAccount # : ", IntegerToString(noAkun), "\nServer : ", server);

Alert (str);

//---
return(INIT_SUCCEEDED);
}

Compile EA
Make sure there are no errors
and we can continue the EA testers by pressing F5 to run EA.
compile EA

Result
result of my first EA

About the Author

Leave Comment

Your email address will not be published. Required fields are marked *