Try here: https://www.mql5.com/en/forum/123595
NoIdea:
Oanda is the only broker I'm aware of where a simple close-all does not work. There may be others but, equally, there are definitely US brokers (e.g. IBFX US) where a simple close-all does work, i.e. you can loop down from OrdersTotal(), closing the newer orders first.
For accounts running on US soil this makes the existing scripts useless [...]
JC:
Oanda is the only broker I'm aware of where a simple close-all does not work. There may be others but, equally, there are definitely US brokers (e.g. IBFX US) where a simple close-all does work, i.e. you can loop down from OrdersTotal(), closing the newer orders first.
what about a script that prevents a new sell on a currency pair if their is already a sell running. or a buy on a currency pair if their is already a buy running? I cant seem to find one anywhere that does that.
Oanda is the only broker I'm aware of where a simple close-all does not work. There may be others but, equally, there are definitely US brokers (e.g. IBFX US) where a simple close-all does work, i.e. you can loop down from OrdersTotal(), closing the newer orders first.
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Close_AllOrders()
{
//Close Orders according to FIFO Rule
for(i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol())
{
switch(OrderType())
{
case OP_BUY:
Result_Close=OrderClose(OrderTicket(),OrderLots(),Bid,0);
if(Result_Close) i--;
break;
case OP_SELL:
Result_Close=OrderClose(OrderTicket(),OrderLots(),Ask,0);
if(Result_Close) i--;
break;
}
}
}
/*-------------------------------------------------------------------------------------------------*/
}
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
At present time it appears there isn't a script that will close all open positions and or reverse them in compliance with FIFO rules. For accounts running on US soil this makes the existing scripts useless because the script seeks to close positions randomly and without respecting First In First Out order imposed by this rule.
If such scripts do exist please let me know, but I haven't found them. Otherwise, I think they would be a very useful addition to MetaTrader, allowing for fast and nimble trading action under FIFO.
Thanks!
NoIdea