Counting pips (with filters)
Counting pips (with filters)
14 Dec 2018, 23:53
Good night,
I have this line to count and filter open positions by layer and trade type in account collection.
LongPositionsCount = Positions.Where(pos => pos.Label == LabelBuy).Where(pos => pos.TradeType == TradeType.Buy).Count();
i need someone to help me make the same filter but making the sum of profit/loss in pips in account collection, by layer and trade type. Something like the code below, but this doesnt work.
LongPositionsInPips = Positions.Where(pos => pos.Label == LabelBuy).Where(pos => pos.TradeType == TradeType.Buy).pips();
Thank you so much and im sorry for my English.
Replies
PanagiotisCharalampous
17 Dec 2018, 11:24
Hi DelTrader,
Try something like this
var LongPositionsInPips = Positions.Where(pos => pos.Label == "Label" && pos.TradeType == TradeType.Buy).Sum(x => x.Pips);
Best Regards,
Panagiotis
@PanagiotisCharalampous
DelFonseca
17 Dec 2018, 20:33
Hi Panagiotis,
Thank you so much. Perfect.
Merry Christmas and Happy New Year. Cheers
@DelFonseca
DelFonseca
15 Dec 2018, 20:47
Hi,
This code make sense to close all trades when sum of account pips by layer are >= -100 or >= 300 ?
Thank you
@DelFonseca