Skip to content

Forex

MT5 Filling Modes: FOK, IOC, Return and BOC Explained

An MT5 filling mode, called the fill policy in MetaTrader 5, sets what happens when an order's full volume cannot execute at once. Fill or Kill (FOK) executes the whole volume or nothing. Immediate or Cancel (IOC) executes what is available and cancels the rest. Return keeps the unfilled remainder working. Book or Cancel (BOC) places a limit order only if it cannot fill immediately. The symbol's execution mode, set by the broker, limits which filling modes an order can use.

MetaQuotes documents the four policies in MetaTrader 5 Help and in the MQL5 Reference, where the order property is called the order filling type.[1][2] Each symbol's Specification window shows its execution mode and its permitted fill policies.[3] PineConnector's error guide lists "Unsupported filling mode" among the messages that can appear beside MT5 error 4756.[4] The fix is covered in how to fix MT5 error 4756. Filling modes sit alongside order types, lots and margin in the trading mechanics library.

Illustrative cover for MT5 filling modes: four order bars that fill in full, fill in part, keep a remainder working or rest in a book, with the official PineConnector logo.
A filling mode decides what happens to volume that cannot execute at once. The broker's symbol settings decide which modes are allowed.

MT5 filling modes at a glance

Scroll horizontally to read every column.

Filling mode What happens to volume that cannot fill at once MQL5 name and symbol flag
Fill or Kill (FOK) Nothing executes unless the whole volume can. Several market offers can make up the volume. ORDER_FILLING_FOK; flag SYMBOL_FILLING_FOK = 1
Immediate or Cancel (IOC) The volume available now fills, up to the order's volume. The rest is cancelled. ORDER_FILLING_IOC; flag SYMBOL_FILLING_IOC = 2
Return The available volume fills. The remainder stays as an order and is processed further. Not allowed for market orders under Market Execution. ORDER_FILLING_RETURN; no symbol flag
Book or Cancel (BOC) Limit and stop-limit orders only. The order must rest in the Depth of Market; if it could fill immediately, it is cancelled. ORDER_FILLING_BOC; flag SYMBOL_FILLING_BOC = 4
  • Who sets it: the broker sets each symbol's execution mode and the fill policies it offers. An order, or an Expert Advisor's request, then uses one of the allowed modes.[1][3]
  • Where to read it: Market Watch, then Specification, then the Execution and Filling fields. In MQL5, the symbol properties SYMBOL_TRADE_EXEMODE and SYMBOL_FILLING_MODE.[3][5]
  • Default in an MQL5 request: "If no filling type is specified, ORDER_FILLING_RETURN is automatically set in the trade request."[5]

The definitions and identifiers follow MetaTrader 5 Help and the MQL5 Reference, as of 25 September 2026.[1][2][5]

What does each filling mode do to an order's volume?

Requested volume = filled volume + volume removed unfilled + volume still working

The split is this article's own bookkeeping, built from MetaQuotes' definitions. Volume removed unfilled is cancelled or never executed. Volume still working stays in an active order. Each filling mode fixes one or more of the three terms when the order meets the market.[1][2]

  • Fill or Kill: filled volume equals the requested volume, or it is zero. MetaQuotes says that if the necessary amount is unavailable, "the order will not be executed". Several offers can make up the volume, and one order can produce several deals.[1]
  • Immediate or Cancel: no volume is left working. The available volume fills and "the remaining volume will be canceled". Whether IOC can be used "is determined on the trade server".[1]
  • Return: no volume is removed unfilled at that moment. After a partial fill, the remainder "is not canceled, and is processed further". MT5 records such an order with the state Partially filled.[1]
  • Book or Cancel: nothing fills on placement. The order enters the Depth of Market only if it cannot execute immediately, so it does not take current liquidity.[1][2]

A filling mode governs volume; the MQL5 Reference calls it the "volume execution type".[2] Price is settled by the execution mode. In Market Execution, sending an order means "advance consent" to the broker's execution price.[1] How far a fill lands from the expected price is covered in the slippage and requotes guide.

Which filling modes does each execution mode allow?

MetaTrader 5 has four execution modes: Instant, Request, Market and Exchange. MetaQuotes states that the "Execution mode for each security is defined by the brokerage company".[1] The execution mode then limits which filling modes a market order can use. MetaQuotes publishes this rule twice, and the two tables differ for Instant and Request Execution.[1][2]

Execution mode Market orders, per the MQL5 Reference Market orders, per MT5 Help
Instant FOK and IOC "regardless of a symbol setting"; Return always FOK only
Request FOK and IOC regardless of the symbol setting; Return always FOK only
Market FOK and IOC as set in the symbol settings; Return disabled FOK or IOC. Return applies here only to limit and stop-limit orders.
Exchange FOK and IOC as set in the symbol settings; Return always FOK, IOC and Return. BOC applies here only to limit and stop-limit orders.

