How to setup stop loss when opening a Market order

Created at 30 Aug 2022, 20:44
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!
JO

joel+ctrader

Joined 23.06.2022

How to setup stop loss when opening a Market order
30 Aug 2022, 20:44


I use ProtoOANewOrderReq to create a market order, but the SL settings are not taking/allowed.
None of the below options are taken so how to setup this?

request = ProtoOANewOrderReq()
request.ctidTraderAccountId = "xxxxxxxx"
request.symbolId = <int>
request.orderType = 1 # market order
request.tradeSide = "buy"
request.volume = 100

# Below settings are not taking / working also tried different combinations:
request.relativeStopLoss = 
request.stopPrice = float(currentprice - 3%)
request.stopTriggerMethod = 1

The workaround I have now is to update the position after the order has been filled using ProtoOAAmendPositionSLTPReq. This is not a very trustworthy method, and I want to set the TP and SL settings on order creation (the same like create a LIMIT order).

Any help is very welcome!

Thx!


@joel+ctrader
Replies

PanagiotisCharalampous
31 Aug 2022, 08:48

Hi there,

For Marker Orders you need to set the relativeStopLoss. stopPrice is not supported for Market orders.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

joel+ctrader
31 Aug 2022, 10:02 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi there,

For Marker Orders you need to set the relativeStopLoss. stopPrice is not supported for Market orders.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Cool! Thx for the reply! I will give this a try later today and let you know. For the relativeStopLoss what kind of value do I need to enter here? In the description it state:

Relative Stop Loss that can be specified instead of the absolute as one.
Specified in 1/100000 of unit of a price.

For BUY stopLoss = entryPrice - relativeStopLoss,
for SELL stopLoss = entryPrice + relativeStopLoss.

So I still don't know what kind of value should be set here because now the write about a stopLoss again. This is a bit confusing.

Do you also know if we can schedule an order if the market is closed it will be filled the next day the market will open again. Maybe been to use order time if force MARKET_ON_OPEN perhaps?

Jo


@joel+ctrader

joel+ctrader
31 Aug 2022, 16:32 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi there,

For Marker Orders you need to set the relativeStopLoss. stopPrice is not supported for Market orders.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Okay again thx for pointing me this out. But unfortunately it is not the solution.

I have try the below values, it accept the order, but the SL has not been set.

request.relativeStopLoss = 1000
request.trailingStopLoss = True

Below the output in json format. There you see also the relativeStopLoss has been set, but it is not activated:

{
    'ctidTraderAccountId': '*******',
    'executionType': 'ORDER_ACCEPTED',
    'position': {
        'positionId': '4084654',
        'tradeData': {
            'symbolId': '270',
            'volume': '0',
            'tradeSide': 'SELL',
            'guaranteedStopLoss': False,
            'comment': '*****'
        },
        'positionStatus': 'POSITION_STATUS_CREATED',
        'swap': '0',
        'price': 0.0,
        'commission': '0',
        'marginRate': 0.0,
        'mirroringCommission': '0',
        'guaranteedStopLoss': False,
        'usedMargin': '0',
        'moneyDigits': 2,
        'trailingStopLoss': True
    },
    'order': {
        'orderId': '*****',
        'tradeData': {
            'symbolId': '270',
            'volume': '100',
            'tradeSide': 'SELL',
            'openTimestamp': '1661952264351',
            'guaranteedStopLoss': False,
            'comment': '******'
        },
        'orderType': 'MARKET',
        'orderStatus': 'ORDER_STATUS_ACCEPTED',
        'executedVolume': '0',
        'utcLastUpdateTimestamp': '1661952264351',
        'closingOrder': False,
        'clientOrderId': 'log_id::ea2cff4b-4e57-4d40-8649-a0c7bbb40481',
        'timeInForce': 'IMMEDIATE_OR_CANCEL',
        'positionId': '******',
        'relativeStopLoss': '1000',
        'trailingStopLoss': True
    },
    'isServerEvent': False
}

Below you can see the SL and TSL are not activated.

What els do I have to send to enable the SL?


@joel+ctrader

PS_Prop
16 Sep 2022, 21:42 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE:

joel+ctrader said:

PanagiotisCharalampous said:

Hi there,

For Marker Orders you need to set the relativeStopLoss. stopPrice is not supported for Market orders.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Okay again thx for pointing me this out. But unfortunately it is not the solution.

I have try the below values, it accept the order, but the SL has not been set.

request.relativeStopLoss = 1000
request.trailingStopLoss = True

Below the output in json format. There you see also the relativeStopLoss has been set, but it is not activated:

{
    'ctidTraderAccountId': '*******',
    'executionType': 'ORDER_ACCEPTED',
    'position': {
        'positionId': '4084654',
        'tradeData': {
            'symbolId': '270',
            'volume': '0',
            'tradeSide': 'SELL',
            'guaranteedStopLoss': False,
            'comment': '*****'
        },
        'positionStatus': 'POSITION_STATUS_CREATED',
        'swap': '0',
        'price': 0.0,
        'commission': '0',
        'marginRate': 0.0,
        'mirroringCommission': '0',
        'guaranteedStopLoss': False,
        'usedMargin': '0',
        'moneyDigits': 2,
        'trailingStopLoss': True
    },
    'order': {
        'orderId': '*****',
        'tradeData': {
            'symbolId': '270',
            'volume': '100',
            'tradeSide': 'SELL',
            'openTimestamp': '1661952264351',
            'guaranteedStopLoss': False,
            'comment': '******'
        },
        'orderType': 'MARKET',
        'orderStatus': 'ORDER_STATUS_ACCEPTED',
        'executedVolume': '0',
        'utcLastUpdateTimestamp': '1661952264351',
        'closingOrder': False,
        'clientOrderId': 'log_id::ea2cff4b-4e57-4d40-8649-a0c7bbb40481',
        'timeInForce': 'IMMEDIATE_OR_CANCEL',
        'positionId': '******',
        'relativeStopLoss': '1000',
        'trailingStopLoss': True
    },
    'isServerEvent': False
}

Below you can see the SL and TSL are not activated.

What els do I have to send to enable the SL?

 

If you want a 10 point SL, set relativeStopLoss to 10 * 100000


@PS_Prop