stopLoss not applied on LIMIT Order

Created at 16 Nov 2023, 10:33
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!
MP

mprusinski

Joined 12.01.2022

stopLoss not applied on LIMIT Order
16 Nov 2023, 10:33


Hello,

 

we are using cTrader OpenApi for trading purposes. For some time we have observed strange behaviour: StopLoss is not being applied on Position although it was properly sent (and acceppted by the server).

 

The scenario is as follows:

  1. LIMIT Order is being placed by our platform. Log:
Nov 16, 2023 @ 01:00:38.626
newOrder request: symbolId: 1018 orderType: LIMIT tradeSide: BUY volume: 1000000 limitPrice: 22.5308 timeInForce: IMMEDIATE_OR_CANCEL stopLoss: 22.5208 takeProfit: 22.5408 comment: "468e8235-88ea-47e0-8b53-8b232124e81d" label: "be374d8d-f748-4446-a0d2-e4650f2b6a9b" clientOrderId: "468e8235-88ea-47e0-8b53-8b232124e81d"

On which correct response was returned by cTrader server (please note presence of stopLoss: 22.5208 takeProfit: 22.5408 fields):

Nov 16, 2023 @ 01:00:38.727
newOrder response: ctidTraderAccountId: 35498021 executionType: ORDER_ACCEPTED position { positionId: 381148142 tradeData { symbolId: 1018 volume: 0 tradeSide: BUY label: "be374d8d-f748-4446-a0d2-e4650f2b6a9b" guaranteedStopLoss: false comment: "468e8235-88ea-47e0-8b53-8b232124e81d" 8: "USD" } positionStatus: POSITION_STATUS_CREATED swap: 0 price: 0.0 commission: 0 marginRate: 0.0 mirroringCommission: 0 guaranteedStopLoss: false usedMargin: 0 moneyDigits: 2 trailingStopLoss: false } order { orderId: 623105372 tradeData { symbolId: 1018 volume: 1000000 tradeSide: BUY openTimestamp: 1700092838702 label: "be374d8d-f748-4446-a0d2-e4650f2b6a9b" guaranteedStopLoss: false comment: "468e8235-88ea-47e0-8b53-8b232124e81d" 8: "USD" } orderType: LIMIT orderStatus: ORDER_STATUS_ACCEPTED executedVolume: 0 utcLastUpdateTimestamp: 1700092838702 closingOrder: false limitPrice: 22.5308 stopLoss: 22.5208 takeProfit: 22.5408 clientOrderId: "468e8235-88ea-47e0-8b53-8b232124e81d" timeInForce: GOOD_TILL_CANCEL positionId: 381148142 trailingStopLoss: false } isServerEvent: false

2. Some time later the position gets filled (so far still everything seems to be allright and both: StopLoss and TakeProfit seems to be correctly processed):

Nov 16, 2023 @ 01:49:14.299
Handling event: ctidTraderAccountId: 35498021 executionType: ORDER_FILLED position { positionId: 381148142 tradeData { symbolId: 1018 volume: 1000000 tradeSide: BUY openTimestamp: 1700095754283 label: "be374d8d-f748-4446-a0d2-e4650f2b6a9b" guaranteedStopLoss: false comment: "468e8235-88ea-47e0-8b53-8b232124e81d" 8: "USD" } positionStatus: POSITION_STATUS_OPEN swap: 0 price: 22.5308 utcLastUpdateTimestamp: 1700095754283 commission: -30 marginRate: 1.0 mirroringCommission: 0 guaranteedStopLoss: false usedMargin: 2000 moneyDigits: 2 trailingStopLoss: false } order { orderId: 623105372 tradeData { symbolId: 1018 volume: 1000000 tradeSide: BUY openTimestamp: 1700092838702 label: "be374d8d-f748-4446-a0d2-e4650f2b6a9b" guaranteedStopLoss: false comment: "468e8235-88ea-47e0-8b53-8b232124e81d" 8: "USD" 9: 1700095754283 } orderType: LIMIT orderStatus: ORDER_STATUS_FILLED executionPrice: 22.5308 executedVolume: 1000000 utcLastUpdateTimestamp: 1700095754283 closingOrder: false limitPrice: 22.5308 stopLoss: 22.5208 takeProfit: 22.5408 clientOrderId: "468e8235-88ea-47e0-8b53-8b232124e81d" timeInForce: GOOD_TILL_CANCEL positionId: 381148142 trailingStopLoss: false } deal { dealId: 581990975 orderId: 623105372 positionId: 381148142 volume: 1000000 filledVolume: 1000000 symbolId: 1018 createTimestamp: 1700095754030 executionTimestamp: 1700095754283 utcLastUpdateTimestamp: 1700095754283 executionPrice: 22.5308 tradeSide: BUY dealStatus: FILLED marginRate: 1.0 commission: -30 baseToUsdConversionRate: 1.0 moneyDigits: 2 } isServerEvent: false

