# Coming from MetaTrader 5

## What is the same

You already think in indicators and expert advisors. An MQL5 indicator becomes an `fg.Indicator`, with outputs in place of buffers. An expert advisor becomes an `fg.Strategy`, whose `compute` returns signals. The ideas map across, and the file is Python.

## What is different

- **Arrays run oldest first.** Index 0 is the oldest bar and `-1` is the latest closed bar. There is no series mode to switch on.
- **Missing values are NaN,** not `EMPTY_VALUE`.
- **Decisions are made on closed bars** and filled at the next real price. A strategy does not run on every tick.
- **Time is UTC.** The broker's clock is available, converted for you.
- **The data is arrays.** `calculate` fills whole arrays instead of looping over `rates_total`.

The [traps page](https://oathra.dev/docs/porting/mql5/traps) lists the mistakes that cost the most when porting.

## Where to start

Read [From MQL5](https://oathra.dev/docs/porting/mql5/overview) first. Then write [your first indicator](https://oathra.dev/docs/get-started/draw-your-first-indicator), which takes about three minutes.

If you already own an MQL5 indicator, the [Indicators](https://oathra.app/forge/indicators) screen in Oathra can convert it. It turns the file into Python and says what translated exactly, what was approximated and what could not be converted.

> **Tip.** Signed in, the assistant on this page ports a snippet for you. Paste it and ask for the Forge version. See [Set up your AI tool](https://oathra.dev/docs/get-started/add-your-ai-tool).

## MQL5 names, in Forge

- OnInit becomes setup(self, ctx). Refuse bad settings with raise fg.InvalidParams(...).
- OnDeinit becomes on_end(self, ctx, reason)
- OnTick becomes compute(self, d) for signals over whole arrays; on_bar(self, ctx) for logic per bar
- OnTimer becomes @fg.every(...) on a method
- OnTrade becomes on_order_event(self, ctx, event)

[All 65 names](https://oathra.dev/docs/porting/mql5/to-forge)

13 things in MQL5 have no Forge form. [See the list.](https://oathra.dev/docs/porting/mql5/to-forge#no-forge-form)

A test of the same rules can give different numbers in MetaTrader and in Forge. [Why a MetaTrader report and a Forge test differ](https://oathra.dev/docs/porting/why-results-differ) lists the causes.

## MQL4

MQL4 code is not converted. Settings files (.set) from MetaTrader 4 and 5 are read.
