Last History Buy & Sell

Created at 04 Jun 2020, 17:08
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!
SE

SEOCO

Joined 23.05.2020

Last History Buy & Sell
04 Jun 2020, 17:08


Hello,

New to all of this.

How can I get the last history buy trade and last history sell trade?

I use var trade = History.Last() but then I got a buy or sell trade.

I need the following

var lastBuyTrade = History.Last().BUY or something

var lastSellTrade = History.Last().SELL or something

 

Any idea?

Thx,

Mario

 


@SEOCO
Replies

PanagiotisCharalampous
05 Jun 2020, 08:16

Hi Mario,

See below an example

var lastBuy = History.Where(x => x.TradeType == TradeType.Buy).Last();

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

SEOCO
05 Jun 2020, 21:30

RE:

PanagiotisCharalampous said:

Hi Mario,

See below an example

var lastBuy = History.Where(x => x.TradeType == TradeType.Buy).Last();

Best Regards,

Panagiotis 

Join us on Telegram

 

Hello thanks for this information.

It still don't work as it should be.

I need to get the last trade history for a specific symbol but my code is not 100% correct. Any idea?

It should be:

- get last buy information from from history where symbolname=symbol.name and tradetype = tradetype.buy"

and 

- get last sell information from from history where symbolname=symbol.name and tradetype = tradetype.sell"

This is my code for the buy part but I think it is not 100% correct:

if (History.Count(x => x.SymbolName == Symbol.Name) > 0 && History.Count(x => x.TradeType == TradeType.Buy) > 0)
            {
                var lastbuy = History.Last(x => x.TradeType == TradeType.Buy);
                ...

Any help would be appreciated.

Thx,

Mario

 


@SEOCO

PanagiotisCharalampous
09 Jun 2020, 09:19

Hi Mario,

See below an example for buy orders

var lastBuy = History.Where(x => x.TradeType == TradeType.Buy && x.SymbolName == Symbol.Name).Last();

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

SEOCO
15 Jun 2020, 15:46

RE:

PanagiotisCharalampous said:

Hi Mario,

See below an example for buy orders

var lastBuy = History.Where(x => x.TradeType == TradeType.Buy && x.SymbolName == Symbol.Name).Last();

Best Regards,

Panagiotis 

Join us on Telegram

 

Thx mate,

So simple and still I was strugling with it.

/Mario


@SEOCO