Replies

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

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
23 Jun 2022, 12:05

RE: RE: RE: RE: Code to make this work?

amusleh said:

william@hallsdesign.co.uk said:

 

Hi,

 

I have been going round in circles with this, and all I want is the current price of a pair I have. I have everything, all my code is placing a trade etc.. But only if I manually add the price in for my pair and run my code.

I have tried all the subscribing and ProtoOASpotEvent stuff. If you wouldnt mind helping me out with the exact code you did, that would be greatly appreciated. I just wish they would allow you to place a market order with a stopLoss and takeProfit without having to faff with all of this!!

Thanks in advance

 

William

Hi,

To receive live quotes of a symbol you have to send a ProtoOASubscribeSpotsReq, after that you will keep receiving ProtoOASpotEvent(s) which will contain the latest symbol bid/ask prices.

For code example please check the console sample of OpenApiPy: OpenApiPy/main.py at main · spotware/OpenApiPy (github.com)

For creating a new market order you have to send a ProtoOANewOrderReq: OpenApiPy/main.py at 50b00db0a2570d4cb62ab0a191501f49aa5ea191 · spotware/OpenApiPy (github.com)

You can set the stop loss and take profit in relative: Messages - cTrader Open API (spotware.github.io)

Hi I have a question about the MARKET orders using the ProtoOANewOrderReq message.

On setting the orderType to MARKET (1), how set the stop loss and take profit? the stopLoss and stopPrice are not allowed to use.

using relativeStopLoss also gives an error: "Relative stop loss has invalid precision". (using int not float). So I have no clue how to set this up. Using the LIMIT order it works, but I want to open a MARKET order and SL and TP needs to be LIMIT orders.

I hope someone has a solution for this?

Jo

 


@joel+ctrader