Topics
Replies
progy85
18 Nov 2021, 08:56
RE:
amusleh said:
Hi,
To get the last four values you can use OrderByDescending and Take, but on your posted sequence the values you are looking to get aren't last four.
You can first skip the last 2 values and then use Take to get the last 4 values:
var result = History.Where(trade => trade.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase)).OrderByDescending(trade => trade.EntryTime).Skip(2).Take(4).Sum(trade => trade.NetProfit);
Hi,
problem is because I need to skip winnings and find last 4 lost.
If I have
win 50
win 100
win 30
lost 15
lost 13
lost 17
win 15
lost 8
lost 12
lost 15
lost 20
win 13
My results must be: 8+12+15+20= 55
Also is ok if use Count. What I need to do Is check if last four trade in a row are lost:
win
lost
win
win
win
lost
lost
lost
win
win
lost
lost
lost
lost
win
I hope you will help me. Thanks!
progy85
18 Nov 2021, 10:06
RE:
amusleh said:
thanks!!!