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

Your first MT5 console workflow.

Connect. Read. Open and close a demo position. Finish by disconnecting the terminal.

Step-by-step transcript

  1. 0:00

    Your first MT5 console workflow.

    This tutorial shows how to use the MT5 API console from start to finish. We will connect a demo account, read its summary, open and inspect a small demo position, close it with the new shortcut, and disconnect.

  2. 0:17

    Open mt5.mrpc.pro.

    Open M T five dot M R P C dot pro. The console opens automatically. In the top bar, use Trial for supported trial access, or enter your own API key. Your own key follows your account’s service billing.

  3. 0:35

    Enter your demo account details.

    Click Connect Ex under Connection. Enter your demo account number, trading password, and exact broker server name. In this lesson the server is MetaQuotes Demo. Use your own demo credentials. We hide the password in this recording.

  4. 0:52

    Leave the optional id blank.

    Leave the optional I D field blank for a new connection. You can set an expiration in minutes to bound the session. Scroll down and click Execute Request once. Wait for the live response directly below the button.

  5. 1:08

    Keep the returned terminal id.

    The green result says Terminal connected. The response contains data dot terminal instance Guid. This is your session identifier. The console uses it as the I D header on later requests. Click the Account Summary next step, or select it from the left navigation.

  6. 1:29

    Verify the demo account.

    In Account Summary, the session identifier is already filled. Click Execute Request. Expand the response. Check the account number and confirm that account trade mode is Demo before trading. This account’s balance is virtual demo money.

  7. 1:47

    Check the starting positions.

    Select Opened Orders and click Execute Request. The response separates pending orders from open positions. Both lists are empty for this tutorial account. This makes it easy to identify the new position we are about to create.

  8. 2:05

    Prepare a small demo order.

    Click Order Send in the Trading Helper section. Select Euro U S dollar and Buy. Set volume to zero point zero one lots. Keep the same terminal identifier. Check that the symbol and volume are allowed by your demo broker.

  9. 2:23

    Execute once, then read the result.

    Scroll to Execute Request and click once. Our live result says Market order executed. The broker returned ten thousand and nine, trade retcode done. HTTP status code two hundred alone is not the trade result. Read the broker code and the returned execution details.

  10. 2:44

    Inspect the new position.

    Use the Opened Orders next step or the left navigation. Execute the request. There is one Euro U S dollar position with zero point zero one lots. The position ticket identifies the position that we will close.

  11. 3:01

    Use the new close shortcut.

    Scroll to the Live Position and Order Registry at the bottom. Check the position’s symbol, ticket, and volume, then click its small cross button. This opens the close form. It does not submit a trade by itself.

  12. 3:17

    Review the close form.

    The console opens Order Close and fills the position ticket and full volume. Check that both match the intended position. Click Execute Request once to submit the close. This extra step lets you review the request before it is sent.

  13. 3:35

    Confirm the position is closed.

    Our closing request returned Done and the close mode Market Order Close. Run Opened Orders again. The position list is empty, confirming that the tutorial position is gone. Closing a trade and disconnecting the terminal are separate actions.

  14. 3:53

    Disconnect when finished.

    Select Disconnect in the connection section. Keep the same terminal identifier and click Execute Request. The response confirms the session ended and reports its lifetime. Our demo position was already closed and verified first.

  15. 4:11

    You have completed the workflow.

    You have completed the full MT5 workflow. Remember the three different identifiers: API key for access, terminal I D for the session, and position ticket for a trade. Follow the written steps with or without sound, and use the separate error-handling tutorial whenever a result needs attention.