Get info if position has been closed by stop loss or take profit

Created at 24 Aug 2022, 21:07
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!
NO

noob7

Joined 20.03.2020

Get info if position has been closed by stop loss or take profit
24 Aug 2022, 21:07


I have code that listens to all trading messages. I`m checking if given message is: PROTO_OA_EXECUTION_EVENT and order ClosingOrder and order type STOP_LOSS_TAKE_PROFIT. But I cannot find which of these 2 closed position. Was it by stop loss or take profit? I`m trying to use code:

 

var executionEvent = ProtoOAExecutionEvent.CreateBuilder().MergeFrom(msg.Payload).Build();

var byStopLoss = executionEvent.Order.HasStopLoss

var byTakeProfit = executionEvent.Order.HasTakeProfit

 

but they are always false.

 


@noob7
Replies

PanagiotisCharalampous
25 Aug 2022, 08:59

Hi noob7,

Did you try checking executionEvent.Position.HasStopLoss and  executionEvent.Position.HasTakeProfit?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 


@PanagiotisCharalampous

noob7
25 Aug 2022, 12:15

RE:

PanagiotisCharalampous said:

Hi noob7,

Did you try checking executionEvent.Position.HasStopLoss and  executionEvent.Position.HasTakeProfit?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 

Yes and it was false also.


@noob7