Scripts: ClosePosition - page 2

 

and this script only close 1 position and we must attached it to  same chart,

i was thinking it close all positions we have ; based on :


this was my Towards Understanding.

thank you all.

 
TIMisthebest:

and this script only close 1 position and we must attached it to  same chart,

i was thinking it close all positions we have ; based on :


this was my Towards Understanding.

<Link removed by moderator>

thank you all.

Yes the script close position of the current symbol only.

I removed the link as it's not allowed the post link to Market products on the forum (even free). Why not use this product if you need to close all position ?

 
angevoyageur:

Yes the script close position of the current symbol only.

I removed the link as it's not allowed the post link to Market products on the forum (even free). Why not use this product if you need to close all position ?

ok, and sorry,

i edit it again,

new build of mt5 have the solution

just for close all position .

thank you.

 
TIMisthebest:

ok, and sorry,

i edit it again,

new build of mt5 have the solution

just for close all position .

thank you.

Sorry but I miss something, which solution ?
 
angevoyageur:
Sorry but I miss something, which solution ?


i was thinking may be the older build of metatrader 5 does not have this.

----

angevoyageur:

Yes the script close position of the current symbol only.

I removed the link as it's not allowed the post link to Market products on the forum (even free). Why not use this product if you need to close all position ?

just for close all position at same time.

thank you.

 
TIMisthebest:


i was thinking may be the older build of metatrader 5 does not have this.

Ah ok, yes it's available since some times, with One Click Trading.
 

The script stopped working properly. Instead of closing positions, it opens them. ((

 
Alivru:

The script stopped working properly. Instead of closing positions, it opens them. ((

In principle, the script is made for brokers who have only one position for each currency. Because it is not clear what, in fact, to close, when the object for applying efforts is not one, but in plural.

So the problem with opening is closed, the new code will be published, but with a lot of positions it will still be incorrect.

 
fxsaber:
It's kind of self-explanatory
input int Deviation = 100;

#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006

#define Bid (SymbolInfoDouble(_Symbol, SYMBOL_BID))
#define Ask (SymbolInfoDouble(_Symbol, SYMBOL_ASK))

void OnStart()
{
  for (int i = OrdersTotal() - 1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS) && (OrderSymbol() == _Symbol) && (OrderType() <= OP_SELL))
      OrderClose(OrderTicket(), OrderLots(), (OrderType() == OP_BUY) ? Bid : Ask, Deviation);
}
Hardly! Your code, like a rhinoceros in a china shop, will just crash all positions and that's all, instead of closing the required volume. Good luck.
 
Nikolay Kositsin:
Hardly! Your code is like a rhinoceros in a china shop, it will just smash all positions and that's all, not close the required volume. Good luck.
Well, it's easy to add a closed volume to the code.