Expert Advisors in MetaTrader 4 – MQL4 for Complete Beginners Tutorial Part 21

In this tutorial we will introduce a new type of program in MQL4 – expert advisors.

In essence, expert advisors (EA’s) are your Forex robots. There are some key differences between expert advisors and scrips, and we will discuss them in this tutorial.

Also, we will create our first test EA and see how it works in the MetaTrader 4 trading terminal.

Source code below video. Important: remember that this is no longer a script – it’s an expert advisor now, and therefore you need to select the associated option in when using the MetaEditor Wizard.

Enrol in the full course here: https://www.forexboat.com/learn-mql4


//+------------------------------------------------------------------+
//| MyFirstEA.mq4 |
//| Copyright 2014, ForexBoat |
//| http://www.forexboat.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, ForexBoat"
#property link "http://www.forexboat.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
Alert("Expert Advisor has been launched");

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

}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
Alert("Your new Bid price is: " + string(Bid));

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

 

What are you waiting for?

START LEARNING FOREX TODAY!

share This:
Muhammad Awais

Leave a Reply

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

What are you waiting for?

START LEARNING FOREX TODAY!

as seen on: