 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
So, in the previous article we called the contextual menu of the «Navigator» window of the group «Expert Advisors» and chose the menu item «Create». As a result of a window appeared in which we will have to choose the type of the object we want to create (see picture 1).
|
|
Picture 1. Select the type of object which we want to write in the MetaQuotes Language 4
|
|
We are interested in creating an Expert Advisor, that’s why we choose the item «Expert Advisor». Then we press «Next».
In the next window (picture 2) we will set parameters of the new Expert Advisor:
- Name — the name of the Expert Advisor (the file will be assigned the same name with extension *.mq4;
- Author — the author of the Expert Advisor;
- Link — the address of the author’s web-site;
- Parameters — parameters of the Expert Advisor which can be changed later when the Expert Advisor is applied to a chart;
|
|
Picture 2. Expert Advisor settings adjustment
|
|
Let’s set a parameter for training purpose. For example, MAPeriod. For this we press the button «Add» and customize each field of the parameter:
- Name — the name of the parameter (in our example MAPeriod);
- Type — the type of the parameter;
- Initial value — the initial value.
Parameters can be of the following types:
- int — integer number (from -2147483648 to 2147483647);
- bool — logical type (either false, or true );
- datetime — the date and time (in format D’YYYY.MM.DD HH:MM:SS’);
- color — color (I will give an account of the format in the following articles);
- double — real number (-1.7 × 10-308 to 1.7 × 10308, accuracy — 15 significant figures);
- string — a line in double quotes (for example, «this is a line»).
We press the button «Ready». As a result we will see a skeleton of the code of our first Expert Advisor:
//+------------------------------------------------------------------+
//| My First Expert.mq4 |
//| Copyright c 2006, Andrey Vedikhin |
//| http://www.vedikhin.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Andrey Vedikhin"
#property link "http://www.vedikhin.ru"
//---- input parameters
extern int MAPeriod=0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Next article: "The structure of an Expert Advisor. Special functions"
|
|
|
|
|
|
 |
|
|
|
|
|
|
|
|
|
|
|
|
|
+7 (495) 710-76-76
|
© 1998—2008 «Alpari» |
|