How to use Meta Editor for Meta Trader 4 (MT4)

Here you will learn the basics of using the MT4 terminal. You will find all the steps below in the proper order.

We have only included things that will be of the greatest importance to you. There are many minor details omitted to save time space.

Everything here covers what you MUST KNOW in order to use MT4.

May we suggest, just reading slowly and enjoying the learning process, so that all of the information soaks right in and is always remembered in the future.

Step 1: Open Meta Editor

To open Meta Editor, you can Click on your "Start Menu", then "All Programs". Locate XMMT4 or MT4 file folder and click on it.

Now click on MetaEditor.

There! Your in!

You can also, use your MT4 terminal to get into MetaEditor...

Just "Right Click" on the file you want to open, in the "Navigator" and Click "Modify". You can also click "Modify Expert" from the "Strategy Tester" or you can Click "Tools" at the top and Open "MetaQuotes Language Editor". They will all open the Meta Editor.

NOTE: Sometimes MetaEditor will be slow opening. Sometimes you may have to press it a couple of times. This happens when using a computer that has low memory.

After it has opened, you should now see this...

If your MetaEditor "Navigator" is not open, click "View" and then click "Navigator".

You should see a list of folders on the left, like in the picture above.

If your "ToolBox" is not open, make sure you open it as well from "View" in the menu bar, as well(Toolbox is where you will be alerted of errors in code).

Step 2: Using MetaEditor

Now, that you are in MetaEditor, you can begin using it!

If you would like to create an Expert Advisor from scratch, you can click on "NEW" in the upper left hand corner.

If you click on "Experts" in the "Navigator", you will see a sample EA called MACD_Sample.MQ4 . Feel free to open it and snoop around the code a bit to get familiar with it.

Download our FREE expert advisor template

The code in that sample is a little overwhelming to a newcomer, so we have included a free sample Expert Advisor for you to learn on. It's coding is as simple as you are going to find and it has explanations and tips along the way.

Just, click the download link below and a new tab or window will open.

Then copy and paste the code into the macd_sample, replacing its current code.

Click "save as" and name it whatever you like.

You Now have it at your disposal to learn and to make new Expert Advisors from.

After you have saved it under a new name, you now need to press the "Compile" button. If you don't press this button the EA will not be available in the MetaTrader 4 terminal or Strategy Tester.

NOTE: Every time you make changes to an Expert Advisor, simply hit the "Compile" button, instead "save".

Step 3: Compiling and fixing errors

Congratulations! You have made it this far! Soon you will have a working auto trader!

As, mentioned right before this step, be sure to always compile files instead of saving them. Compiling compiles and saves them.

It also checks for errors, which is extremely important.

An autotrader will not run if there are any errors, so that is why compiling and checking errors is a MUST.


In MetaEditor you will be notified in the toolbox of errors and warnings. An EA can and will still run with warnings, but cannot and will not run with errors.

For example, simply open your new file from "Template.mq4" and where it says "Extern int Period" change it to Period1...

The picture below shows where this is talking about...

After you have changed this to Period1 press the "Compile" button.

The result will be an Error in the "toolbox", just like the one in the picture below...

Next, "Double Click" on the error. This will take you to the line of code where the error is.

The picture below shows this, as well.

So, what is this line of code telling us?

It is telling us, that there is an "undeclared identifier" named "period".

Since we changed the code at the top of the page, it has now effected this line of code. This line of code was connected to the code that we changed.

It is a line of code where the "RSI INDICATOR" is created. "Period" is the period we are using for the "RSI INDICATOR" settings.

The line of code at the top, that we changed was to tell this line of code what number to use for the "period" part of the indicator setting. Since it now says "period1", there is nothing for the RSI code to cross reference to, so it is like a "dead link" now.

You will understand more on indicator code later, but for now you have 3 choices to fix this code...

  1. Change the code we changed, back from "period1" to just "period", so that it can sync with this error line of code again...
  2. Change the "RSI INDICATOR" from "period" to "period1", so that it can sync up with the top code.
  3. Remove "period" from the error line of code and replace it with a number to represent the time period you want the "RSI INDICATOR" to operate on.

    Such as: double RSI1CUSTOM=iRSI(NULL,0,14,applied_price,barshift);

As you can see there can be several ways to fix an error, the key is knowing why the error is there in the first place.

As demonstrated in this coding error example, you saw that sometimes the line of code showing an error, may not necessarily be the root cause of the error itself.

You will need to become familiar with the basic framework of an Expert Advisors code in order to know what to do, when an error comes up.

The hope is that after reading through the MQL4 BASICS material, that you will be fully equipt with the knowledge and skills to create and edit your own, profitable autotraders.

NEXT UP --->

Understanding the framework of an expert advisor