โ† All tutorials
MT5 API ยท 4:04

Manage a pending order.

Place. Inspect. Modify. Cancel. Verify.

Step-by-step transcript

  1. 0:00

    Manage a pending order.

    This tutorial shows how to place, inspect, modify, and cancel an MT5 pending order using a dedicated demo account.

  2. 0:11

    Connect your demo account.

    Open M T five dot M R P C dot pro. Enter TRIAL or your API key, then your demo login, trading password, and exact broker server in Connect E X. Execute the request. When it succeeds, the console keeps the returned terminal ID for your next requests. Use a dedicated demo account for practice.

  3. 0:35

    Read the current quote.

    Choose Symbol Info Tick and enter the exact symbol name. Our E U R U S D ask is around one point one one four seven. A Buy Limit belongs below the current ask. We choose one point zero five for this demonstration, well away from the market. Use prices and volume increments allowed by your broker.

  4. 0:58

    Place the Buy Limit.

    Open Order Send. Select the Buy Limit operation, not the default market Buy. Enter zero point zero one lots and an entry price of one point zero five. Check the symbol and operation again before executing. A pending order waits for its entry conditions; placement does not mean a market position has opened.

  5. 1:21

    Save the order ticket.

    Our response has HTTP Status Code 200, no API error, and returned Code ten thousand and nine: Done. For this pending-order request that means placement completed. The order field contains the ticket we will use for inspection, modification, and cancellation. A zero deal field here is normal because no market deal was executed.

  6. 1:47

    Inspect what was placed.

    Call Opened Orders. Find the same ticket in opened Orders. Check the symbol, Buy Limit type, placed state, entry price, and remaining volume. The position Infos list is empty in this recording. That confirms we have a pending order, not a filled position. Keep using this ticket throughout the tutorial.

  7. 2:10

    Change the entry price.

    Open Order Modify and enter the pending order’s ticket. Set price to one point zero four. We leave the optional stop-loss, take-profit, and expiration fields blank because this request changes only the entry price. Execute once, then inspect the response before doing anything else.

  8. 2:31

    Verify the change.

    The modification returns Done. Now call Opened Orders again and find the same ticket. Its price Open is one point zero four, while its type remains Buy Limit and volume remains zero point zero one. This readback makes the result easy to verify, instead of assuming that a successful HTTP response changed the order.

  9. 2:55

    Cancel the pending order.

    To cancel, open Order Close and enter the pending order’s ticket. Leave volume blank for this pending-order removal. Although the method is named Order Close, it also removes pending orders. Always inspect the ticket first: a position ticket would request a position close rather than pending-order cancellation.

  10. 3:17

    Read the removal result.

    The result shows Done and close Mode M R P C Pending Order Remove. Call Opened Orders again. In our recording both lists are empty and the pending ticket is absent. If your order triggered before cancellation, inspect positions and history to establish its current state before taking another action.

  11. 3:39

    Finish with cleanup.

    The order is removed and no position remains. Disconnect the terminal when finished. Disconnecting alone would not cancel a pending order. For any rejected request, inspect error first; when data contains a broker result, read its returned code and description. Correct the stated problem before retrying. You have now completed the pending-order lifecycle.