Close All Script

I got a lot of messages and emails asking me for a script that closes all the opened trades!

This script is for all prurposes closing options which you can use it to close your instant orders (the orders you open at the current market price which they are the normal orders and the opposite of pending orders), pending orders and more!

CloseAll script:

The script is all purposes closing script which means you can decide what type orders you want to close.
You can choose one of 8 options by its index number by setting the option parameter in the input window you get when you run the script (Figure 1):

close all orders script

These are the options:

0 Close all the orders (instant and pending orders) - this is the default option which mean if you run the script and didn't set any parameters all the orders (instant and pending) will be closed.
1 Close all instant orders; instant orders mean the orders that opened at the market price.
2 Close all pending orders.
3 Close by the magic number. You have to set the magic_number variable.
4 Close by comment. You have to set the comment_text variable.
5 Close orders (instant orders) in profit and leave the orders in loss.
6 Close orders (instant orders) in loss and leave the orders in profit.
7 Close not today orders and leave the orders that opened today.
8 Close before a date (input) orders.

The other variables which you can set are:

magic_number : Set it if you'll use closing option 3 - closing by magic number.
comment_text : Set it if you'll use closing option 4 - closing by comment.
before_day : Set it if you'll use closing option 8 - closing before date.
Slippage : Allowed difference between the expected close price and the price the trade actually closes at.

Enjoy yourself! and tell me your comment!

Current version 3.00 (19-Sep-2011)