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
intDuration=1;
boolres;
intMagicExpert=666666;
intCheckForClose(inttype){if(Duration!=0){//Lenght of time a postion is held for(inti2=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
I can't to help for you. Test this code and show me the logs.
boolres;
intMagicExpert=666666;
intCheckForClose(inttype){//Lenght of time a postion is held for(inti2=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
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
May be you take a weekend leave the hard nut next Monday ?
The girl may wait for you in Londen :)
The EA is runnig perfect
I can't to help for you. Test this code and show me the logs.
Ii's the MetaQuotes Server and The time is 2007.11.16 12:45 (:
I give you the logs after using your latest version
I give you the logs after using your latest version