Both pages agree on Market Execution: a market order must use FOK or IOC, whichever the symbol allows, and cannot use Return.[1][2] The Market Watch help says One Click Trading picks its policy the same way, and uses FOK for Instant and Request Execution.[3] For pending orders, the MQL5 Reference says Return "should be used regardless of an execution type", because such orders are not executed when sent.[2]

Illustrative matrix of MT5 filling modes for market orders by execution mode: Instant and Request allow FOK, with IOC and Return listed only by the MQL5 Reference; Market allows FOK or IOC per symbol and no Return; Exchange allows FOK or IOC per symbol and Return; BOC is for limit orders only.
Summary of MetaTrader 5 Help and the MQL5 Reference as of 25 September 2026. For Instant and Request, MQL5 permits FOK/IOC regardless of symbol flags; those flags alone do not resolve the table difference.

The symbol flags alone do not resolve the Instant/Request difference: MQL5 lists FOK and IOC there regardless of the flags. Distinguish terminal UI choices from the documented MQL5 request rules. Check the execution mode and full broker response, and verify the documented configuration on demo rather than changing EA options from flags alone.[2][3]

Worked example: a 1.00-lot buy under each filling mode

Illustrative example, not a recommendation. A buy market order requests 1.00 lot. At that moment only 0.60 lot is available to fill it. The symbol accepts the filling mode in each row. For Return, assume Exchange Execution, where both MetaQuotes tables allow Return on market orders. The volumes are invented to show the arithmetic, not the liquidity of any broker.

Filling mode Filled + removed unfilled + still working Result
FOK 0.00 + 1.00 + 0.00 = 1.00 lot Not executed: no deal and no position.
IOC 0.60 + 0.40 + 0.00 = 1.00 lot Deals totalling 0.60 lot; the other 0.40 lot is cancelled.
Return 0.60 + 0.00 + 0.40 = 1.00 lot Deals totalling 0.60 lot; the order shows Partially filled and 0.40 lot is still processed.
BOC Not available BOC applies only to limit and stop-limit orders.

Change one input. If the full 1.00 lot is available as two offers of 0.70 and 0.30 lot, FOK, IOC and Return all fill 1.00 lot, because 0.70 + 0.30 = 1.00. MT5 can record that as two deals for one order, and the History tab lists the order and each deal.[1][6]

BOC tests whether a limit order could fill now. On an Exchange Execution symbol, MT5 does not verify a limit order's price, so a buy limit placed above the current ask "triggers almost immediately and turns into a market one".[1] Suppose the ask is 1.10010. A BOC buy limit at 1.10020 could fill at once, so it is cancelled. A BOC buy limit at 1.10000 sits below the ask, so it is placed in the book.[1][2] The order types guide explains where limit and stop orders sit relative to price.

Illustrative bars for a 1.00-lot MT5 buy with 0.60 lot available: FOK fills 0.00, IOC fills 0.60 and cancels 0.40, Return fills 0.60 and keeps 0.40 working, and BOC applies only to limit orders.
Illustrative volumes, not a recommendation or a measured fill. Filled plus removed unfilled plus still working equals 1.00 lot in every case.

Where does the filling mode enter a TradingView-to-MT5 order?

An automated trade passes through four stages: a Pine Script rule, a TradingView alert, an Expert Advisor's order request and the broker's execution. The filling mode first appears at the third stage.

  1. Alert. When a TradingView alert triggers, its webhook sends an HTTP POST request with the alert message in the body.[7]
  2. Message. A PineConnector message holds a License ID, a command, the exact broker symbol and parameters.[8] An illustrative market buy, pasted into the TradingView alert's Message field, reads LicenseID,buy,EURUSD,vol_lots=0.01,sl_pips=20: 0.01 lot with a 20-pip stop loss. As of 25 September 2026, PineConnector's syntax reference lists no filling-mode parameter.[8]
  3. EA request. In MQL5, the filling mode is the type_filling field of the trade request, set by the program that sends the order.[2][9] In a PineConnector setup, the EA builds that request. Its Broker Set input defaults to Automatic, described as "Normal automatic selection". Set B is "A configuration to try for unsupported order-filling errors".[10] Which filling mode each option sends is not documented; test on demo.
  4. Broker. The trade server checks the request against the symbol's rules. The order can be rejected, or filled in full or in part according to its filling mode.[1]

On PineConnector Edge, the hosted EA's settings, including Broker Set, can be viewed and changed in Portal → Edge → EA Settings; the guide warns that "Applying changes interrupts signals" while the terminal restarts.[11] TradingView's Strategy Tester makes its own, separate fill assumptions. By default, its broker emulator fills a limit order as soon as price reaches the order's level. The backtest_fill_limits_assumption parameter can require price to move further first.[12] A simulated fill is not an MT5 deal. An IOC partial fill in MT5 also opens less volume than the message requested, so check the deal volume, not the alert.

How do you check which filling modes a symbol allows?

  1. Open the specification. In MT5 Market Watch, right-click the receiving broker's exact symbol, including any suffix, and choose Specification.[3][13] Read two fields: Execution (Instant, Request, Market or Exchange) and Filling, the "available fill policies".[3]
  2. Look at the order window. Under Market and Exchange Execution, the Fill Policy field offers Fill or Kill, Immediate or Cancel or Book or Cancel. MetaQuotes adds: "If this field is inactive, then the option is disabled on the server."[6]
  3. Read the flags in code. An Expert Advisor reads SYMBOL_FILLING_MODE as a combination of bit flags: 1 for FOK, 2 for IOC and 4 for BOC. Return has no flag. A value of 3 means FOK and IOC (1 + 2); a value of 1 means FOK only.[5]
  4. Check the result. After a demo order, the History tab shows the order's state, such as Partially filled, and each deal with its volume.[1][6]

Without terminal access, as on Edge, PineConnector's syntax reference says to request the same MT5 symbol specification "through the broker or support".[13] On Edge, the Symbols tab (Portal → Edge → Symbols) lists every symbol your broker offers, with its specification, so you can copy the exact case-sensitive symbol name into your alert; names can differ between account types on the same server (Symbols guide). It does not show the Execution or Filling fields.

What does "unsupported filling mode" mean, and what should you check?

"Unsupported filling mode" means an order request named a filling mode the symbol does not accept, so the order was not executed. MQL5 runtime error 4756, ERR_TRADE_SEND_FAILED, reads "Trade request sending failed".[14] MQL5's trade server return codes include 10030, TRADE_RETCODE_INVALID_FILL, "Invalid order filling type".[15] PineConnector's error guide lists unsupported filling mode as one of several messages beside 4756, and says 4756 alone does not select one fix.[4]

Two sentences in the MQL5 Reference show one way the error can arise. A request that specifies no filling type gets ORDER_FILLING_RETURN automatically, and Return orders are not allowed under Market Execution.[5] A request that leaves the field empty on a Market Execution symbol therefore asks for a mode the symbol rejects. The inference applies to anyone writing or reviewing MQL5 code; PineConnector does not document how its EA sets the field.

For a PineConnector setup, work through the checks in order:

  1. Read the full Experts and Journal entries at the time of the failed request, not only the number.[4][16]
  2. Compare the symbol's Execution and Filling fields with the request.[3]
  3. Follow the error guide: "Older PineConnector EAs offer Broker Set B for this case". Use it only if your EA version has that setting and it matches the supported configuration.[4] The EA reference adds: "Do not cycle through these at random."[10]
  4. On Edge, Broker Set is in Portal → Edge → EA Settings; change it only when Support asks you to. Applying a change restarts the terminal, so signals pause for about a minute. Start from the Portal connection and signal details, and contact support if the terminal detail you need is not shown.[4][11]
  5. After any change, send a fresh demo test. Receipt of the signal and the broker outcome are separate checks.[17]

The step-by-step fix, including the other messages that appear beside 4756, is in how to fix MT5 error 4756. Other terminal codes are in the MetaTrader error troubleshooting guide.

What are the common mistakes with MT5 filling modes?

  • Reading FOK as price protection. FOK decides how much volume fills, not at what price. Under Market Execution the broker still decides the price.[1]
  • Assuming IOC always fills in full. IOC can open less volume than requested. Check the deal volume in History before treating the position as the requested size.[1][6]
  • Forgetting a Return remainder. The unfilled part of a Return order keeps working after the first deal. MetaQuotes counts "unfilled orders to execute a market deal" among active orders, so check active orders before sending a replacement.[6]
  • Using symbol flags to settle a documentation conflict. For Instant/Request execution, MQL5 lists FOK and IOC regardless of those flags. The flags alone do not reconcile its table with MT5 Help. Distinguish the request rules from terminal UI choices and check the full broker response.[1][2]
  • Checking a different symbol or account. Specification values are set by the broker for each symbol. Check the exact symbol, suffix included, on the account that will receive the alerts.[3][13]
  • Using BOC on a market order. BOC supports only limit and stop-limit orders.[2]
  • Treating a simulated fill as a broker fill. A TradingView order-fill event, a PineConnector receipt and an MT5 deal are separate records. Verify the deal and the position on the receiving account.[12][17]

