double PositionLastClosedPriceOpen(string f_symbol="",
int f_cmd=-1,
int f_magic=-1)
{
if(f_cmd==OP_BUYLIMIT || f_cmd==OP_SELLLIMIT ||
f_cmd==OP_BUYSTOP || f_cmd==OP_SELLSTOP)
return DBL_MAX;
datetime f_timeClose=0;
double f_priceOpen=DBL_MAX;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
if((f_symbol==OrderSymbol() || f_symbol=="") &&
(f_cmd ==OrderType() || f_cmd==-1) &&
(f_magic ==OrderMagicNumber() || f_magic==-1))
if(OrderCloseTime()>f_timeClose)
{
f_timeClose=OrderCloseTime();
f_priceOpen=OrderOpenPrice();
}
return f_priceOpen;
}