Close At Profit EA - page 3

 

EA to Close all orders after any open order hit the target.... PLS PLS PLS

Hi Dear All:

I need a Ea that can close all active and pending orders of all pairs after any active order hit its target(SL or TP) whatever it will be SL or TP. I dont care about its triggering profit or loss dear. (Just simple all orders will be closed after any active orders hit the SL or TP)

Cause for hedging sometimes its very important to minimize the loss by close all orders. PLS PLS PLS need all of your help... many many thanks to all of you....

 
mladen:
Here is a simple EA that will do exactly what you need. It has only 2 parameters : CloseAtPipsProfitand AllSymbols.
- if AllSymbolsis set to true it will look into every order, otherwise it will test only the chart symbol for profits

- if CloseAtPipsProfitis set to 0 it will examine each and every order and in combination with AllSymbols, if the profit is equal to or greater than the required one in pips, it will close the order

PS: this EA adds up order profit, order swap and order commission in order to get a real profit (it is not ignoring the swap and commission) so, in cases when commission and/or swap is present, the difference between order close price and order open price in pips might differ from the CloseAtPipsProfit parameter but the profit will be correct. Also default profit in pips is set to 0, so do not forget to set it to desired value when starting the EA

Hi M,

I did a search today for a script that will close only trades that are in profit and this sweet baby of yours, with laser-like precision as usual, does the job - or at least, is supposed to. But I have not been able to get it to work in 509 or 6xx mt4. It's been some time since you wrote it and I wonder if anything in it could have since become obsolete.

Please be kind enough to take a look at it again for a mouth-to-mouth resuscitation!!! It's too good to let go to waste now.

Also, as an EA, it remains sitting on the chart after it has done its job and could easily be forgotten there, whereupon it will close subsequent trades unintentionally. Is it possible to get it, as an EA, to de-activate itself after execution, or perhaps to simply recreate it as a script with a one-time execution? Thanks for your amazing patience with endless requests such as this.

It's at https://www.mql5.com/en/forum/181356

 
Pips4Fun:
Hi M,

I did a search today for a script that will close only trades that are in profit and this sweet baby of yours, with laser-like precision as usual, does the job - or at least, is supposed to. But I have not been able to get it to work in 509 or 6xx mt4. It's been some time since you wrote it and I wonder if anything in it could have since become obsolete.

Please be kind enough to take a look at it again for a mouth-to-mouth resuscitation!!! It's too good to let go to waste now.

Also, as an EA, it remains sitting on the chart after it has done its job and could easily be forgotten there, whereupon it will close subsequent trades unintentionally. Is it possible to get it, as an EA, to de-activate itself after execution, or perhaps to simply recreate it as a script with a one-time execution? Thanks for your amazing patience with endless requests such as this.

It's at https://www.mql5.com/en/forum/181356

Pips4Fun

I am not getting any error with it

Do you have enable live trading (or the auto trading button) checked/pressed?

 

Thanks for your prompt response.

I do not get any errors and Live Trading is enabled. I get a smiley face and have set CloseAtPipsProfit to 1.0. But all trades in profit remain unclosed.

 
Pips4Fun:
Thanks for your prompt response. I do not get any errors and Live Trading is enabled. I get a smiley face and have set CloseAtPipsProfit to 1.0. But all trades in profit remain unclosed.

Which broker?

 
mladen:
Which broker?

AlpariUK.

OK on trying again, a trade in profit has closed with AllSymbols set to false. On the same platform on another chart with AllSymbols set to true, trades in profit still remain open. Rather odd behaviour.

 
Pips4Fun:
AlpariUK. OK on trying again, a trade in profit has closed with AllSymbols set to false. On the same platform on another chart with AllSymbols set to true, trades in profit still remain open. Rather odd behaviour.

Tested it and it works

Anyway, try this one too : change the slippage to some positive number (FXCM recommends for their traders to use 3 for slippage, otherwise it will not close orders) and try it out. All symbols simply means should it try to close all the symbols regardless of the current chart symbol, or just the current chart symbol and there is no error in checking that

Also keep in mind that the EA takes into account swaps/commissions too (not just the profit part of the order), so the total of swap/commissions+profit must exceed the required amount of pips

close_all_at_pips_profit_1.01.mq4
 
mladen:
Tested it and it works

Anyway, try this one too : change the slippage to some positive number (FXCM recommends for their traders to use 3 for slippage, otherwise it will not close orders) and try it out. All symbols simply means should it try to close all the symbols regardless of the current chart symbol, or just the current chart symbol and there is no error in checking that

Also keep in mind that the EA takes into account swaps/commissions too (not just the profit part of the order), so the total of swap/commissions+profit must exceed the required amount of pips

close_all_at_pips_profit_1.01.mq4

I've fallen in love with your version already!!! Also because it takes swap and commissions into consideration. But will give this FXCM one a run and let you know how it goes.

Thanks so much for your help; and I wish you a very nice week-end.

 

Tried v1.01 with slippage at 3. Again, no trades closed with AllSymbols set to true or false. What on earth could be wrong?

 
Pips4Fun:
Tried v1.01 with slippage at 3. Again, no trades closed with AllSymbols set to true or false. What on earth could be wrong?

Sorry to ask, but how are you testing it and on what symbols?

What is it written out in the upper left corner?

Reason: