Experts: 1 Click To Close All Open Positions - page 2

 
Personally, I haven't checked the code so I don't know that it can end up in an infinite loop, but the way the discussion is going, it certainly sounds like it can

If that is the case, I'd have to agree with Alain. Your argument that it would add an extra "if" statement to control that condition and so add extra overhead, to me, just means that it's badly coded in the first place.

Murphy's Law will eventually bite you in the ass. In coding, you can't think in terms of "it will never happen", you have to think in terms of, what do I do when it DOES happen.

My 2c, off my soapbox now ;-)
 
Stuart Browne:
Personally, I haven't checked the code so I don't know that it can end up in an infinite loop, but the way the discussion is going, it certainly sounds like it can

If that is the case, I'd have to agree with Alain. Your argument that it would add an extra "if" statement to control that condition and so add extra overhead, to me, just means that it's badly coded in the first place.

Murphy's Law will eventually bite you in the ass. In coding, you can't think in terms of "it will never happen", you have to think in terms of, what do I do when it DOES happen.

My 2c, off my soapbox now ;-)

In how many ways should I say the same thing over and over again?

I know German, French and a little bit Russian. I'll write in one of those languages if you can't understand what I say.

I've never said  "it will never happen".

What I'm trying to say is, you can face with an infinite  loop if and only if broker's trading server is down &&  you have open orders && be curious enough to see what happens if you click "Close All" button.

Let me say once more when Trading server is DOWN.

It won't fall in to an infinite loop by itself, somebody has to force all these 3 conditions.

In such case, just restart the mt4. That's all. 

 
grandaevus:

In how many ways should I say the same thing over and over again?

I know German, French and a little bit Russian. I'll write in one of those languages if you can't understand what I say.

I've never said  "it will never happen".

What I'm trying to say is, you can face with an infinite  loop if and only if broker's trading server is down &&  you have open orders && be curious enough to see what happens if you click "Close All" button.

Let me say once more when Trading server is DOWN.

It won't fall in to an infinite loop by itself, somebody has to force all these 3 conditions.

In such case, just restart the mt4. That's all. 

That's fine...if you don't want to listen, don't listen, if you don't want to learn, don't learn. Stuart said it very nicely "In coding, you can't think in terms of "it will never happen".

When using your code for your self, and you don't have problem to restart MT4 to fix an issue, it's ok. When you post code publicly, you have a responsibility, at least it's how I am seeing things.

My conclusion to everyone. Don't use this code on a real account, it could lead to undesirable issues.

 

To whom it may concern,

Those who're afraid of an infinite loop, 

Just delete this sentence from the code

if(checkOrderClose==false) continue;

or

add //

// if(checkOrderClose==false) continue;
 

Forum on trading, automated trading systems and testing trading strategies

Experts: 1 Click To Close All Open Positions

grandaevus, 2016.03.19 18:01

To whom it may concern,

Those who're afraid of an infinite loop, 

Just delete this sentence from the code

if(checkOrderClose==false) continue;

or

add //

// if(checkOrderClose==false) continue;

Code has been fixed and sent to be published.

This new version doesn't contain the code written below that previous versions had which may cause an infinite loop . 

if(checkOrderClose==false) continue;

but instead brings an error control system to prevent an infinite loop while still closing all trades. 

if(checkOrderClose == false)
         {
         int errorCode = GetLastError();
         
         if (errorCode == 1 || errorCode == 2 || errorCode == 5 || errorCode == 6 || errorCode == 64 || errorCode == 65 || errorCode == 132 || errorCode == 133 || errorCode == 139) break;
         else continue;        
         }
 
This is just what I need but it made my mt4 freeze. Tried re-opening after closing but everytime I press the button it freezes. Maybe cause I'm using another EA as well on the same chart??
 

Dear Forex Advisior.

                            we are use your 1 click close all ea it is very good and nice and great ea . But we are expecting other option on the screen so that when we click on that option we want all the orders in all others pairs to be closed of in a single click i.e we want both the windows on the screen so that when we click on the first window orders in that pair must be closed off , and when we click on the second window orders in all the pairs on the platform must be closed off, 

we are expecting and we are try to your email but we are not getting so we request you send you your email .to my email .chakrradar@gmail.com 

 

we are are expect two windows . one present pair .and another second one is all pairs but option are same 

 
This is an expert for MQL4 not MQL5...what is there for MQL5? Thanks.
 
can you make it for mt5 please
Reason: