Saturday, 9 February 2013

Close All Trades All Symbols MQL4 Script for Metatrader 4

There are times when having the quick ability to close out all trades on an account or on a given magic number comes in handy. Whether you are taking a large profit or getting out of a jam, the CloseAll_AllSymbols MQL4 script for Metatrader belongs in every forex trader's arsenal of tools. Simply double click the script from the Navigator pane after copying it into the correct folder, and all open trades should be closed for the magic number selected. The default value is to close all trades for all magic numbers (MagicNumber = -1).

CloseAll_AllSymbols MQL4 is a Metatrader 4 Script that searches through an account and closes out all open trades that match the selected magic number. By default all trades are closed so this makes a handy way to exit the market and get flat in a flash. The script contains default values that will execute unless you manually edit the code from within the MetaEditor.

// when MagicNumber = -1 then close all magic numbers
extern int MagicNumber = -1;

// pips of slippage to allow
extern int Slippage = 7; 

If you wish to change the maximum allowance for slippage, you must change the value in the code prior to executing the script on your chart. Right-click on the navigator pane while selecting the script's name, and choose Modify. This should open up the MetaEditor and load the script into memory. Change the value as desired, then click the "Compile" button at the top of the MetaEditor. 

How to use CloseAll_AllSymbols.mq4

Download the file below and copy it into your "..\experts\scripts" folder. After restarting Metatrader 4 so that it has a chance to compile and find the script and place it in the Navigator pane. You should see the script CloseAll_AllSymbols listed under "Scripts" if you copied the file into the right location, and restarted your Metatrader. Be careful because when you double click the MT4 script all trades on ALL selected charts should close immediately!

You may post this MT4 script to other sites, but if you do, you must post a link to this page directly and you may not sell it or the source code. You are otherwise free to copy, use and distribute this MQL4 script for non-commercial use. 

Note: updated 11/11/2011 to eliminate a small bug that prevented the script from unloading correctly, and reworked the for loop direction to take all fill possibilities into account.

Updated 12/1/2012 to make script compatible with FIFO order exit rule.

3 comments:

  1. Hey Ya'll,

    Below is a list of the highest ranking FOREX brokers:
    1. Best Forex Broker
    2. eToro - $50 minimum deposit.

    Here is a list of top forex instruments:
    1. ForexTrendy - Recommended Probability Software.
    2. EA Builder - Custom Indicators Autotrading.
    3. Fast FX Profit - Secret Forex Strategy.

    I hope you find these lists helpful...

    ReplyDelete
  2. GPS robot [10x increase of the deposit sum]

    I just got done with a webinar with Mark and his partner, Antony, two days ago and it was GREAT.

    During the webinar Mark and Antony shared their secrets to success and answered questions about their new version of the GPS Forex Robot that IS COMING OUT TODAY!

    ReplyDelete
  3. 70tradesis an innovative program capable of recognizing the safest continuation chart patterns. It scans through all the forex pairs, on all time frames and analyzes every prospective breakout.

    ReplyDelete