New Guy looking for a simple (Close all current trades)

 

I am simply wanting a way to close out all my trades regardless of currency pair, long or short @ the same time. I am very new to this..any help would be appreciated.

 

The attached executable will close ALL orders on the Client Terminal.

It will pop up msg box and state how many orders can be closed.

It will invite you to say: YES or NO to close nn orders (window title bar shows nn)

If NO it stops.

If YES it nukes them all...

It will not stop close attempts until ALL orders are closed.

It will pop up msg box to give brief details at end.

hth

.

NOTE:for ease of use, having copied attachment to ..\experts\scripts\

probably best to stop terminal, copy, restart terminal.

in terminal bring up the Navigator window Ctrl-N

under scripts find the script which has whatever name you wish, as long as .ex4 extension...

right click it and choose "Set hotkey"

there you can use Alt or Ctrl keys followed by suitable easy to remember letter or number (have looksee at terminal's help on "User Interface - Navigator" or search on keyword "favorites" without ""

A hotkey is great way to setup quick action results on your programs. I use Alt-Z as simple to remember [for me] and to use.

.

REMEMBER: this is/can be dangerous script. IF you say YES then ALL orders will be closed on that Client Terminal.

IF your are somehow lucky and right click the chart main window and select "Remove script" - well, maybe it will get aborted before it closes all, but I'd not bet on it!!!

Files:
 

NANA;


My god you must be a GOD...Thank you so much....I have so much to learn....

 

your welcome. hope it serves you well :)

no, not god - just trader attempting to help as-and-when...

if you find that it does not work as stated in first post, please PM me - I have much to learn also and may have missed something.

 

Dear Sir,

It is with much sorrow that I reply to inform that the script does not work.


 
7488:


Please state the nature of your difficulties.

Be precise. Environment at time of "does not work"

eg, orders needed to be closed, broker orders with, version of Terminal, what you have done to install script, what the script did eg, outputs, msg boxes, prints to terminal tab

"does not work", means nothing. If I borrowed your lawn mower, took it home and later called you to say "does not work", what would be your reaction???

maybe something like: does not start, does not cut grass, does not cut grass short enough, does not have all the wheels, ... the list is endless

basically: give me some hard facts so that I may be of assistance!

see what I am on about?

thank you.

.

not run, not close orders, not ???

I used before posted = worked fine for me on my platform (build 226) and broker (Alpari (UK) a sub-pip pricing data feed of 3 pips and 5 pips)

You must supply any and all info (even if seems unimportant to you - all 'events' are important) otherwise no help can be given.

"does not work", can not be used for basis of help.

Regards

.

I suggest from now on that you PM me, this forum is not about solving yours or my 'issues' over shared between 'us' software.

No further replies will be forthcoming unless use PM's

thank you.

 

7488 please try this when market re-opens, copyd attachment to ..\experts\scripts\

//+------------------------------------------------------------------+
//|                              _CloseAllMarketAndPendingOrders.mq4 |
//|                                         Copyright © 2010, sxTed. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, sxTed."
#property link      "http://www.metaquotes.net"
#include <stdlib.mqh>

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
void start() {
  int  iOrders=OrdersTotal()-1, i, iError;
  bool ok;
  
  for(i=iOrders; i>=0; i--) {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
      if(OrderType()==OP_BUY)       ok=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5);
      else if(OrderType()==OP_SELL) ok=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5);
      else if(OrderType()>OP_SELL)  ok=OrderDelete(OrderTicket());
      if(!ok) {
        iError=GetLastError();
        Print("Order:",OrderTicket(),"  Error:",iError," ",ErrorDescription(iError));
      } 
    }
    else Print("OrderSelect error: ",GetLastError());
  }
}
//+------------------------------------------------------------------+
 

Just for the record fbj... with the message box, I wanted to try out your lawnmower. It did a great job, so I cleared a space in the shed for it and took my basic model down the tip.

V

Reason: