Download MetaTrader 5
To add comments, please log in or register
Code Base will help you in mastering your theoretical skills. Come and learn!
Deklin
26
Deklin 2015.06.29 00:35 

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);
                }
            }
        }
     }

/
To add comments, please log in or register