Hi There ...
Because you are working with any symbol you can not use things such as bid , ask, point but rather MarketInfo( OrderSymbol(), MODE_BID ), MarketInfo( OrderSymbol(), MODE_ASK ) etc ...
Try updating to this:
PHP Code:
//+------------------------------------------------------------------+
//| check profitable positions with magic 111 |
//+------------------------------------------------------------------+
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if( OrderMagicNumber()==111 )
{
if(OrderType()==OP_BUY)
{
CurrentProfitB+= MarketInfo( OrderSymbol(), MODE_BID)-OrderOpenPrice() ;
}//if(OrderType()==OP_BUY)
if(OrderType()==OP_SELL)
{
CurrentProfitS+=OrderOpenPrice()- MarketInfo( OrderSymbol(), MODE_ASK );
}//if(OrderType()==OP_SELL)
} //if( OrderSymbol()==Symbol1 && OrderMagicNumber()==111 )
CurrentProfit=CurrentProfitB+CurrentProfitS;
}// for(cnt=OrdersTotal();cnt>=0;cnt--)
//======================
PHP Code:
//+------------------------------------------------------------------+
//| Close all |
//+------------------------------------------------------------------+
void CloseAllOrd(int magic)
{
RefreshRates();
int total = OrdersTotal();
for (int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == magic)
if(IsTradeContextBusy()) Sleep(1000);
if(IsTradeContextBusy()) Sleep(2000);
if(OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),MarketInfo( OrderSymbol(), MODE_BID),slippage,White);
if(OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots(),MarketInfo( OrderSymbol(), MODE_ASK),slippage,White);
}
}
You may want to check your log for more errors but that should do it.
Patrick