Can PendingOrders.Count be split by Symbol? Label? etc

Created at 03 Jan 2018, 16:26
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!
DR

Drummond360

Joined 22.12.2017

Can PendingOrders.Count be split by Symbol? Label? etc
03 Jan 2018, 16:26


Hi all,

I'm limiting the number of Pending orders my cBot places using this variable;

             var totalOrders = PendingOrders.Count;

Is there a way to split this count according to TradeType, Symbol, etc?

For example when defining the open positions I'm using this variable;

var longPosition = Positions.Find(label, Symbol, TradeType.Buy);

Many thanks in advance...


@Drummond360
Replies

PanagiotisCharalampous
03 Jan 2018, 16:57

Hi Drummond360,

There is no straightforward way to do this however I think that with some coding it is possible. You can access the PenringOrders properties as below

PendingOrders[index].SymbolCode
PendingOrders[index].TradeType

Therefore with a loop and some checks, you should be able to split the orders.

Best Regards

Panagiotis


@PanagiotisCharalampous

Drummond360
04 Jan 2018, 11:13

Thank you for your quick reply....

I'm limiting my cBot to just 1 long and 1 short order per instance. Might this Boolean aproach work?

bool longPendingorder = false;

foreach (var order in PendingOrders)
            {
                if (order.TradeType == TradeType.Buy && order.Label == label && order.SymbolCode == Symbol.Code)
                {
                    longPendingorder = true;
                }
            }

Then I can place a long order if longPendingorder == false......?

My apologies if this is nonsesnse! As mentioned in my other posts I'm a novice with code...

 


@Drummond360

PanagiotisCharalampous
04 Jan 2018, 17:11

Hi Drummond360,

From what I see, then yes, it should work...

Best Regards,

Panagiotis


@PanagiotisCharalampous