What is the simplest and most efficient way to test if there is already an open position of a specific pair?
This works but is there a simpler way?
string Pair = "EURUSD";
if (OrdersTotal() > 0) {
for (int iii = OrdersTotal() - 1; iii >= 0; iii--) {
if (OrderSelect(iii, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Pair) {
Alert("There is already an open position of " + Pair);
}
}
}
}
What is the simplest and most efficient way to test if there is already an open position of a specific pair?
This works but is there a simpler way?
string Pair = "EURUSD"; if (OrdersTotal() > 0) { for (int iii = OrdersTotal() - 1; iii >= 0; iii--) { if (OrderSelect(iii, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Pair) { Alert("There is already an open position of " + Pair); } } } }