# Convert stop to trailing stop after profit

**URL:** <https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805>\
**Category:** API Developers\
**Created:** [June 8, 2022, 9:57am UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805 "2022-06-08T09:57:25Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boomerang](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@Boomerang](https://community.tradovate.com/u/Boomerang)\
**Post date:** [June 8, 2022, 9:57am UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/1 "2022-06-08T09:57:25Z")

</div>

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](https://community.tradovate.com/t/modifyorderstrategy-command-schema/4529/2) 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!

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [June 8, 2022, 12:33pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/2 "2022-06-08T12:33:00Z")

</div>

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:

```auto
{ 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).

---

<div class="post-metadata">

**Author:** ![supahcullen](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@supahcullen](https://community.tradovate.com/u/supahcullen)\
**Post date:** [October 27, 2022, 5:44am UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/4 "2022-10-27T05:44:09Z")

</div>

[This](https://community.tradovate.com/t/autobreak-even-and-offset/5723) might help?

> [@Autobreak Even and Offset](https://community.tradovate.com/t/autobreak-even-and-offset/5723):
>
> Hello. Is it possible to implement a Place Order over the REST API that takes advantage of the Auto breakeven and offset functions available in the desktop brackets? Thanks!

---

<div class="post-metadata">

**Author:** ![RonM](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@RonM](https://community.tradovate.com/u/RonM)\
**Post date:** [November 22, 2022, 4:00pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/5 "2022-11-22T16:00:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [November 22, 2022, 5:29pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/6 "2022-11-22T17:29:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RonM](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@RonM](https://community.tradovate.com/u/RonM)\
**Post date:** [November 22, 2022, 6:59pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/7 "2022-11-22T18:59:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shaquille\_Miller](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Shaquille\_Miller](https://community.tradovate.com/u/Shaquille_Miller)\
**Post date:** [December 18, 2022, 4:35pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/8 "2022-12-18T16:35:37Z")

</div>

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](mailto:millershaquille533@gmail.com)

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [May 15, 2023, 1:25pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/9 "2023-05-15T13:25:46Z")

</div>

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:

```auto
{
    "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).

---

<div class="post-metadata">

**Author:** ![Mark\_heris](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Mark\_heris](https://community.tradovate.com/u/Mark_heris)\
**Post date:** [August 9, 2024, 6:12am UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/11 "2024-08-09T06:12:30Z")

</div>

Thanks @Alexander for nice explanation We are submitting Auto Trail through API .

We are sending following value

- `stopLoss` -20
- `trigger` - 20
- `freq` -5

If I manually calculate Trail Stop should get updated but it’s not getting updated.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/d/d19b2c538483cf5a59d98c87e6c11aba539d1b71.png)

Can you please help ? any help would be really appreciated. This is very good feature with Tradovate . User need to understand

---

<div class="post-metadata">

**Author:** ![Frik](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/frik/32/2627_2.png) [@Frik](https://community.tradovate.com/u/Frik)\
**Post date:** [October 9, 2024, 7:13am UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/12 "2024-10-09T07:13:22Z")

</div>

How is the breakeven field used?

---

<div class="post-metadata">

**Author:** ![Shantron](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Shantron](https://community.tradovate.com/u/Shantron)\
**Post date:** [February 10, 2025, 11:01pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/13 "2025-02-10T23:01:20Z")

</div>

Hi @Alexander

Just a quick question…  
Below i have the order im sending to tradovate, i dont see the trailing stop in the orders.  
Is there something wrong with my settings?

Im trying to do the following:  
when 8 points in profit: move SL to breakeven  
when 20 points in profit: move SL 13 points in profit

```auto

{
  "accountId": -,
  "accountSpec": "-",
  "symbol": "ESH5",
  "action": "Buy",
  "orderStrategyTypeId": 2,
  "params": {
    "entryVersion": {
      "action": "Buy",
      "symbol": "ESH5",
      "orderQty": 1,
      "orderType": "Limit",
      "price": 6085.75,
      "isAutomated": true,
      "timeInForce": "Day"
    },
    "brackets": [
      {
        "qty": 1,
        "profitTarget": 28,
        "stopLoss": -8,
        "trailingStop": false,
        "autoTrail": {
          "stopLoss": 7,
          "trigger": 20,
          "freq": 20
        },
        "breakeven": 8,
        "breakevenPlus": 0
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![Shantron](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Shantron](https://community.tradovate.com/u/Shantron)\
**Post date:** [February 10, 2025, 11:04pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/14 "2025-02-10T23:04:56Z")

</div>

Did you ever get this working?

---

<div class="post-metadata">

**Author:** ![Frik](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/frik/32/2627_2.png) [@Frik](https://community.tradovate.com/u/Frik)\
**Post date:** [February 11, 2025, 11:43am UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/15 "2025-02-11T11:43:38Z")

</div>

> [@Shantron](#):
>
> `freq`

Your freq is too big. It waits for a 20 point move before updating the stop again.

I use freq: 0.25, but freq:1 would be ok too.

---

<div class="post-metadata">

**Author:** ![Shantron](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Shantron](https://community.tradovate.com/u/Shantron)\
**Post date:** [February 11, 2025, 6:09pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/16 "2025-02-11T18:09:25Z")

</div>

But I only want to update once, when 20 points in profit the stop needs to be moved to 13p in profit

---

<div class="post-metadata">

**Author:** ![Frik](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/frik/32/2627_2.png) [@Frik](https://community.tradovate.com/u/Frik)\
**Post date:** [February 12, 2025, 1:35am UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/17 "2025-02-12T01:35:55Z")

</div>

Then it should work… Remember that 20 points (80 ticks) is huge for ES…

---

<div class="post-metadata">

**Author:** ![Shantron](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Shantron](https://community.tradovate.com/u/Shantron)\
**Post date:** [February 12, 2025, 1:54pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/18 "2025-02-12T13:54:37Z")

</div>

Am i supposed to adjust the values positively/negatively for shorting/longing or are the numbers absolute?

> [@Frik](#):
>
> Remember that 20 points (80 ticks) is huge for ES…

I am aware but I need to retire early hehe

---

<div class="post-metadata">

**Author:** ![Frik](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/frik/32/2627_2.png) [@Frik](https://community.tradovate.com/u/Frik)\
**Post date:** [February 12, 2025, 11:04pm UTC](https://community.tradovate.com/t/convert-stop-to-trailing-stop-after-profit/4805/19 "2025-02-12T23:04:53Z")

</div>

They are relative, but if your stop is never moved up because it never reach 20 points of profit, then you will end up with no profit and eventually it might hit your original stop loss and kill your retirement plans.
