---
title: "MT4 custom indicators: install, inspect and run them safely · CloudSat"
description: "How custom indicators work in MetaTrader 4: file types, where they go, compiling from source, buffers and iCustom, repainting checks and a lighter terminal."
url: https://cloudsat.io/learn/mt4-custom-indicators-install-and-test
updated: 2026-11-18T12:00:00Z
source: CloudSat (https://cloudsat.io/). Prices in USD.
---

[Trading and crypto](https://cloudsat.io/learn/topic/trading)

# MT4 custom indicators: install, inspect and run them safely

How custom indicators work in MetaTrader 4: file types, where they go, compiling from source, buffers and iCustom, repainting checks and a lighter terminal.

CloudSat team November 18, 2026 7 min read

MetaTrader 4 ships with 30 built-in indicators and nine timeframes, by MetaQuotes' own count. Everything beyond that is a custom indicator: a small MQL4 program that computes a value for each bar and hands it to the chart. Knowing how those programs are stored, compiled and read by Expert Advisors lets you install them cleanly, check them before you trust what they draw, and keep a terminal responsive on a server. Nothing here rates indicators as good or bad; this is about how they work.

## What a custom indicator is

A custom indicator calculates values and stores them in buffers, numbered arrays that the terminal draws as lines, histograms or arrows. It cannot place trades: MQL4 reserves trade functions for Expert Advisors and scripts. An EA can, however, read an indicator's buffers and act on them, which is how most automated MT4 setups use indicators.

You will meet five file types:

| Extension | What it is | Notes |
| --- | --- | --- |
| `.mq4` | Source code | Readable; compile it in MetaEditor |
| `.ex4` | Compiled program | What the terminal runs; cannot be read back as source |
| `.mqh` | Include file | Shared code some sources need to compile |
| `.tpl` | Chart template | Saves a chart's indicators and their settings |
| `.set` | Saved inputs | Loaded from the **Inputs** tab of the properties dialog |

## Install one in five steps

1. In MT4, open **File > Open Data Folder**. Indicators belong in this data folder, not in the program folder under Program Files.
2. Open `MQL4\Indicators` and copy the `.ex4` or `.mq4` file there. Include files go to `MQL4\Include`, templates to `templates`.
3. In the **Navigator** window, right-click **Indicators** and choose **Refresh**, or restart the terminal.
4. Drag the indicator onto a chart, or use **Insert > Indicators > Custom**.
5. Set the **Inputs**, **Colors**, **Levels** and **Visualization** tabs, then save the chart as a template so you never repeat the setup.

**Visualization** decides on which timeframes the indicator is drawn, which helps when a template is shared between a one-minute and a daily chart.

## Compile from source when you can

If you have the `.mq4` file, open it in MetaEditor (press F4 in the terminal) and compile it with F7. The **Errors** tab lists problems; warnings do not stop compilation but are worth reading, and `#property strict` at the top makes the compiler stricter about sloppy code.

Source code matters for a second reason: you can see what the program does. Search it for three things before running it:

- `#import` followed by a `.dll` name: the indicator calls native Windows code.
- `WebRequest`: it talks to the network.
- `FileOpen`: it reads or writes files.

None of these is wrong in itself, but an indicator that only draws a moving average needs none of them. A bare `.ex4` file is a black box by comparison. Keep **Allow DLL imports** switched off, both under **Tools > Options > Expert Advisors** and on the indicator's **Common** tab, unless a tool you have vetted needs it. A DLL runs with the same rights as your Windows user.

## Buffers, shift and iCustom

An Expert Advisor reads another indicator through `iCustom`. Its parameters are the symbol, the timeframe, the indicator's name relative to `MQL4\Indicators`, the indicator's inputs in their declared order, then `mode` (the buffer index) and `shift` (how many bars back):

```mql4
// Read buffer 0 of "MyChannel" (inputs 20 and 2.0) on the last closed bar
double upper = iCustom(NULL, 0, "MyChannel", 20, 2.0, 0, 1);
if(upper == EMPTY_VALUE)
   return;   // the indicator drew nothing on that bar
```

The `shift` argument is where many automated rules go wrong. Shift 0 is the bar still forming, and its value changes with every tick until the bar closes. A rule that reads shift 0 can fire and un-fire several times inside one bar. Reading shift 1, the last closed bar, gives a value that no longer moves, at the cost of acting one bar later.

Inputs you leave out fall back to their defaults, so an EA that omits them silently uses whatever the indicator's author chose. Pass every input explicitly.

## Check for repainting before you trust a signal

A repainting indicator changes values on bars that have already closed. The chart history then looks cleaner than anything the indicator could have shown in real time. Some tools repaint by design: a zigzag redraws its last leg as prices move, and a fractal is confirmed only after two more bars. Others repaint because their code reads data from bars that come after the one being calculated.

A simple check needs no code:

1. Attach the indicator to a live chart on a short timeframe.
2. When it draws a signal, note the bar's time and the value, or take a screenshot.
3. Come back twenty bars later and compare.

If the source is available, look for loops that read `Close[i-1]` or `iHigh(NULL, 0, i-1)` while calculating bar `i`. MT4 numbers bars from the newest (0) backwards, so `i-1` is a later bar: on history, that is a look into the future.

## Keep a terminal light on a server

Every incoming tick makes the terminal recalculate the indicators on every open chart. A well-written indicator recalculates only the bars that changed, using the `prev_calculated` value the terminal passes in:

```mql4
int OnCalculate(const int rates_total, const int prev_calculated,
                const datetime &time[], const double &open[],
                const double &high[], const double &low[],
                const double &close[], const long &tick_volume[],
                const long &volume[], const int &spread[])
{
   // First call: the whole history. Later calls: new bars plus the forming bar.
   int limit = (prev_calculated == 0) ? rates_total - InpPeriod - 1
                                      : rates_total - prev_calculated;
   for(int i = limit; i >= 0; i--)
      Buf[i] = iMA(NULL, 0, InpPeriod, 0, MODE_SMA, PRICE_CLOSE, i);
   return(rates_total);
}
```

Older indicators often loop over the whole history on every tick. One of them is harmless; a dozen across twenty charts keeps a CPU core busy. Lower **Max bars in chart** under **Tools > Options > Charts**, close charts nobody watches, and keep one template per setup.

On a server, an indicator that feeds an EA must run in the same terminal as the EA. Copy your `MQL4\Indicators` folder and templates from the old data folder to the new one, using the same terminal build. On CloudSat, the [MetaTrader 4 one-click app](https://cloudsat.io/apps/deploy-metatrader4) puts the terminal on a Windows server you reach over Remote Desktop, so your charts and EAs keep running after you disconnect.

## MT4 or MT5 indicators?

The two platforms do not share binaries: an `.ex4` file does not run in MetaTrader 5, and an `.ex5` file does not run in MT4. MQL5 also reads indicators differently, through a handle and `CopyBuffer` rather than one `iCustom` call per value, so porting means rewriting. MetaQuotes lists 38 built-in indicators and 21 timeframes for MT5. Use the platform your broker supports, and the [moving averages guide](https://cloudsat.io/learn/moving-averages-sma-ema-wma-explained) covers how MT4's built-in averages are calculated.

## Where indicators come from

MetaQuotes runs a free Code Base, where indicators usually come with source code, and a Market for paid tools, which arrive compiled and licensed. Forums and vendors fill the rest. Treat any claim that an indicator "wins" with suspicion: an indicator is arithmetic on past prices, and no formula guarantees what comes next.

## FAQ

### Why does my indicator not appear in the Navigator?

It is usually in the wrong folder: it must be in `MQL4\Indicators` under the data folder that **File > Open Data Folder** opens. Refresh the Navigator after copying. A file built for MT5 (`.ex5`) never appears in MT4.

### Can a custom indicator place trades?

No. Trade functions are available to Expert Advisors and scripts only. An EA can read the indicator through `iCustom` and trade on it.

### Do custom indicators slow MetaTrader 4 down?

Each one recalculates on incoming ticks, so heavy indicators on many charts add up. Indicators that use `prev_calculated` cost far less than ones that recompute the full history every time.

### Do indicators keep working when I close Remote Desktop?

Yes, as long as you disconnect rather than sign out. Signing out closes the terminal and everything running in it.

*Trading involves risk of loss. Nothing in this article is financial advice.*

**Run it on CloudSat.** Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. [See plans](https://cloudsat.io/plans) or [deploy a server](https://dash.cloudsat.io/console/deploy).

## Keep reading

[All guides in Trading and crypto](https://cloudsat.io/learn/topic/trading)

- [Moving averages explained: SMA, EMA, WMA and their lag](https://cloudsat.io/learn/moving-averages-sma-ema-wma-explained): Trading and crypto Moving averages explained: SMA, EMA, WMA and their lag 6 min read
- [Forex VPS checklist: location, sizing and a clean setup](https://cloudsat.io/learn/forex-vps-checklist-location-sizing-setup): Trading and crypto Forex VPS checklist: location, sizing and a clean setup 6 min read
- [Technical analysis software, sorted by the job it does](https://cloudsat.io/learn/technical-analysis-software-by-job): Trading and crypto Technical analysis software, sorted by the job it does 6 min read
- [MetaTrader 4 scripts: how they run and how to write one](https://cloudsat.io/learn/metatrader-4-scripts-explained): Trading and crypto MetaTrader 4 scripts: how they run and how to write one 6 min read
