Forex trading works by using a broker’s quotes to request and manage currency positions. Buys generally fill at the ask and sells at the bid. In MetaTrader 5 (MT5), an order is a request, not a confirmed fill. The broker checks its volume, stops, margin and filling type. Orders can wait, execute, be rejected or be cancelled. Executed deals can open, change or close positions, with costs determined by the broker’s terms.
This hub maps PineConnector's trading mechanics library: the parts of a trade that stay the same whatever strategy sends it. CFDs on indices, metals and other assets follow the same chain, with contract sizes, margin rules and sessions set in each symbol's specification. When a TradingView alert starts the chain, PineConnector and its EA pass the request on, and the broker still accepts or rejects it.[1]

Which trading mechanics guide answers your question?
The library groups its guides by the stage of a trade where each question comes up. Start with the stage you are stuck on. The diagram in the next section shows how the stages connect.
Quotes and prices
- Bid, ask and spread: why a buy opens at the ask and closes at the bid, and what the spread costs.
- Pips, points and pip value: pip size by quote precision, and pip value per lot for forex, metals and indices.
- Why TradingView prices differ from your broker's: data feeds, quote sides and CFD pricing.
- Broker symbol suffixes: how to find the exact symbol name an order must use.
- CFDs vs futures vs spot: counterparty, expiry and why their prices can differ.
Orders and execution
- Order types: market, limit, stop and stop-limit: where each order sits relative to price, and how long it lasts.
- MT5 filling policies: FOK, IOC, Return and BOC: which filling types a symbol allows, and why.
- Stops level and freeze level in MT5: the minimum distance for stops, and when changes near the price are blocked.
- Slippage and requotes: why a fill differs from the requested or alert price.
Size, leverage and margin
- Lot size, contract size and volume step: what one lot means per symbol, and what happens to a size between two steps.
- Leverage in forex: what leverage changes (margin) and what it does not (loss per pip).
- Margin level, margin call and stop-out: equity, free margin and the account levels that trigger closures.
Positions and accounts
- Netting vs hedging accounts in MT5: what a second, opposite order does to an open position.
- MT4 vs MT5 for automated trading: the documented differences that matter once alerts place orders.
Costs
- The full cost of a trade: spread, commission, swap and slippage, expressed in R.
- Swap and rollover fees: overnight financing, swap types and the triple-swap day.
Time, sessions and gaps
- Forex market sessions: session clock times, overlaps and daylight-saving shifts.
- Broker server time vs UTC vs TradingView time: why the same bar can carry different timestamps.
- Weekend gaps and the market open: why a stop can fill beyond its price.
How does a forex order become a position?
MetaQuotes describes MT5 trading with three linked records: an order, a deal and a position.[2] The diagram adds the alert that starts an automated request, and the costs.