3. Finally, STOP_LOSS_TAKE_PROFIT order event arrives, but WITHOUT StopLoss set (only TakeProfit was set):

Nov 16, 2023 @ 01:49:14.300
Handling event: ctidTraderAccountId: 35498021 executionType: ORDER_ACCEPTED position { positionId: 381148142 tradeData { symbolId: 1018 volume: 1000000 tradeSide: BUY openTimestamp: 1700095754283 label: "be374d8d-f748-4446-a0d2-e4650f2b6a9b" guaranteedStopLoss: false comment: "468e8235-88ea-47e0-8b53-8b232124e81d" 8: "USD" } positionStatus: POSITION_STATUS_OPEN swap: 0 price: 22.5308 takeProfit: 22.5408 utcLastUpdateTimestamp: 1700095754284 commission: -30 marginRate: 1.0 mirroringCommission: 0 guaranteedStopLoss: false usedMargin: 2000 moneyDigits: 2 } order { orderId: 623112535 tradeData { symbolId: 1018 volume: 1000000 tradeSide: SELL openTimestamp: 1700095754284 label: "be374d8d-f748-4446-a0d2-e4650f2b6a9b" guaranteedStopLoss: false comment: "468e8235-88ea-47e0-8b53-8b232124e81d" 8: "USD" } orderType: STOP_LOSS_TAKE_PROFIT orderStatus: ORDER_STATUS_ACCEPTED executedVolume: 0 utcLastUpdateTimestamp: 1700095754284 closingOrder: true limitPrice: 22.5408 clientOrderId: "468e8235-88ea-47e0-8b53-8b232124e81d" timeInForce: GOOD_TILL_CANCEL positionId: 381148142 } isServerEvent: true

 

As a result we end up with Position that has NO StopLoss active on the broker side.

 

Could you please investigate and please explain how this is even possible? This is a major problem as although correct request was made - the result is position being created without SL protection.


@mprusinski
Replies

PanagiotisCharalampous
17 Nov 2023, 07:00

Reply to: stopLoss not applied on LIMIT Order

Hi there,

This can happen if the stop loss is within the spread. What symbol are you trading and on which broker?

Best regards

Panagiotis


@PanagiotisCharalampous

mprusinski
17 Nov 2023, 09:23 ( Updated at: 18 Nov 2023, 06:03 )

RE: Reply to: stopLoss not applied on LIMIT Order

PanagiotisCharalampous said: 

This can happen if the stop loss is within the spread. What symbol are you trading and on which broker?

USDCZK on IcMarkets. You are probably right as I see, the spread was around 127pips while SL set to 100pips. Do you know if the server is sending some kind of event/information in such case to inform client that the SL was not properly set?


@mprusinski

PanagiotisCharalampous
18 Nov 2023, 06:21

Reply to: stopLoss not applied on LIMIT Order

Hi,

It does not sent a specific report, you need to check the STOP_LOSS_TAKE_PROFIT event and if not set, act accordingly.

Best regards,

Panagiotis


@PanagiotisCharalampous