Hi
I just started using TargetCloseAllTradesBE with the EmergPairLossPerc option (line 37), on BnG pg88. I identify the EA this way because their are same name EAs without the newest option.
The problem is "TargetCloseAllTradesBE" when "EmergPairLossPerc" calls for "ClosePair (symbol)" in BnG the errors are caused by the pending orders. The pending orders do get closed evently but with nuuuuuumerous failures. When you have hundreds of pending it can a lot of failures. We need a EA coder to close pending orders properly.
Thank you for your help
Ray
See attached:
TargetCloseAllTradesBE" when it "ClosePair (symbol)"
- traderduke
- Trader
- Posts: 306
- Joined: Mon Nov 28, 2011 7:30 pm
- Location: East Coast USA
TargetCloseAllTradesBE" when it "ClosePair (symbol)"
You do not have the required permissions to view the files attached to this post.
- renexxxx
- Trader
- Posts: 860
- Joined: Sat Dec 31, 2011 3:48 am
TargetCloseAllTradesBE" when it "ClosePair (symbol)"
Your version of ClosePair(string pair):traderduke » Sat Jul 30, 2016 11:36 pm wrote:We need a EA coder to close pending orders properly.
Code: Select all
void ClosePair(string pair)
{
for (int i = OrdersTotal()-1 ; i >=0 ; i--)
{
if ( !OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) continue;
if ( OrderSymbol() != pair) continue;
int ticket = OrderTicket();
while(IsTradeContextBusy()) Sleep(100);
if (!OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) continue;
bool res = OrderClose(ticket, OrderLots(), OrderClosePrice(), 3, CLR_NONE);
if(res)
Alert("Order #" + IntegerToString(ticket) + " was closed.");
else
Alert("Closing order failed: " + ErrorDescription(GetLastError()));
Alert("Closed Losing Pair ",pair, " <",DoubleToStr(EmergPairLossPerc,1));
}
return;
}Code: Select all
if ( OrderSymbol() != pair) continue;
if ( (OrderType() != OP_BUY) && (OrderType() != OP_SELL) ) continue;
Code: Select all
bool res = false;
if ( (OrderType() == OP_BUY) || (OrderType() == OP_SELL) ) {
res = OrderClose(ticket, OrderLots(), OrderClosePrice(), 3, clrNONE);
}
else {
res = OrderDelete( ticket, clrNONE );
}
if(res)
Alert("Order #" + IntegerToString(ticket) + " was closed.");
else
Alert("Closing order failed: " + ErrorDescription(GetLastError()));
And, one other thing, get rid of the second OrderSelect() ... the order has already been selected, no need to select it again.
R.
- traderduke
- Trader
- Posts: 306
- Joined: Mon Nov 28, 2011 7:30 pm
- Location: East Coast USA
TargetCloseAllTradesBE" when it "ClosePair (symbol)"
Rene
Thanks for your help, I'll test it this week!
Ray
Thanks for your help, I'll test it this week!
Ray