Count Positions and Pending Orders in one Symbol Only

Created at 15 Aug 2018, 21:10
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
RY

ryanoia@gmail.com

Joined 09.03.2018

Count Positions and Pending Orders in one Symbol Only
15 Aug 2018, 21:10


I understand that the PendingOrders.Count and Positions.Count syntax counts all open positions and pending orders regardless of the symbol or pair. 

Is it possible to count only pending orders and open positions in only one symbol? I would like to achieve the following operation and result:

foreach (var position in Positions)
            {
                if (position.count == 0)
                {
                         CancelPendingOrders    
                }
            }  

Then if all pending orders are canceled, execute market orders and placestoporders and stuff. 

Basically process I want to achieve is:

  1. Bot looks for symbols with no open positions
  2. If bot finds a symbol that has no open position, it cancels any pending orders therein
  3. if there are no pending orders or all pending orders are already canceled in that symbol, it executes a spot buy or sell or places a stop order at a designated pips from the ask or bid, etc.

 


@ryanoia@gmail.com