I don't think this is right,
You can write it like this, Print("i= ",I," order number = ",orderticket ());
//You can use this to close your position.
if(order type()= = OP _ BUY)order close(order ticket(),OrderLots(),Bid,3,Blue);
if(order type()= = OP _ SELL)order close(order ticket(),OrderLots(),Ask,3,Red);