OrdersCount function allows to get the orders count of predefined type.
Example:
Inserted Code
int OrdersCount(int type)
{
int orders = 0;
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) orders++;
}
return (orders);
} Example:
Inserted Code
int start()
{
int BuyCnt = OrdersCount(OP_BUY);
if (BuyCnt > 0) return (0);
... MQL4: idea * experience + creative solution