2. Let’s open Meta Editor!

Bookmark and Share

1. Expert Advisor's composing screen

The function to produce your own Expert Advisor is automatically installed when you install MetaTrader.

To go to the composing screen, you have to open the normal Meta Trader. Then right-click the Expert Advisor at Navigator(left side) and select “Create.”

Expert AdvisorからCreateを選択

 

The screen should be something like this. In fact, this software is adjunct to MetaTrader and called MetaEditor. This is something different from MetaTrader itself. (Just like the relationship between Office and Visual Basic.)

In the wizard displayed at the beginning, you have to choose what kind of program you want to make. If you are going to make an automatic trading program, please select “Expert Advisor” at the top. In the next screen, you will enter “General Properties” but, at this moment, only the minimum of the information will be enough.

We’ll make a sample program at first. Please enter “Sample” in “Name” and “Your Name” in “Author”.

2. Making a program with Meta Editor

MetaEditor 新規作成

So, is this the kind of page displayed? This will be the basis for making a new program with Meta Editor. Simply said, this is something like a foundation before constructing a building.

Briefly explaining, a line starting with a double slash like this:

  1. //

is called "comment out" and has no meaning as a program. This means that for the machine, there will be no change whether this line exists or not. Usually, it is used to insert a note about the programming code so that people can understand more easily when they see it.

  1. int init() {
  2.   // The program will be written here.
  3.   return(0);
  4. }

There is a part like this at the top. (Supplemented and abbreviated for convenience) This is the part that will be performed at the beginning when you run the program. For example, we often write a function like “check if the account number is right” here.

  1. int deinit() {
  2.   //  The program will be written here.
  3.   return(0);
  4. }

Afterwards, there will be a part like this. This is a part that will be performed when you end the program. This is not used much.

  1. int start() {
  2.   // The program will be written here.
  3.   return(0);
  4. }

This last part is the most important of all. This part will be performed each time when there is a movement in price. It will be the fundamental component for continuously trading automatically.

We will write a process like, ”Comparing the average movement of the previous 5-hours to the last 1-hour ...” here.

up