View Single Post
  #2 (permalink)  
Old 03-29-2008, 01:48 PM
Mistigri's Avatar
Mistigri Mistigri is offline
Junior Member
 
Join Date: Mar 2006
Location: SLC
Posts: 23
Mistigri is on a distinguished road
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(cntSELECT_BY_POSMODE_TRADES);
         if( 
OrderMagicNumber()==111 )
            {
               if(
OrderType()==OP_BUY)
                  {
                     
CurrentProfitB+= MarketInfoOrderSymbol(), MODE_BID)-OrderOpenPrice() ;
                  }
//if(OrderType()==OP_BUY)
               
if(OrderType()==OP_SELL)
                  {
                     
CurrentProfitS+=OrderOpenPrice()- MarketInfoOrderSymbol(), 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 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(),MarketInfoOrderSymbol(), MODE_BID),slippage,White);
            if(
OrderType()==OP_SELL)   
             
OrderClose(OrderTicket(),OrderLots(),MarketInfoOrderSymbol(), MODE_ASK),slippage,White);
      } 

You may want to check your log for more errors but that should do it.

Patrick
Reply With Quote