Close All Positions in MT5 at Once! – Download Free Script!

Recently, I wrote an article about how to close all positions in mt4. Now, we will explain how to do the same thing in MT5.

Managing multiple open positions in MetaTrader 5 (MT5) can be daunting, especially when you need to close them all simultaneously. Fortunately, MT5 provides a solution with the “Close All Positions” script. This article will guide you through installing and using this script to close all your positions quickly and efficiently.

Before you start, watch my video instructions:


Step-by-Step Guide to Installing and Using the “Close All Positions” Script

Step 1: Download the Script

First, you need to download the “Close All Positions” script. You can find this script below:

Close MT5 positions

close all positions

Step 2: Open MT5 and Access the Scripts Folder
  1. Launch MetaTrader 5: Open your MT5 platform.
  2. Navigate to the Data Folder: Click on File the top menu, then select Open Data Folder. This will open the root directory where MT5 stores its files.
Step 3: Locate the Scripts Folder
  1. Find the MQL5 Folder: In the data folder, locate and open the MQL5 folder.
  2. Open the Scripts Folder: You will see several subfolders within the folder. Find and open the Scripts folder.
Step 4: Install the Script
  1. Copy the Script: Copy the “Close All Positions” script file (usually a .mq5 or .ex5 file) from your download location.
  2. Paste the Script: Paste the copied script file into the Scripts folder you opened earlier.
Step 5: Refresh the Scripts in MT5
  1. Return to MT5: Go back to the MT5 platform.
  2. Open the Navigator: Press Ctrl + N to open the Navigator window or find it on the left side of the MT5 interface.
  3. Refresh the Navigator: Right-click on the Scripts section within the Navigator window and select Refresh. This action will ensure that the newly added script appears in the list.
Step 6: Apply the Script to Close All Positions
  1. Locate the Script: In the Navigator window, expand the Scripts section to find the “Close All Positions” script.
  2. Drag and Drop the Script: Click and drag the script from the Navigator window and drop it onto any open chart within the MT5 platform.
Step 7: Execute the Script
  1. Confirm Execution: Upon dropping the script onto a chart, a dialogue box may appear asking you to confirm the execution of the script. Confirm by clicking OK or Yes.
  2. Monitor the Closure: The script will automatically close all open positions associated with your account. You can monitor the closure of these positions in the Trade tab of the Terminal window at the bottom of the MT5 interface.

Troubleshooting and Tips

  • Script Permissions: Ensure that the script has the necessary permissions to execute. If the script does not run, check the Tools -> Options -> Expert Advisors Settings to ensure that automated trading is enabled and DLL imports are allowed.
  • Compatibility: Verify that the script is compatible with your version of MT5. Scripts designed for older versions may not function correctly on newer updates.
  • Error Messages: If you encounter error messages, review them Experts and Journal tabs in the Terminal window for detailed information on what went wrong. This can provide clues for troubleshooting.


Using the “Close All Positions” script in MetaTrader 5 efficiently manages your trading portfolio, especially during volatile market conditions requiring quick action. Following the steps outlined above, you can easily install and utilize this script to close all your open positions with minimal hassle.

Always test new scripts in a demo account before using them in a live trading environment to ensure they work as expected and familiarize yourself with their functionality. Happy trading!



Igor has been a trader since 2007. Currently, Igor works for several prop trading companies. He is an expert in financial niche, long-term trading, and weekly technical levels. The primary field of Igor's research is the application of machine learning in algorithmic trading. Education: Computer Engineering and Ph.D. in machine learning. Igor regularly publishes trading-related videos on the Fxigor Youtube channel. To contact Igor write on:

Trade gold and silver. Visit the broker's page and start trading high liquidity spot metals - the most traded instruments in the world.

Trade Gold & Silver


Recent Posts