Getting new portion event with takeprofit and stoploss in one event

Created at 15 Sep 2021, 11:14
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!
olegchubukov's avatar

olegchubukov

Joined 23.08.2019

Getting new portion event with takeprofit and stoploss in one event
15 Sep 2021, 11:14


Hey there!

As long as I know two events are sent when opening a new order with a takeprofit and stoploss in cTrader terminal.

I am going to forward new orders/positions to mt4 terminal. This means I have to make to calls to mt4 as well.

Is there a way or a known workaround of getting new position notifications with takeprofit and stoploss in one event from cTrader?

 

Thanks

Oleg


@olegchubukov
Replies

amusleh
17 Sep 2021, 08:58

Try to use Execution event when the type is either OrderFilled or OrderPartialFill, those response types will have stop loss and take profit of the filled order (position).

 


@amusleh

olegchubukov
17 Sep 2021, 09:21

RE:

amusleh said:

Try to use Execution event when the type is either OrderFilled or OrderPartialFill, those response types will have stop loss and take profit of the filled order (position).

 

That's exactly the problem. Stoplosses and takeprofits do not come in the ORDER_FILLED event, but in ORDER_ACCEPTED event under order type STOP_LOSS_TAKE_PROFIT.


@olegchubukov

... Deleted by UFO ...

amusleh
17 Sep 2021, 09:50

Hi,

The response for order filled contains both relative stop loss and relative take profit, here is an actual response for order filled Type:

{
   {
      "ctidTraderAccountId":"532255",
      "executionType":"ORDER_FILLED",
      "position":{
         "positionId":"239668487",
         "tradeData":{
            "symbolId":"1",
            "volume":"100000",
            "tradeSide":"BUY",
            "openTimestamp":"1631861204356",
            "guaranteedStopLoss":false
         },
         "positionStatus":"POSITION_STATUS_OPEN",
         "swap":"0",
         "price":1.1774,
         "utcLastUpdateTimestamp":"1631861204356",
         "commission":"-4",
         "marginRate":1.1774,
         "mirroringCommission":"0",
         "guaranteedStopLoss":false,
         "usedMargin":"235",
         "moneyDigits":2
      },
      "order":{
         "orderId":"359826732",
         "tradeData":{
            "symbolId":"1",
            "volume":"100000",
            "tradeSide":"BUY",
            "openTimestamp":"1631861204118",
            "guaranteedStopLoss":false
         },
         "orderType":"MARKET",
         "orderStatus":"ORDER_STATUS_FILLED",
         "executionPrice":1.1774,
         "executedVolume":"100000",
         "utcLastUpdateTimestamp":"1631861204356",
         "closingOrder":false,
         "clientOrderId":"ctd-1fa7f52eaa5946f0a79b1f18ec6b413d",
         "timeInForce":"IMMEDIATE_OR_CANCEL",
         "positionId":"239668487",
         "relativeStopLoss":"150",
         "relativeTakeProfit":"150",
         "trailingStopLoss":false
      },
      "deal":{
         "dealId":"330052413",
         "orderId":"359826732",
         "positionId":"239668487",
         "volume":"100000",
         "filledVolume":"100000",
         "symbolId":"1",
         "createTimestamp":"1631861204118",
         "executionTimestamp":"1631861204356",
         "utcLastUpdateTimestamp":"1631861204356",
         "executionPrice":1.1774,
         "tradeSide":"BUY",
         "dealStatus":"FILLED",
         "marginRate":1.1774,
         "commission":"-4",
         "baseToUsdConversionRate":1.1774,
         "moneyDigits":2
      },
      "isServerEvent":false
   }
}

You see the order has two fields, one for relative stop loss and another for relative take profit.


@amusleh

olegchubukov
17 Sep 2021, 10:18

RE:

amusleh said:

Hi,

The response for order filled contains both relative stop loss and relative take profit, here is an actual response for order filled Type:

{
   {
      "ctidTraderAccountId":"532255",
      "executionType":"ORDER_FILLED",
      "position":{
         "positionId":"239668487",
         "tradeData":{
            "symbolId":"1",
            "volume":"100000",
            "tradeSide":"BUY",
            "openTimestamp":"1631861204356",
            "guaranteedStopLoss":false
         },
         "positionStatus":"POSITION_STATUS_OPEN",
         "swap":"0",
         "price":1.1774,
         "utcLastUpdateTimestamp":"1631861204356",
         "commission":"-4",
         "marginRate":1.1774,
         "mirroringCommission":"0",
         "guaranteedStopLoss":false,
         "usedMargin":"235",
         "moneyDigits":2
      },
      "order":{
         "orderId":"359826732",
         "tradeData":{
            "symbolId":"1",
            "volume":"100000",
            "tradeSide":"BUY",
            "openTimestamp":"1631861204118",
            "guaranteedStopLoss":false
         },
         "orderType":"MARKET",
         "orderStatus":"ORDER_STATUS_FILLED",
         "executionPrice":1.1774,
         "executedVolume":"100000",
         "utcLastUpdateTimestamp":"1631861204356",
         "closingOrder":false,
         "clientOrderId":"ctd-1fa7f52eaa5946f0a79b1f18ec6b413d",
         "timeInForce":"IMMEDIATE_OR_CANCEL",
         "positionId":"239668487",
         "relativeStopLoss":"150",
         "relativeTakeProfit":"150",
         "trailingStopLoss":false
      },
      "deal":{
         "dealId":"330052413",
         "orderId":"359826732",
         "positionId":"239668487",
         "volume":"100000",
         "filledVolume":"100000",
         "symbolId":"1",
         "createTimestamp":"1631861204118",
         "executionTimestamp":"1631861204356",
         "utcLastUpdateTimestamp":"1631861204356",
         "executionPrice":1.1774,
         "tradeSide":"BUY",
         "dealStatus":"FILLED",
         "marginRate":1.1774,
         "commission":"-4",
         "baseToUsdConversionRate":1.1774,
         "moneyDigits":2
      },
      "isServerEvent":false
   }
}

You see the order has two fields, one for relative stop loss and another for relative take profit.

Oh, those ones! Great! A bit math and here we go. Didn't get that those numbers were points, not pips. Thank you!


@olegchubukov