Dear Mr. Rosh,To close orders - 页 2

 

I change a little and nothing happened

See the program and picture like below

int CheckForClose(int type)
{
if (Duration!=0)
{ //Lenght of time a postion is held

for(int i2=OrdersTotal()-1;i2>=0;i2--)
{
if(!OrderSelect(i2,SELECT_BY_POS,MODE_TRADES)) continue;
// if(OrderMagicNumber()!=MagicExpert) continue;
//if (OrderOpenTime()<TimeCurrent()-Duration*60*720)
{//Duration*60*720
if (OrderType()==OP_BUY)
{
int res=OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
if (res!=0) Print("Order #",OrderTicket()," Close is failed with error ", GetLastError());
}
if (OrderType()==OP_SELL)
{
res=OrderClose(OrderTicket(), OrderLots(), Ask,3, Violet);
if (res!=0) Print("Order #",OrderTicket()," Close is failed with error ", GetLastError());
}
}// end if(OrderOpenTime()<TimeCurrent()-Duration*60*720)
}// end for(int i2=OrdersTotal();i2>=0;i2--)
} //end duration check
}//end check for close

 
I made a mistype. Correct please.
int  Duration=1;
bool res; 
int MagicExpert=666666;
 
int CheckForClose(int type)
 {
  if (Duration!=0)
   { //Lenght of time a postion is held 
 
    for(int i2=OrdersTotal()-1;i2>=0;i2--)
     {
     if(!OrderSelect(i2,SELECT_BY_POS,MODE_TRADES))        continue;
      if(OrderMagicNumber()!=MagicExpert) continue;
       //if (OrderOpenTime()<TimeCurrent()-Duration*60*720)
        {//Duration*60*720 
         if (OrderType()==OP_BUY)
          {
          res=OrderClose(OrderTicket(),OrderLots(),Bid,3,Yellow);
          if (!res) Print("Order #",OrderTicket()," Close is failed with error ",GetLastError());
          }
         if (OrderType()==OP_SELL)
          {
          res=OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
          if (!res) Print("Order #",OrderTicket()," Close is failed with error ",GetLastError());
          }
        }// end if(OrderOpenTime()<TimeCurrent()-Duration*60*720)
     }// end for(int i2=OrdersTotal();i2>=0;i2--)
   }   //end duration check
 }//end check for close
 
 

May be you take a weekend leave the hard nut next Monday ?

The girl may wait for you in Londen :)

 
Still nothing happened (:
 

The EA is runnig perfect

 
No, it is 11 hours and 18 minutes



I can't to help for you. Test this code and show me the logs.


bool res; 
int MagicExpert=666666;
 
int CheckForClose(int type)
   { //Lenght of time a postion is held 
 
    for(int i2=OrdersTotal()-1;i2>=0;i2--)
     {
     if(!OrderSelect(i2,SELECT_BY_POS,MODE_TRADES))        continue;
      if(OrderMagicNumber()!=MagicExpert) 
         {
         Print("Order #",OrderTicket()," skipped")
         continue;
         }
         Print("Try to close order #",OrderTicket());
         if (OrderType()==OP_BUY)
          {
          res=OrderClose(OrderTicket(),OrderLots(),Bid,3,Yellow);
          if (!res) Print("Order #",OrderTicket()," Close is failed with error ",GetLastError());
          }
         if (OrderType()==OP_SELL)
          {
          res=OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
          if (!res) Print("Order #",OrderTicket()," Close is failed with error ",GetLastError());
          }
     }// end for(int i2=OrdersTotal();i2>=0;i2--)
   }//end check for close
 

Ii's the MetaQuotes Server and The time is 2007.11.16 12:45 (:

 

I give you the logs after using your latest version

附加的文件:
aaa_1.txt  12 kb
 

I give you the logs after using your latest version

附加的文件:
aaa.txt  12 kb
原因: