• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 12:47pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 12:47pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

EA/Script to close Trades and Pending orders? 12 replies

Need Scripts - close all open and pending orders 10 replies

Close all pending orders and open orders once they reach profit target 3 replies

script to "close open orders" and "open opposite orders" 3 replies

Orders & Pending Orders Script 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Need help to mod "Close All Pending Orders" script
Exit Attachments
Tags: Need help to mod "Close All Pending Orders" script
Cancel

Need help to mod "Close All Pending Orders" script

  • Post #1
  • Quote
  • First Post: Sep 21, 2012 11:59pm Sep 21, 2012 11:59pm
  •  Jack0812
  • | Joined Jul 2012 | Status: Member | 6 Posts
Hi all,

Anybody help me to modify this EA http://www.forexfactory.com/images/attach/mq4.gif Close All PENDING Orders Specific Pair.mq4 to Close All PENDING Orders AFTER Close all open trades of Specific Pair?

I mean I need it just close all pending orders ASA the open trades hit TP/SL of Specific Pair.

Thank you in advance.


  • Post #2
  • Quote
  • Sep 23, 2012 5:50am Sep 23, 2012 5:50am
  •  Jack0812
  • | Joined Jul 2012 | Status: Member | 6 Posts
I would really appreciate if someone could help me...

Thank you in advance.
 
 
  • Post #3
  • Quote
  • Sep 23, 2012 6:22am Sep 23, 2012 6:22am
  •  fxtr51
  • Joined Jan 2010 | Status: Member | 1,163 Posts
Find this part of the code:
Inserted Code
//Close pending orders
      case OP_BUYLIMIT  :
      case OP_BUYSTOP   :
      case OP_SELLLIMIT :
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
Modify it like this:
Inserted Code
//Close pending orders
      case OP_BUYLIMIT  : result = OrderDelete( OrderTicket() );
      case OP_BUYSTOP   : result = OrderDelete( OrderTicket() );
      case OP_SELLLIMIT : result = OrderDelete( OrderTicket() );
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
 
 
  • Post #4
  • Quote
  • Sep 23, 2012 6:26am Sep 23, 2012 6:26am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 2,919 Posts
you aren't actually asking for 'help'. helping would suggest you have some steam behind you and just need some guidance in the correct direction.

you basically don't even have any code and just want someone to do it all for you. sorry, but that's not 'help'. also, your question is unclear at best for anyone who would do it all for you. i'm sure someone, somewhere, has already coded what you want anyway. either do some searching, or be clearer with what exactly you want to happen.

help others to help you by being straight, and most of all, being clear.
 
 
  • Post #5
  • Quote
  • Sep 23, 2012 6:55am Sep 23, 2012 6:55am
  •  fxtr51
  • Joined Jan 2010 | Status: Member | 1,163 Posts
nubcake,
yes, it is one of those foggy requests which give room for much speculation,
but he provided the code (click on the name of the EA and it will download)
and since the most simple solution required only a copy and paste,
I chose to help.

The only application of this EA would be to attach it on a pair where
the last open order just closed and he must be present to catch this
moment.

If he wants something else, he should express it clearly but here my help is ending.
 
 
  • Post #6
  • Quote
  • Sep 23, 2012 7:04am Sep 23, 2012 7:04am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 2,919 Posts
Quoting fxtr51
Disliked
nubcake,
yes, it is one of those foggy requests which give room for much speculation,
but he provided the code (click on the name of the EA and it will download)
and since the most simple solution required only a copy and paste,
I chose to help.

The only application of this EA would be to attach it on a pair where
the last open order just closed and he must be present to catch this
moment.

If he wants something else, he should express it clearly but here my help is ending.
Ignored
you have greater patience than i. this i know to be true. i saw the 'source' and it was almost a blank new template. *exasperated look of great confusion*
 
 
  • Post #7
  • Quote
  • Sep 23, 2012 7:55am Sep 23, 2012 7:55am
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,831 Posts
Quoting Jack0812
Disliked
Anybody help me to modify this EA
Ignored
hey jack..... seeming small point of reference, that is a script not an ea..... there is a difference.....

