How to use your own custom indicator in an Expert Advisor
MetaTrader can call an indicator it did not ship. The function is iCustom,
and it takes the indicator's file name, the inputs it expects in the right
order, and the number of the buffer you want to read:
int handle = iCustom(_Symbol, _Period, "MyThing", 14, 2.0, true);
That is easy to write and easy to get subtly wrong. Miscount the inputs and the indicator silently runs on different settings than you meant. Read buffer 1 when you wanted buffer 2 and you get a line that looks plausible and is not the one you asked for.
TradeSmithy turns that call into a node. You describe the indicator once, and from then on it behaves like any of the 38 built-ins: real output ports you drag wires from, real inputs you can type or wire.
What a definition is made of
| Part | What it is | Limit |
|---|---|---|
| Name | What the node is called on your canvas | 60 characters |
| File name | What iCustom looks for, relative to the Indicators folder | 120 characters |
| Inputs | The indicator's own parameters, in the order it declares them | 24 |
| Outputs | The buffers you want to read, each with a label and an index | 8 |
| File | The compiled .ex4 or .ex5 itself | 600 KB |
Inputs are positional, because that is what iCustom is. Each one is typed
(int, double, bool, string) and rendered into the generated call as a
literal — a double always gets a decimal point, so 2 is emitted as 2.0
and MQL5 picks the double overload rather than the int one. That is the class
of bug that produces an indicator running on arguments nobody chose.
The upload is required, and that is the point
You cannot save a definition that names a file without attaching the file.
This looks like friction until you consider what a fileless definition
actually is: a name for something the platform never received. It generates
iCustom(_Symbol, _Period, "MyThing", ...), which compiles only on a machine
that already happens to have MyThing installed. Your own terminal might.
Nobody else's does — and if you ever publish that strategy, a buyer receives a
dangling reference with nothing to install.
Requiring the upload is what makes the file name a promise the platform can keep. Files are content-addressed, so re-uploading the same artifact de-duplicates instead of consuming your storage twice.
Output labels are cosmetic; output ids are not
Each output has a label you read on the canvas and an id the edges store. The id is derived from the label once, when the output is created, and then frozen.
Rename "Upper band" to "Resistance" afterwards and the label changes on the node while every wire stays exactly where it was. This is the same rule the whole connection system follows — ids drive logic, labels are UI only — and it exists so that tidying up your naming cannot silently rewire a strategy.
What the file check can and cannot prove
A compiled MetaTrader indicator has no publicly specified magic number, so there is no way to assert that a file is one. The upload check is therefore a denylist: it rejects things that are provably something else — a Windows executable, a zip or RAR archive, a Linux binary, a PDF, a PNG, a GIF, a JPEG — enforces the size cap, and stops there.
We would rather say that plainly than imply a review that does not happen. Two consequences follow honestly from it:
- Publishing a strategy that ships compiled files requires you to attest that you have the right to redistribute them, recorded against the listing.
- Nothing here makes a binary safe. Treat an indicator from a stranger the way you would treat any other executable.
.ex4 and .ex5 are not interchangeable
A project targets a platform, and that decides which extension an upload must
have. An .ex4 will not load in MetaTrader 5; an .ex5 will not load in
MetaTrader 4. Accepting either would let you upload a file your own EA cannot
use — and, worse, ship it to someone else that way.
The extension is the fact, so a definition's platform is read off the file
rather than stored as a separate field that could disagree with the bytes it
describes. The stored file name drops the extension on both platforms, because
iCustom appends the right one itself. (This is one of many places the two
terminals differ; we wrote about
what changes when you switch platform.)
Switching an existing project to the other platform does not delete anything. It flags the nodes whose artifact is now the wrong kind and refuses the export until you resolve them.
The definition travels with the graph
A custom indicator node carries a complete snapshot of the definition, not a reference to your library.
That matters most at the point of sale. When someone buys a strategy, the nodes and edges are copied — a node pointing back at the seller's library would arrive with ports that resolve to nothing, and the wires would vanish on the first load. Instead, the definition arrives with the node and the compiled files are copied into the buyer's library inside the same transaction as the payment.
Your library exists for reuse, and it is advisory. Deleting an indicator from it never touches a graph that already uses it.
If you sell a strategy that depends on custom indicators, the listing publishes their file names before payment — a deliberate, narrow exception to keeping the workflow private, because the alternative is selling somebody an EA that cannot compile. File names only; never inputs, buffers or wiring. There is more on that line in what the buyer actually receives.
The assistant will not edit a definition
The AI assistant can wire your custom indicator into a strategy, change what feeds it and read from its outputs. It cannot rewrite the definition itself — whatever is on the canvas for that node is kept.
A model that helpfully "tidies" a file name produces an EA that no longer compiles on your machine, and takes the wires with it. That is not a trade worth making for tidier text.
Plans
Authoring custom indicators is a paid feature: Pro includes 25 MB of storage, Premium 100 MB, and the Free plan does not include uploads.
Using one is never gated. If you buy a strategy containing custom indicators on a Free plan, you can open it, edit it and export it — and if a paid plan lapses, your own projects keep working. A downgrade never locks work you have already done.
Keep reading
Every indicator parameter can be a wire, not a typed-in number
An RSI period does not have to be 14 forever. Wire it to a global parameter and it becomes tunable in the terminal — and optimisable later — without touching the graph.
3 min readMQL4 vs MQL5: what actually changes when you switch platform
MQL5 is not MQL4 with a bigger version number. Orders, indicators, buffer numbering and even argument order differ — and the worst differences compile cleanly.
4 min readHow to size a position from account balance, not a fixed lot
A hardcoded 0.1 lot means something different on every account. Here is how to read balance, tick value and the broker's own limits into the graph and size a trade from them.
6 min read