EA to close pending orders

To add comments, please log in or register
nighthawk206
26
nighthawk206  

Ladies and Gentleman,

I have read a lot of threads here at Forex TSD and want to show sincere respect for all the programmers here who have done so much for the community and also thanx for the ppl who created this forum. Now I have a problem.

I'm looking for an EA that closes pending orders after a given time. It should have following features:

- Time after closing all pending orders in seconds. This should be a loop when pending orders are closed it should monitor when new pending orders are opened and close them again after given time.

- Stop closing pending orders (the loop) when first pending order is triggered and continues closing trades when opened trades are closed

- Recognise Trade comment OR magic number OR both. So you can trade manually at the same time without affecting trades with MN or trade comment. If I open a trade manually (without MN or trade comment) the loop still continues and closes pending orders

Have anyone come up with such an EA? or is there anyone interested in coding such an EA? I would appreciate a lot.

Mladen Rakic
127115
Mladen Rakic  

nighthawk206

Pending orders have an expiration time as a part of them. Did you try using it (since it is a much safer way than using EA for that (if the broker allows it) because, in that case, the broker must delete pending orders regardless if your PC is working or not)

nighthawk206:
Ladies and Gentleman,

I have read a lot of threads here at Forex TSD and want to show sincere respect for all the programmers here who have done so much for the community and also thanx for the ppl who created this forum. Now I have a problem.

I'm looking for an EA that closes pending orders after a given time. It should have following features:

- Time after closing all pending orders in seconds. This should be a loop when pending orders are closed it should monitor when new pending orders are opened and close them again after given time.

- Stop closing pending orders (the loop) when first pending order is triggered and continues closing trades when opened trades are closed

- Recognise Trade comment OR magic number OR both. So you can trade manually at the same time without affecting trades with MN or trade comment. If I open a trade manually (without MN or trade comment) the loop still continues and closes pending orders

Have anyone come up with such an EA? or is there anyone interested in coding such an EA? I would appreciate a lot.
nighthawk206
26
nighthawk206  

Pendings

mladen:
nighthawk206 Pending orders have an expiration time as a part of them. Did you try using it (since it is a much safer way than using EA for that (if the broker allows it) because, in that case, the broker must delete pending orders regardless if your PC is working or not)

Hi Mladen,

Thanks for your reply. No sir, that would be just way too much work if you want to close pending orders lets say every 60 seconds. But anyway thank you for your reply.

Mladen Rakic
127115
Mladen Rakic  

nighthawk206

Was going to write the following : "There is already a script in metatrader that is called "close_pending" which closes all pending orders currently opened." and then looked at the code and found that it has an error (if there is more than one pending order opened it will skip closing some pending orders).

So, instead, wrote a simple EA that can close pending orders as it should (without "forgetting" some) and in which you can choose after how many seconds after opening the pending order it should be closed (if "timeElapsed" is set to 0 or less than 0, it will close the pending order as soon as it is placed on chart, so set that parameter to the value you wish) and you can chose to close pending orders just for the current symbol or for all the symbols

nighthawk206:
Hi Mladen, Thanks for your reply. No sir, that would be just way too much work if you want to close pending orders lets say every 60 seconds. But anyway thank you for your reply.
Mladen Rakic
127115
Mladen Rakic  

PS - just an example what that script that comes with metatrader does (the case when it fails to do what it is supposed to do) :

opened 3 pending orders

dragged the script and it succeeded to close only 1 of the 3 even though it is working in a loop and should have closed all

and it is there from the start of mql4

Files:
techmac
2973
techmac  

And they are distributing that faulty code with metatrader for years? Interesting approach to quality improvement

Mladen Rakic
127115
Mladen Rakic  

Yes, it seems that that one does that "from the beginning of the time". Looked into my old saved files and it is the same script, meaning, for all these years nobody officially bothered to correct it. Nothing new (there were cases when some things were reported and they answered nonsense (just ask linixser about the "adx saga")) when refusing to acknowledge errors is in question

techmac:
And they are distributing that faulty code with metatrader for years? Interesting approach to quality improvement
techmac
2973
techmac  

They will correct it eventually : when they stop supporting metatrader 4 :):)

And then, just to keep the tradition, same stuff with metatrader 5

nighthawk206
26
nighthawk206  
mladen:
nighthawk206

Was going to write the following : "There is already a script in metatrader that is called "close_pending" which closes all pending orders currently opened." and then looked at the code and found that it has an error (if there is more than one pending order opened it will skip closing some pending orders).

So, instead, wrote a simple EA that can close pending orders as it should (without "forgetting" some) and in which you can choose after how many seconds after opening the pending order it should be closed (if "timeElapsed" is set to 0 or less than 0, it will close the pending order as soon as it is placed on chart, so set that parameter to the value you wish) and you can chose to close pending orders just for the current symbol or for all the symbols

Hi Mladen,

Thank you very much, you did it again. Great work and sorry for delay from my part, being away... I took also some time to test your EA. It works pretty nice. The idea for this EA is following:

1. An EA opens pending order 5 pips away from current price.

2. Mladen's EA will close the pending order after given time (60seconds or so)

3. The first EA will open a new pending order 5 pips away from current new price immediately when the pending order is closed (continuous loop)

4. When there is a strong movement (more than 5 pips/minute) the pending order is triggered

From this point on it would be nice if the EA stops closing pending orders till opened trades are closed so that if the strong move continues, the first EA will add more positions (open more pending orders)

One way to use it is semi automatic. You monitor the EA and close trades if they go against you or when you are happy with the profits.

This is just a rough sketch, surely there are possibilities to make it all in one EA etc... I'm not saying this is the holy grail that everyone is looking for but let's see if we can get up with something...

To add comments, please log in or register