Функция поиска открытых ордеров

FXWizard

Гуру форума
//+------------------------------------------------------------------+
//| Поиск открытых ордеров |
//+------------------------------------------------------------------+
bool ExistPositions( int type_ord) //================
{
int ot=0;

for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{


if(OrderType() == OP_BUYSTOP)
ot = 1;

if(OrderType() == OP_SELLSTOP)
ot = 2;

if(OrderType() == OP_BUY)
ot = 4;

if(OrderType() == OP_SELL)
ot = 5;

if(type_ord == ot)
return(True);
}

}
return(false);
}
 

FXWizard

Гуру форума
Пример применения:
если надо проверить, открыт ли в рынке ордер BUY

if (ExistPositions(4) == true){

}

если надо убедится, что ордер BUY не открыт

if (ExistPositions(4) == false){

}
 
Верх