
07-16-2007, 08:28 PM
|
|
Member
|
|
Join Date: Jun 2007
Posts: 71
|
|
Quote:
Originally Posted by wallacelim
Hi John,
Pardon me if I am asking a stupid question.
Like for example if currently my GBPUSD is in 3rd progression and it hit the take profit. Is FXA0 suppose to close all trade (Like 10point3?) ??
Because base on the code in FXA0
void CloseAllOrders()
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if (OrderType()==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,slippage, Yellow); }
if (OrderType()==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask,slippage, Yellow); }
return(0);
}
}
}
It will only close the last trade (which is probably the one which hit take profit in my example). If we want to close all trade like 10point3, we should move the return (0); out like this.
void CloseAllOrders()
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if (OrderType()==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,slippage, Yellow); }
if (OrderType()==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask,slippage, Yellow); }
}
}
return (0);
}
|
It only closes the profitable trade and on the next iteration if the number of open trades is less than the protected trades, the code closes all trades. This is also a protection if someone manually closes a trade it will close all trades. (Not my idea, that one is thanks to the original 10points3 author) but no worries because all trades will be closed if profit target is reached.
|