Check if there is already an open position of a specific pair

Back to topics list To post a new topic, please log in or register
avatar
7
deklin 2015.06.29 02: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);
                }
            }
        }
     }

Back to topics list  

To add comments, please log in or register