//--------------------------------------------------------------------- // Retrieves the opening time of the last specified type of order. //--------------------------------------------------------------------- #property copyright "© RickD 2006-2007" #property link "www.e2e-fx.net" //--------------------------------------------------------------------- // type - OP_BUY/OP_SELL //--------------------------------------------------------------------- datetime GetLastOpenTime(int type) { datetime tm = -1; int cnt = OrdersTotal(); for (int i=0; i < cnt; i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; //if (OrderSymbol() != Symbol()) continue; //if (OrderMagicNumber() != Magic) continue; if (OrderType() != type) continue; tm = MathMax(tm, OrderOpenTime()); } cnt = HistoryTotal(); for (i=0; i < cnt; i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue; //if (OrderSymbol() != Symbol()) continue; //if (OrderMagicNumber() != Magic) continue; if (OrderType() != type) continue; tm = MathMax(tm, OrderOpenTime()); } return (tm); }