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

noob7 since: 20 Mar 2020;

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

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.

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  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

Head of Community Management at cTrader

noob7 since: 20 Mar 2020;

  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.