Convert stop to trailing stop after profit

Hello!

I have all of my trade signals working but now having some issues with execution or best way to execute the trade. Here is an example scenario:

  • I get a long signal, which I first execute with a defined stop + target profit
  • Once I hit a certain amount of profit, I’d like the stop to turn into a trailing stop starting at breakeven or some trailing amount.

I’m using the content in this post as initial thoughts: modifyOrderStrategy command schema - #2 by Howard but it doesn’t quite handle my use case

I know in the UI of tradovate, we have options of having an “Auto-breakeven” stop. I have a vague suspicion I could submit a trailing stop after my code watches the trade for whatever initial profit I want (or update the existing order?) but was wondering if there is a way to “finesse” it on Tradovate server-side.

Thanks!

As it stands there is no ‘native’ way to do this. You can watch for events via websocket, and send orders based on what happens in real-time. But keep in mind: disconnects can affect the outcome of a strategy that relies on watching events to escape a bad position, rather than a bracket strategy/OCO/OSO which is guaranteed to work within its good-until period, stable connection or not. Relying on this type of mechanism to take excess profit in select scenarios sounds less risky, however.

With that in mind and the disclaimer above, watch for the execution of your profit-target order from the WebSocket. You’re looking for an event object like this:

{ e: 'props', entityType: 'executionReport', entity: ExecutionReport }

Once filled, you can submit a trailing stop via API as an attempt to continue to ride the momentum of a market move. I’d suggest the trailing stop because it will automatically tap out, so once submitted you won’t have to watch the websocket events anymore.

I would not suggest using this strategy to close via market order, or to close positions using /order/liquidatePosition. Additionally, relying on a similar strategy to call order/cancelOrder is also not advised (a disconnected websocket can’t cancel an order, for example).

This might help?

Alexander, you are the leader here. Please tell me straight up, is auto trading really working on Tradovate, or delays, issues are such that it is kind of working but not really??? I have a strategy on Tradingview that works, I want to code it on Tradovate. Is it worth my time and money? If yes, can you recommend someone who can rewrite my strategy and make it work on Tradovate? I need to know before I go elsewhere. Thank you

Hi Ron, this is a bit off-topic here, but that’s OK.

The recent changes to CME Market Data Requirements have made it slightly more difficult expense-wise to use our API for automated trading. However, if you’re willing to pay the CME’s MD distributors’ rates, then there should be no problems with the API once it has been enabled for your user. The API is and has been fully functional for retail users since ~2020. Bear in mind we use our own API as the backbone of the Tradovate Trader application.

1 Like

Alexander, can you direct me or recommend a developer who can make it happen for me. I have the code in Pine Script on Tradingview. I made a mistake, thinking since I run my Tradovate trades on Tradingview, I assumed that I will not have problems executing the orders on Traingview, sadly it’s not happening. I need someone to make it happen for me, rewrite the code in whatever language is used on Tradovate, connect it and make it work - turn key! I am not a coder/developer, I am a trader and I have a strategy that works for me. Please help, or I am leaving Tradovate.

Roman

1 Like

Hi RonM I am a developer and I would be happy to see if I can be of assistance in using the API for automation. Could you provide a little more information about the specific tasks you are looking to automate? This will help me determine how I may be able to assist you. Thank you.
You may email me at millershaquille533@gmail.com

1 Like

Hi guys, converting to a trailing stop after an amount of profit is made is now possible. When you are creating your orderStrategy params, you simply need to add the autoTrail field to your params JSON:

{
    "accountId": XXXXX,
    "symbol": "ESM3",
    "orderStrategyTypeId": 2,
    "action": "Sell",
    "params": JSON.stringify({
        "entryVersion": {
            "orderQty": 1,
            "orderType": "Market",
            "timeInForce": "Day"
        },
        "brackets": [
            {
                "qty": 1,
                "profitTarget": -5,
                "stopLoss": 2.5,
                "trailingStop": false,
                "breakeven": 1.25,
                "autoTrail": {
                    "stopLoss": 0.25,
                    "trigger": 0.25,
                    "freq": 0.25
                }
            }
        ]
    })
}

Each of these values is read as the raw value difference (not ticks, notice that the trailing values are all divisible by the tick size .25)

autoTrail Fields

  • stopLoss - trailing distance relative to the current price
  • trigger - amount of profit in price-value before the auto-trail converts your stop to a trailing stop
  • freq - the amount of change that must occur before the trailing stop will move, or the granularity of updates. If set to the instrument tick size, this will cause the stop to move on every positive tick (‘positive’ relative to your current position).