Thread: 10points 3.mq4
View Single Post
  #2797 (permalink)  
Old 07-16-2007, 02:54 PM
wallacelim wallacelim is offline
Junior Member
 
Join Date: Jan 2007
Posts: 2
wallacelim is on a distinguished road
FXA0 - Ladderv0.01.mq4

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);
}
Reply With Quote