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.
- Timeframes: one candle = one minute (M1) up to one day (D1).
- Symbol and timeframe of the chart.
- Candles: open, high, low and close of each period.
- Indicator drawn on the price, here a moving average.
- Price scale with the current price.
- Time scale, in the platform's server time.
- Indicator window below the chart, here RSI with levels 70 and 30.
Ready to try it on a real or demo account?
Partner link · trading carries a high risk of loss
Step 1: Open the Data Folder
MetaTrader does not keep your programs in its installation folder. It keeps them in a separate Data Folder.
- Open the terminal.
- Click File → Open Data Folder.
- 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:
- Indicators: custom indicators
- Scripts: scripts that run once on a chart and then stop
- Experts: Expert Advisors (see Expert Advisors)
- Include and Libraries: supporting files that some indicators need
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
- Open the Navigator window (View → Navigator, or Ctrl+N).
- Right-click Indicators and choose Refresh. You can also restart the terminal.
- Your indicator appears in the list. Drag it onto a chart, or double-click it.
- 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:
- Click Tools → MetaQuotes Language Editor, or the IDE button on the toolbar.
- Open the source file from the Indicators folder in the MetaEditor Navigator.
- Click Compile.
- 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:
- Compiled-only files hide their code. An .ex4 or .ex5 file cannot be checked. Prefer source code you can read.
- DLL imports. Some programs ask for permission to load DLL files, which are outside programs that can do almost anything on your computer. Leave Allow DLL imports switched off unless you trust the author and know why the program needs it.
- Web requests. Code that sends data to outside addresses could leak account details.
- Repainting. Some indicators change past signals after the fact, so their history looks better than it really was.
- Sales claims. Files sold with promises of steady profit are a warning sign. No indicator removes market risk.
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
- The Code Base and Market on MQL5.com, which you can also reach from the terminal. Code Base items usually include source code.
- Authors who publish readable source code and explain what each input does.
- Code you write yourself in MetaEditor.
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.
