CFDs and forex are complex instruments and come with a high risk of losing money rapidly due to leverage. Risk disclosure

How to Install Custom Indicators in MT5 and MT4

This guide shows where custom indicator and script files go in MetaTrader, how to compile source code, and how to check a file before you run it.

Extrade Pakistan editorial team ·

On this page
  1. What a custom indicator is
  2. Step 1: Open the Data Folder
  3. Step 2: Copy the file to the correct folder
  4. Step 3: Refresh and attach
  5. Step 4: Compile source code in MetaEditor
  6. Security risks of unknown files
  7. Where to get code safely
  8. Frequent questions

What a custom indicator is

A custom indicator is a program written in MQL, the MetaTrader programming language. It draws lines, histograms or arrows on a chart in addition to the built-in indicators. MetaTrader 5 uses MQL5 and MetaTrader 4 uses MQL4. The two are not compatible, so an MT4 indicator will not run in MT5 and an MT5 indicator will not run in MT4. See MQL4 and MQL5 for the language differences.

Custom indicators come in two file types:

File type MT4 MT5 What it is
Source code .mq4 .mq5 Readable code that you can open, check and compile
Compiled file .ex4 .ex5 Ready-to-run program that you cannot read

If you only need the standard indicators that come with the platform, see Add indicators.

M1M5M15H1H4D11EUR/USD, H12341.08351.08471.08591.08711.0870508:0014:0020:0002:006RSI (14)70307
  1. Timeframes: one candle = one minute (M1) up to one day (D1).
  2. Symbol and timeframe of the chart.
  3. Candles: open, high, low and close of each period.
  4. Indicator drawn on the price, here a moving average.
  5. Price scale with the current price.
  6. Time scale, in the platform's server time.
  7. Indicator window below the chart, here RSI with levels 70 and 30.
Anatomy of a chart window. Drawn example, not a screenshot: layout and names differ between platforms and versions.

Step 1: Open the Data Folder

MetaTrader does not keep your programs in its installation folder. It keeps them in a separate Data Folder.

  1. Open the terminal.
  2. Click File → Open Data Folder.
  3. A file explorer window opens. Inside it you will see the MQL5 folder in MT5 or the MQL4 folder in MT4.

Use this menu every time. Several terminals on one computer each have their own Data Folder, and the menu always opens the correct one.

Step 2: Copy the file to the correct folder

Inside MQL5 (or MQL4) there are separate folders for each program type:

To install a custom indicator in MT5, copy the .mq5 or .ex5 file into MQL5\Indicators. To add a custom indicator in MT4, copy the .mq4 or .ex4 file into MQL4\Indicators. Scripts go into the Scripts folder in the same way.

Some downloads come with extra files. Put each extra file where the author's instructions say, usually in Include or Libraries.

Step 3: Refresh and attach

  1. Open the Navigator window (View → Navigator, or Ctrl+N).
  2. Right-click Indicators and choose Refresh. You can also restart the terminal.
  3. Your indicator appears in the list. Drag it onto a chart, or double-click it.
  4. Review the inputs in the window that opens, then click OK.

Scripts work the same way from the Scripts branch of the Navigator. Menu names can differ slightly between platform builds. If an item is not where this guide says, check the platform's built-in Help for your build.

To keep an indicator setup for later, save it as a template. See Templates and profiles.

Step 4: Compile source code in MetaEditor

A .mq5 or .mq4 file must be compiled before it can run. The terminal often does this on its own when it refreshes. If the indicator does not appear in the Navigator, compile it yourself:

  1. Click Tools → MetaQuotes Language Editor, or the IDE button on the toolbar.
  2. Open the source file from the Indicators folder in the MetaEditor Navigator.
  3. Click Compile.
  4. Read the Errors tab at the bottom of the window. If you see errors, the code may be written for the other platform or may need missing Include files.

A successful compile creates an .ex5 or .ex4 file next to the source file. For other problems, see MetaTrader errors.

Security risks of unknown files

An indicator is a program running on your computer next to your trading account. Treat unknown files with care:

Leveraged forex and CFD trading can lose money fast, and an indicator does not change that. Test any new tool on a demo account first, for example an MT5 demo account, and read Risk management.

Where to get code safely

Avoid files shared in chat groups or sent by strangers. If you use MetaTrader through any broker, install programs only from sources you can verify.

Frequent questions

Where is the Indicators folder in MT5?

Open File → Open Data Folder, then MQL5 → Indicators. In MT4 the path is MQL4 → Indicators.

Why doesn't my indicator appear in the Navigator?

Refresh the Navigator or restart the terminal. If it still does not appear, compile the source file in MetaEditor and read the error list.

Can I use an .ex4 indicator in MT5?

No. .ex4 files run only in MT4. You need an MQL5 version of the indicator. See MT4 vs MT5.

How do I install scripts in MT5?

Copy the file into MQL5\Scripts, refresh the Navigator, then drag the script onto a chart.

Is it safe to allow DLL imports?

Only for programs whose source and author you trust. DLL access gives a program wide control over your computer.

Can I test an indicator on past data?

Yes. You can view it in visual mode in the Strategy tester. Past results do not predict future results.

Related pages