Frequently asked questions

What is the difference between fill or kill and immediate or cancel?

Fill or Kill (FOK) executes an order's whole volume or none of it. Immediate or Cancel (IOC) executes the volume available at that moment, up to the order's volume, and cancels the rest. For a 1.00-lot order with 0.60 lot available, FOK fills nothing and IOC fills 0.60 lot. In MetaTrader 5, the symbol's execution mode and broker settings decide which of the two it accepts.

What is the order filling type in MT5?

The order filling type is the MetaTrader 5 order property that says what happens to volume that cannot execute at once. MQL5 names it ORDER_TYPE_FILLING, with the values Fill or Kill, Immediate or Cancel, Book or Cancel and Return. An Expert Advisor sets it in the type_filling field of its trade request. The symbol's execution mode and broker settings decide which values are valid.

What does unsupported filling mode mean in MT5?

Unsupported filling mode means an MT5 order request used a filling type the symbol does not accept, so the order was not executed. MQL5 lists trade server return code 10030, "Invalid order filling type". With an Expert Advisor, the message can appear beside runtime error 4756. Check the Execution and Filling fields in the symbol's Specification, then the EA's documented filling options.

How do I check which filling modes my broker allows in MT5?

In MetaTrader 5, right-click the exact symbol in Market Watch and choose Specification. The Execution field shows Instant, Request, Market or Exchange, and the Filling field lists the permitted fill policies. In MQL5, SYMBOL_FILLING_MODE returns flags: 1 for Fill or Kill, 2 for Immediate or Cancel and 4 for Book or Cancel. Return has no flag. For Instant and Request execution, MQL5 lists FOK and IOC regardless of the symbol flags; those flags alone do not resolve the documentation difference.

What is the Return filling mode in MT5?

Return is the MetaTrader 5 filling mode that keeps an order's unfilled volume working after a partial fill, instead of cancelling it. Return is not allowed for market orders under Market Execution. The MQL5 Reference says Return is set automatically when a request names no filling type, and that pending orders should use Return in any execution mode.

Reviewed 25 September 2026. Facts were checked against the linked sources on that date; Edge EA Settings updated 6 October 2026. Nothing in this article was tested on a trading account and no code was compiled.

Related reading

Sources

  1. MetaQuotes – MetaTrader 5 Help: Basic Principles (execution types and fill policy), accessed 25 September 2026.
  2. MetaQuotes – MQL5 Reference: Order Properties (ENUM_ORDER_TYPE_FILLING), accessed 25 September 2026.
  3. MetaQuotes – MetaTrader 5 Help: Market Watch and symbol specification, accessed 25 September 2026.
  4. PineConnector – EA errors: match the message beside 4756, accessed 25 September 2026.
  5. MetaQuotes – MQL5 Reference: Symbol Properties (SYMBOL_FILLING_MODE), accessed 25 September 2026.
  6. MetaQuotes – MetaTrader 5 Help: Executing Trades, accessed 25 September 2026.
  7. TradingView – How to configure webhook alerts, accessed 25 September 2026.
  8. PineConnector – Syntax: message structure, accessed 25 September 2026.
  9. MetaQuotes – MQL5 Reference: Trade Request Structure, accessed 25 September 2026.
  10. PineConnector – EA settings reference: Broker Set, accessed 25 September 2026.
  11. PineConnector – Edge: EA settings, accessed 25 September 2026.
  12. TradingView – Strategies: slippage and unfilled limits, accessed 25 September 2026.
  13. PineConnector – Syntax: look up broker values, accessed 25 September 2026.
  14. MetaQuotes – MQL5 Reference: Runtime Errors, accessed 25 September 2026.
  15. MetaQuotes – MQL5 Reference: Trade Server Return Codes, accessed 25 September 2026.
  16. PineConnector – Frequently asked questions: the Journal tab, accessed 25 September 2026.
  17. PineConnector – Syntax: check the result, 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.


Leave a comment

Back To PiCo Blog

Ready when your strategy is

You bring the strategy.We bring the infrastructure.

Connect TradingView to MetaTrader, choose where MT5 runs and put the full PineConnector workflow through its paces from your first month.

Strategy and trading decisions remain yours. The MT5 environment can be ours.

PineConnector Edge

Run the full PineConnector workflow.

$59/mo at launch

Core plan · 1 connection · 1 hosted MT5 environment

Try Core for $7

7 days of Core for $7, then $59/month at the launch price unless you cancel.