To most users a trading app is a price chart, a buy button and a sell button. Under that surface sits a distributed system that would look familiar to anyone who has built a low-latency service: a client front end, an order gateway, a matching or pricing engine, a risk layer, and a set of upstream liquidity feeds, all stitched together across data centers on two or three continents. Understanding that architecture explains a lot of what retail traders experience day to day, from why a fill price differs from the quote on screen to why a stop-loss sometimes triggers at a worse level than the one entered.
This explainer takes the system apart layer by layer: the four front ends most retail brokers ship, the path an order takes from a phone to a data center, order types as a small state machine, the automation hooks, and the part engineers tend to skip, which is the evidence on where retail traders actually lose money.
Infographic: The graphic below summarizes six reference points from this article: (1) MetaTrader 4 was released in 2005 and MetaTrader 5 in 2010, and both remain the dominant retail front ends; (2) a standard forex lot is 100,000 units of the base currency, a mini lot 10,000 and a micro lot 1,000; (3) light in optical fiber covers roughly 200 kilometers per millisecond, so a London-to-New York round trip costs about 70 milliseconds before any processing; (4) brokers that host their matching infrastructure in the Equinix NY4 facility in New Jersey commonly advertise execution times under 20 milliseconds; (5) two typical account cost models are a spread from 1.0 pip with zero commission versus a spread from 0.0 pip with about 5 US dollars commission per standard lot; and (6) risk disclosures mandated by European and UK regulators typically show that somewhere between roughly 70 and 85 percent of retail CFD accounts lose money.
Layer one: the four front ends
MetaTrader 4, released by MetaQuotes in 2005, is the Windows application that defined retail forex. Its strategy tester is single-threaded and its order set is limited, but it has an enormous library of indicators and automated strategies written in MQL4, and many traders refuse to leave it for that reason alone.
MetaTrader 5, from 2010, is the intended successor. It adds a multi-threaded, multi-currency strategy tester, a depth-of-market view, more pending order types, a built-in economic calendar, native support for exchange-traded instruments alongside over-the-counter CFDs, and a more modern object-oriented language, MQL5. Adoption lagged because MQL4 code does not run unmodified on MT5, but most brokers now steer new accounts toward it, and some account types exist only on MT5.
Web terminals are browser builds of the same engines. They require no installation and work on any operating system, which matters for Linux and ChromeOS users, but they typically cannot run custom indicators or automated strategies and depend on the browser tab staying alive. Native mobile apps are where most new retail activity now happens. A current broker-built app bundles charting with built-in indicators, price alerts delivered as push notifications, one-tap switching between live and demo accounts, market and pending orders with stop-loss and take-profit, and increasingly a copy trading tab. The trade-off is screen real estate and the temptation to act on every notification.
Layer two: the execution path
When a user taps buy on a phone, the request travels over TLS to the broker’s API gateway, is authenticated against the account, and is handed to the trade server, which checks margin, applies any dealer rules, and routes the order to a pricing source.
How that routing works defines the broker’s business model. In a straight-through-processing or ECN arrangement, the order is passed through a liquidity bridge to one or more external price providers, typically banks and non-bank market makers, and the fill comes back from whichever provides the best price. In a market-maker arrangement, the broker’s own engine takes the other side. Many brokers run a hybrid, internalizing small retail flow and hedging larger exposures externally.
Geography matters because the major foreign-exchange liquidity pools sit in a few specific buildings. The Equinix NY4 campus in Secaucus, New Jersey, and LD4 in Slough outside London host a large share of the servers that quote currency prices, so brokers co-locate their trade servers there to cut the round trip to liquidity. A broker hosted in NY4 can plausibly quote internal execution under 20 milliseconds; the same order from a trader in Jakarta still has to cross the Pacific first, which is why the latency a user experiences is dominated by their own distance from the server rather than by the broker’s internal speed.
This is also why the virtual private server, or VPS, is a standard upsell. A VPS in the same facility as the trade server cuts an automated strategy’s latency from hundreds of milliseconds to a few, and keeps running when the trader’s laptop sleeps.
Layer three: order types as a state machine
Across online trading platforms the order vocabulary is nearly identical, because the MetaQuotes terminals set the convention and broker-built apps followed it. It helps to think of an order as a small state machine with three possible states: pending, open and closed.
- Market order. Executes immediately at the best available price. It skips the pending state entirely, which means the fill may differ from the quote displayed when the button was tapped. That difference is slippage, and it is normal.
- Limit order. A pending order to buy below the current price or sell above it. It converts to an open position only if the market reaches the level, and it fills at that level or better.
- Stop order. A pending order to buy above the current price or sell below it, used to enter on a breakout. Once triggered it becomes a market order, so it can fill worse than the trigger level in a fast market.
- Stop-loss and take-profit. Exit instructions attached to an open position. A take-profit is a limit order; a stop-loss is a stop order, with the same slippage caveat. Both are stored on the trade server, so they remain active when the app is closed.
- Trailing stop. A stop-loss that follows the price in the trader’s favor. In MT4 and MT5 it is managed by the client terminal, so it stops updating when the terminal disconnects.
Two more concepts complete the picture. Margin is the collateral the platform locks against an open position; leverage is simply the ratio between position size and that collateral. If floating losses push account equity below a maintenance threshold, the platform issues a margin call and, at a lower threshold called the stop-out level, begins closing positions automatically. Some brokers set the stop-out level at zero on certain account types, which means positions are liquidated only when equity is exhausted.
Layer four: automation and APIs
What distinguishes MetaTrader from a consumer finance app is that it is programmable. An Expert Advisor is a compiled MQL4 or MQL5 program that runs inside the terminal, receives every tick, and can place, modify and close orders without human input. Custom indicators and scripts use the same language. The strategy tester replays historical data against the code, with MT5 able to run thousands of parameter combinations in parallel across CPU cores or a distributed agent network.
Beyond MQL, brokers expose varying degrees of external access: FIX connections for institutional clients, REST and WebSocket APIs on some proprietary platforms, and an official Python package for MT5 that lets a notebook pull quotes and submit orders. Third-party analytics such as Trading Central plug in as chart indicators. The practical constraint for developers is that every broker’s symbol naming and server time zone differ slightly, so code rarely ports cleanly between accounts.
Layer five: the cost plumbing
Platforms monetize through a few channels, and an engineer evaluating one should be able to list them. The spread is the difference between bid and ask, and it is the primary cost on commission-free accounts, where it typically starts around 1.0 pip on major pairs. ECN-style accounts narrow the spread toward zero and charge an explicit commission instead, commonly in the region of 5 US dollars per standard lot per round turn. Swap is the overnight financing charge or credit applied to positions held past the daily rollover, derived from the interest rate differential between the two currencies plus a broker markup; swap-free accounts remove it, sometimes in exchange for a wider spread. Cent accounts denominate balances in cents so that a 0.01 lot trade risks a few cents rather than a few dollars, which is useful for testing code with real execution at negligible stakes.
Where retail traders actually lose money
The architecture above is robust and, at reputable brokers, genuinely fast. The uncomfortable finding from a decade of regulator-mandated disclosures is that none of it changes the outcome for most users. The majority of retail CFD accounts lose money, because the products are leveraged, and with some brokers a sharp move can leave a client owing more than the deposit. Platform speed is not the bottleneck; decision quality is.
The failure modes are consistent. Over-leverage comes first: a platform may permit leverage as high as 1:2000, which turns a half-percent adverse move into a total loss of margin, and the existence of the setting is not a reason to use it. Trading without a written plan comes second, followed by moving stop-losses further away when a trade goes wrong, over-trading in response to push notifications, and failing to account for swap on positions held for weeks. Mobile-first design amplifies several of these, because a notification is a prompt to act and the cost of acting is a single tap.
There is also a jurisdictional layer that technical users tend to ignore. Whether a given platform is available to you, and whether using it is legal, depends on your country and local rules; many international brokers exclude residents of the United States, the United Kingdom, Singapore, Hong Kong and Australia, and the protections attached to an international entity can differ sharply from those of the same brand’s domestically regulated arm. Checking your own regulator’s guidance is a prerequisite, not an afterthought.
A checklist for the technically minded
Treat a trading platform like any production system you are about to depend on. Confirm which regulated entity you are contracting with and where client funds are held. Measure your own round-trip latency rather than trusting the marketing figure. Read the contract specifications for each instrument: contract size, minimum volume, swap rates and trading hours. Use the demo environment, often funded with up to 100,000 units of virtual money, to test your order logic under live prices before any real deposit. Then size every position so that the stop-loss, if it fills with slippage, costs an amount you have decided in advance you can lose. The platform does exactly what it is told at remarkable speed; the one component that cannot be benchmarked is the operator.