it's one of many from an excellent coder, Matias Romeo, from days gone by.... it's written without waste, so it may seem brief..... but in reality there is not a single character too many or too few...... it's an almost perfect example of perfect coding.......

//---

as for your request, you'll most likely need to monitor the pair with a true ea..... it should count open buys or sells and once there were none, close all remaining pending orders.....h
to trade and code, keep both simple... no call to impress....h
 
 
  • Post #8
  • Quote
  • Sep 23, 2012 10:57pm Sep 23, 2012 10:57pm
  •  Jack0812
  • | Joined Jul 2012 | Status: Member | 6 Posts
@fxtr51

Thanks for your effort but it's not works. I want it wait till open orders hit SL or TP than it start closing all pending orders not closing all pending orders as soon as it attach to the chart now.

Thank you.
 
 
  • Post #9
  • Quote
  • Sep 24, 2012 12:31am Sep 24, 2012 12:31am
  •  Bruce Flea
  • | Joined Jan 2011 | Status: Member | 179 Posts
Then as hayseed said, you need an EA, not a script.

Different animals altogether
No way I'll wreck this... It's a beer truck!
 
 
  • Post #10
  • Quote
  • Edited 6:21am Sep 24, 2012 1:52am | Edited 6:21am
  •  cja
  • Joined Feb 2007 | Status: Member | 1,980 Posts
I have removed my script, please use the updated one posted by fxtr51.
Trade what you see not what you hope
 
 
  • Post #11
  • Quote
  • Sep 24, 2012 5:16am Sep 24, 2012 5:16am
  •  fxtr51
  • Joined Jan 2010 | Status: Member | 1,163 Posts
cja,
your script doesn´t work.

I modified it and now it works as it should.
Attached File(s)
File Type: mq4 Close All PENDING @ Zero trades.mq4   2 KB | 1,143 downloads
 
 
  • Post #12
  • Quote
  • Sep 24, 2012 6:13am Sep 24, 2012 6:13am
  •  cja
  • Joined Feb 2007 | Status: Member | 1,980 Posts
Quoting fxtr51
Disliked
cja,
your script doesn´t work.

I modified it and now it works as it should.
Ignored
Thanks for that I retested it and it worked most of the time however for some reason occasionally it would delete the pending orders while trades were still open when loading the script, probably not counting the open trades correctly. I guess that can be an issue when doing limited testing its very easy to miss something.

Regards CJA
Trade what you see not what you hope
 
 
  • Post #13
  • Quote
  • Last Post: Sep 24, 2012 10:57am Sep 24, 2012 10:57am
  •  hayseed
  • Joined Nov 2006 | Status: Member | 3,831 Posts
just a thought.....

it almost appears as that would max out the cpu...... have you checked.....

scripts are most often used for a one shot task..... if there is no end, they sometimes can lock things up......h

//----
//----

Inserted Code
 
 
 
//---- this would be an ea...... not a script......
 
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
 
  if(Count() == 0)  {ClosePendings();}
  return(0);
  }
//----
//----
int Count()
{
 int count=0;
 int i;
 int total=OrdersTotal();
 for(i=0;i<total;i++)
 {
  OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
 
  if(OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue;
 
   count++;
 }
 return(count);
}
//----
//----
void ClosePendings()
  {
  int total = OrdersTotal();
  for(int i=total-1;i>=0;i--)
  {
    OrderSelect(i, SELECT_BY_POS);
    if(OrderSymbol() != Symbol()) continue;
    {
    int type   = OrderType();
    bool result = false;
 
    switch(type)
    {
      case OP_BUYLIMIT  :
      case OP_BUYSTOP   :
      case OP_SELLLIMIT :
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
    }
    }  
  }
  }
to trade and code, keep both simple... no call to impress....h
 
 
  • Platform Tech
  • /
  • Need help to mod "Close All Pending Orders" script
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023