- Quote. Market Watch shows each symbol's bid and ask; the spread is the difference.[3] A security is generally bought at the ask and sold at the bid.[2] A TradingView chart can use another feed, from ICE composite symbols to individual brokers.[4]
- Signal. In an automated setup, a TradingView alert triggers and its webhook sends an HTTP POST with the alert message as the body.[5] A PineConnector message holds a License ID, a command, the broker's exact symbol and parameters.[6] The receiving EA applies its settings, and the broker accepts or rejects the resulting request.[1]
- Order. An order is an instruction to a broker to buy or sell. MT5 offers market orders and six pending types: buy limit, buy stop, sell limit, sell stop, buy stop limit and sell stop limit.[2][7] Each order records its volume, stop loss, take profit and filling type.[8]
- Checks. The trade server checks the order's correctness, including prices and available funds, and can reject it.[2] The next section lists the checks.
- Deal. A deal is the actual buy or sell, and one order can produce several deals.[2] The broker sets each symbol's execution mode. In Market Execution, sending an order means agreeing in advance to the broker's price. In Instant Execution, a broker that does not accept the requested price sends a requote.[2]
- Position. A deal can open, add to, reduce, close or reverse a netting position. A hedging account can hold separate positions, including opposite ones.[2] Check actual SL/TP on the receiving position. The forex examples use Bid for a long’s trigger and Ask for a short’s. Exchange Stocks, Exchange Futures and Futures Forts follow exchange trigger rules, usually Last.[2][7]
- Margin. While the position is open, MT5 shows its margin, the free margin (equity minus margin) and the margin level (equity divided by margin, times 100).[7] Margin call and stop-out levels are properties of the account, set in percent or in the deposit currency.[9] In MT5's normal mode, a stop-out closes the position with the largest loss first.[7]
- Costs and close. The spread is paid through the ask-to-bid round trip. Commission follows the broker's terms, and swap follows the specification's swap settings at each rollover.[7][3] A netting position closes with an opposite deal of the same volume; a hedging position closes with Close Position.[2]
Each stage leaves its own evidence. TradingView's alert log has a Webhook status column for delivery.[5] PineConnector's docs treat receipt of a message and the broker outcome as separate checks.[10] In MT5, the Trade tab lists the open position, and the History tab lists the order and each deal it produced.[7]
What does the broker check before it accepts an order?
MetaQuotes documents each check below in the symbol specification or the account state. The MetaQuotes pages cited here do not give the order in which the server applies them, so treat them as a set. Each failure has its own MQL5 trade server return code.[11]
Scroll horizontally to read every column.
| Check | What the request must satisfy | Return code if it fails |
|---|---|---|
| Volume | Lots between the symbol's minimal and maximal volume, in whole volume steps.[3][12] | 10014, invalid volume |
| Stop distance | Stop loss, take profit and pending prices outside the Stops level channel, counted in points from the current price.[3] | 10016, invalid stops |
| Margin | Enough free margin to cover the margin the new order needs.[2][7] | 10019, not enough money |
| Filling | A filling type the symbol allows under its execution mode.[8][2] | 10030, invalid filling type |
| Trade mode and session | A symbol open to this direction at this time. Some symbols are long only, short only or close only.[3] | 10017, trade disabled; 10018, market closed |
A rejected request produces no deal and no position. PineConnector's error guide lists unsupported filling mode, invalid volume and invalid stops among the messages that can appear beside MT5 error 4756. The guide adds that 4756 alone does not select one fix.[13] For the fixes, see how to fix MT5 error 4756 and common MetaTrader errors in automated trading.
One illustrative EURUSD order, check by check
Illustrative example, not a recommendation. A USD account has a balance of 10,000.00 USD, no open positions and leverage of 1:30. The EURUSD specification is invented for the arithmetic: contract size 100,000, five digits (Point 0.00001), Stops level 20 points, volume from 0.01 to 100 in steps of 0.01, Forex margin calculation and a margin rate of 1. The quote is bid 1.10000, ask 1.10010.
The TradingView alert's Message field holds this illustrative PineConnector message, with your License ID in place of LicenseID:
LicenseID,buy,EURUSD,
Forex margin = lots × contract size ÷ leverage (in the base currency), converted to the deposit currency, × margin rate
- Volume: 0.30 lot sits inside 0.01 to 100 and is exactly 30 steps of 0.01, so it passes.
- Stop distance: one PineConnector pip is 10 points,[14] so 20 pips is 200 points, or 0.00200. The minimum distance is Stops level × Point = 20 × 0.00001 = 0.00020,[15] so the stop passes.
- Margin: 0.30 × 100,000 ÷ 30 = 1,000.00 EUR. For a buy, MT5 converts at the current ask: 1,000.00 × 1.10010 = 1,100.10 USD.[16] Free margin of 10,000.00 USD covers it, so it passes.
- Filling: the request must use a filling type listed in the symbol's Filling field.[3] The example assumes it does.
- Deal and position: assume the order fills at the 1.10010 ask. Closing a long means selling at the bid, so the position opens one spread behind: (1.10000 − 1.10010) × 30,000 units = −3.00 USD.
- Account state: ignoring when commission is charged, equity is 10,000.00 − 3.00 = 9,997.00 USD. Free margin is 9,997.00 − 1,100.10 = 8,896.90 USD. Margin level is 9,997.00 ÷ 1,100.10 × 100, about 908.7%.[7]
At 0.30 lot, one pip is worth 0.30 × 0.0001 × 100,000 = 3.00 USD. The 1.0-pip spread therefore costs 3.00 USD. An illustrative commission of 7 USD per lot for the round turn adds 2.10 USD, for 5.10 USD, or 1.7 pips, before swap and slippage. Each 0.1 pip of slippage on either fill adds 0.30 USD. Holding through rollover adds the specification's swap.
The 20-pip stop plans a loss of 20 × 3.00 = 60.00 USD before costs, so the known costs equal 5.10 ÷ 60.00 = 0.085 R. The planned loss is not a maximum: costs, fills and gaps can make the actual loss differ.[17] In this example, leverage changes only the margin figures. At 1:100, the margin would be 300.00 EUR, or 330.03 USD, and one pip would still be worth 3.00 USD.
Where do you read each number in MT5?
Open Market Watch, right-click the exact broker symbol and choose Specification.[3][15] Use the receiving account's specification, as it stands on the day you check. PineConnector's docs list the same fields to record. On PineConnector Edge, the Symbols tab (Portal → Edge → Symbols) lists every symbol the broker offers, with its specification, including digits, contract size, minimal volume, volume step and stops level, and lets you copy the exact symbol name into the alert instead of retyping it (Edge Symbols guide). For a field the tab does not show, the docs say to request the specification through the broker or support.[15]
| Number | Where in MT5 | What it decides |
|---|---|---|
| Bid, ask, spread | Market Watch | The fill side and the spread cost |
| Contract size, Digits, Tick size, Tick value | Specification | Pip value and profit per price step |
| Minimal volume, Maximal volume, Volume step | Specification | Whether a lot size is valid |
| Stops level (points) | Specification | The minimum distance for stops, targets and pending orders |
| Execution, Filling | Specification | Which filling types a request can use |
| Calculation, Margin currency | Specification | The margin formula and its conversion |
| Swap type, Swap long, Swap short, Swap rates | Specification | The holding cost at each rollover |
| Balance, Equity, Margin, Free margin, Margin level, each position's Swap | Toolbox, Trade tab | Room for another order, and swap charged so far |
| Orders, deals, each deal's Commission | Toolbox, History tab | What happened, and what it cost |
Field names follow MetaQuotes' help as of 25 September 2026.[3][7] On the TradingView side, note which data provider the chart uses. Volume data and trading hours can vary by provider,[4] and your broker quotes its own bid and ask. Read why TradingView prices differ from your broker's before relying on exact price levels in an alert.
How should you use this library?
- A rejected order: find the return code, then open the guide for that check: stops level, filling policies, lot size or margin level.
- An alert with no trade: work through the stage-by-stage diagnosis for a webhook that produced no MT5 trade.
- A new symbol: record its specification fields from the receiving account, then check the message's units against them. Symbol Mapping can translate an incoming symbol to the broker's name before it is sent to the terminal.[18]
- Sizing and limits: position sizing and loss limits belong to the risk management hub. Costs in backtests belong to the backtesting hub.
Every number in these guides is illustrative. Your broker's specification, your account type and your regulator decide the real values.
What does this map leave out?
- Broker variation. The broker sets each symbol's execution mode and each account's netting or hedging system.[2] Commission terms are the broker's too.[7] Each account carries its own margin call and stop-out levels.[9]
- Volume rounding. PineConnector's FAQ says the EA checks the broker's minimum, maximum and step before sending a size.[19] Its syntax reference says to compare the requested and accepted volume rather than assume a rounding direction.[17]
- Acceptance is not the final state. An accepted request, a deal and the resulting position are separate facts. On a netting account, a new deal can reduce or reverse a position instead of opening one.[2] Only a stop loss that reached the broker is held on its server;[7] a level that exists only in a chart script is not.
- Regulation. Retail leverage limits and margin close-out rules are set by regulators, so check the rules that apply to your account. ASIC's order for retail CFD clients in Australia, for example, sets leverage limits from 30:1 to 2:1 and runs to 23 May 2027.[20]
- Automation. PineConnector executes the instruction in the message. It does not choose the symbol, the size, the stop or whether to trade.
Frequently asked questions
What are the basics of forex trading?
Forex trading basics come down to five parts: a bid and ask quote, an order sized in lots, the margin held while a position is open, trading costs, and the broker's rules in each symbol's specification. The costs are spread, commission, swap and slippage. A buy generally fills at the ask and closes at the bid, so each position starts one spread behind.
How do CFD trading mechanics differ from spot forex?
ASIC describes a CFD as a leveraged derivative contract that lets a client speculate on the change in value of an underlying asset, such as an exchange rate, index or commodity. In MT5, a CFD uses the same order, deal and position chain as a forex pair. Contract size, margin calculation, sessions and swap come from each CFD's specification, and retail leverage limits depend on the regulator.
How do orders work in MT5?
An MT5 order requests a trade; acceptance is not a confirmed fill. Check the order state and any deals, which can open, change or close positions. Market orders request execution at available prices, subject to the execution mode and broker processing. Pending orders wait for their conditions. Match the order and deal records in History, then verify the resulting position.
Why does MT5 reject an order?
MT5 rejects an order when the broker's trade server finds it invalid or cannot fund it. Common MQL5 return codes are 10014 (invalid volume), 10016 (invalid stops), 10019 (not enough money) and 10030 (invalid filling type). Each points to a field in the symbol specification or to the account's free margin. A request sent through PineConnector faces the same broker checks after the EA builds it.
Does leverage change how much you lose per pip?
No. For a given lot size, pip value depends on pip size, contract size and lots, converted to the account currency. On EURUSD with a 100,000 contract, 1.00 lot moves 10 USD per pip at any leverage. Leverage changes the margin the broker holds for the position, and with it how much free margin remains before the account's margin call and stop-out levels apply.
Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account.
Related reading
- Trading risk management: the rules that survive automation
- How to backtest a trading strategy: the method library
- Trading metrics: the complete library
- MetaTrader 5 updates for automated traders
- Trading glossary: terms for forex, CFDs and automation
Sources
- PineConnector – EA settings reference: what shapes the trade request, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Basic Principles, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Market Watch and symbol specification, accessed 25 September 2026.
- TradingView – What is the difference between ICE and other forex providers?, accessed 25 September 2026.
- TradingView – How to configure webhook alerts, accessed 25 September 2026.
- PineConnector – Syntax: message structure, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Executing Trades, accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Order Properties, accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Account Properties, accessed 25 September 2026.
- PineConnector – Syntax: check the result, accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Trade Server Return Codes, accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Symbol Properties, accessed 25 September 2026.
- PineConnector – EA errors: match the message beside 4756, accessed 25 September 2026.
- PineConnector – Syntax: the PineConnector pip, accessed 25 September 2026.
- PineConnector – Syntax: look up broker values, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Margin Calculation: Retail Forex, Futures, accessed 25 September 2026.
- PineConnector – Syntax: loss-based sizing, accessed 25 September 2026.
- PineConnector – Match your broker's symbols: add a broker prefix and suffix, accessed 25 September 2026.
- PineConnector – Frequently asked questions: volume handling, accessed 25 September 2026.
- ASIC – 22-082MR ASIC's CFD product intervention order extended for five years, accessed 25 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.