DEV Community

KathieFinlay
KathieFinlay

Posted on

MT5 Close OrdersScript

Topics: trading-bot, mt5-script, instant-mt-close, indicators, expert-advisors, metatrader5, mql-all-close, dual-mt5-close, mql5, quick-mt5-exit, forex-trading, mt5-stop-all, mt5-close-utility, order-management, order-close, risk-management, expert-advisor

My Repo: https://github.com/ZovraT/MT5-MT4-Close-Orders-Script

Information

Advanced MT5 / MT4 forex trading tool and indicator suite designed for modern trading platforms, featuring automation, risk management, trade execution, market analysis, and algorithmic trading capabilities. This project supports traders with expert advisors (EAs), indicators, scalping systems, position sizing tools, and real-time trading assistance.

โšก MT5 Auto Scripts

A professional desktop tool for executing MT5 trading scripts instantly built for traders who can't afford to be slow.


๐Ÿšจ The Problem Every Trader Knows

"Market is crashing. You need to close everything. Now."

You open MT5 โ€” close position 1, close position 2, cancel order 1, cancel order 2...

By the time you're done, the damage is done.

MT5 Auto Scripts gives you a single button to close every open position and cancel every pending order across your entire account instantly, with a clean confirmation flow and real-time feedback.


Screenshot

photo


๐ŸŽฌ Demo

Demo


What It Does

Close All Orders Script connects to your active MT5 session and performs the following in sequence:

  1. Reads all open market positions from the account
  2. Sends a close request for each position at the current market price
  3. Reads all pending orders (limit, stop, stop-limit)
  4. Cancels every pending order individually
  5. Verifies each closure and reports the final result

The entire process takes a few seconds and gives you step-by-step progress feedback throughout.


Features

Feature Description
Close All Positions Closes every open market position regardless of symbol, direction, or volume
Cancel All Pending Orders Removes all limit, stop, and stop-limit orders from the account
Multi-Symbol Support Works across forex pairs, metals, indices, crypto โ€” any instrument on your MT5 broker
Pre-Execution Preview Before running, the app shows a full table of every position and order that will be affected
Confirmation Requirement The Run button stays disabled until you explicitly check the confirmation box โ€” no accidents
Live Connection Status Sidebar shows your MT5 server name, login ID, and live connection state at all times
Animated Progress Bar Each step of the script is shown in real time: connect โ†’ close positions โ†’ cancel orders โ†’ verify โ†’ done
Disconnect / Reconnect Toggle your MT5 connection directly from the sidebar without restarting the app
Real-Time Status Bar Bottom bar shows the current operation and a live clock

๐Ÿ›ก๏ธ Safety Design

This tool handles irreversible trading actions, so it was designed with several layers of protection:

  • Confirmation gate โ€” the Run button is visually disabled and non-clickable until the user ticks the acknowledgement checkbox
  • Order preview โ€” a full grid of all open positions and pending orders is displayed before any action is taken, so you always know exactly what will be closed
  • Connection check โ€” if MT5 is disconnected, the script refuses to run and shows a warning in the status bar
  • Warning banner โ€” a clearly visible red warning reminds the user that the action cannot be undone
  • No auto-run โ€” the script never runs automatically; every execution requires a manual trigger

Roadmap

  • [x] Close All Orders Script
  • [ ] Close by Symbol โ€” close only positions on a specific instrument (e.g. XAUUSD only)
  • [ ] Close by Direction โ€” close only Buy positions, or only Sell positions
  • [ ] Close by Loss โ€” automatically close any position in drawdown beyond a set threshold
  • [ ] Scheduled Execution โ€” trigger a close script at a specific time
  • [ ] Telegram Notification โ€” send a message to your Telegram after execution completes

MT5 Auto Scripts ย ยทย  Built for traders, by traders ย ยทย  v1.0.0

My Repo: https://github.com/ZovraT/MT5-MT4-Close-Orders-Script

Top comments (0)