Read the transcript
This tutorial shows you how to run a complete MT5 API example. We will connect, read account data, open and inspect a demo position, then close it and disconnect.
Open M R P C dot pro slash API. Click Run a live demo to jump to the example.
Every language listed here can run online on this website. For this walkthrough, choose JavaScript. The selected tab turns blue, and the example code changes to match.
Click Run full demo. This creates a fresh demo account and connects to MT5. Keep the page open while the console reports each stage.
Read the live console. After connecting and reading the account, the example opens a zero point zero one lot Euro U S dollar demo position. It reads the position, closes it, verifies the close, and disconnects. Only demo funds are traded.
Check the result before using the code. Success and disconnected must both be true. The open response reports trade retcode done. The opened positions include the position ticket. The final position list should be empty.
When signed in, click Download example. Expand Run locally for the runtime requirements and command. Keep your API key private. Guests can try the browser demo free, and sign up to download their own example.
You have completed the demo workflow. Use your own API key for your application, retain the cleanup steps, and always disconnect when finished. You can replay any step and follow the written instructions without audio.