How to open one position per pair

 

Hi, 


I have found a lot of outdated codes on the form in regard to this topic. What is the quickest way to open 1 positon per pair?

I'm using the code below which one open 1 pair and 1 trade but I wish to open 1 trade for each pair I select. Thanks


if(((OrdersTotal()==0) && (PositionsTotal()==0))
       {
   
 
    
       
       trade.SellStop
       (
       BuyAmount,                        // Lot size
       BidPrice,             // Entry price
        _Symbol,                       // Current pair
       BidStopLoss,            // Stop loss
       BidTakeProfit,            // Take profit
       ORDER_TIME_DAY,                 //effective till 23:59:59 of the specified day
       0,                              // Expire date
       ""
       );   
       }
 
mrwick:

I have found a lot of outdated codes on the form in regard to this topic. What is the quickest way to open 1 positon per pair?

I'm using the code below which one open 1 pair and 1 trade but I wish to open 1 trade for each pair I select. Thanks

If you deal with pending orders, then you'll have to iterate through all orders to check for that their symbol does not equal _Symbol.

As for positions, a simple PositionSelect(_Symbol) will return true only if a position already exists for _Symbol.

 
Seng Joo Thio:

If you deal with pending orders, then you'll have to iterate through all orders to check for that their symbol does not equal _Symbol.

As for positions, a simple PositionSelect(_Symbol) will return true only if a position already exists for _Symbol.

Thank you Seng for the advice. :)