.Append not working

Created at 25 Mar 2024, 17:21
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!
PO

polepole

Joined 07.07.2023

.Append not working
25 Mar 2024, 17:21


Hello,

I have the following code:

//make a list of all BUYs
allBuys = Positions.Where(p => p.TradeType == TradeType.Buy);

//get the BUY with the highest price
var last_in = allBuys.OrderByDescending(x => x.EntryPrice).First();

//make another list of positions
var buyBundle = new[] { last_in };

//when I try this, nothing is added to buyBundle
var to_add = allBuys.OrderByDescending(x => x.EntryPrice).Last();
buyBundle.Append(to_add);

Is there something wrong with the declaration of buyBundle? Or where is the error? The compiler doesn't throw any errors.

Thank you,
Dinu


@polepole
Replies

polepole
25 Mar 2024, 21:38

[SOLVED]

The correct code is

buyBundle = buyBundle.Append(to_add).ToArray();


@polepole