← All research notes
Primer··4 min read

Take profit and stop loss: writing the exit before the entry

Abstract

Trigger orders, mark price, market versus limit, and how normalTpsl sends an entry with its exits in one signature.

Leverra Research

A stop loss you plan to place "after the entry fills" is a stop loss that sometimes never gets placed. Take-profit and stop-loss orders let you write the exit into the trade before you are in it.

Trigger orders in one paragraph

A TP or SL is a trigger order: it sits dormant until the market reaches a trigger price, then becomes a real order. A stop loss triggers when price moves against you; a take profit triggers when it moves in your favour. Both are reduce-only, so they can only shrink or close your position, never open a new one in the other direction.

What price triggers them

On Hyperliquid, TP/SL orders trigger on the mark price, not the last traded price. The mark price combines several inputs, including the oracle, so a single thin wick on the book is less likely to set off your stop. The flip side: price on the chart can briefly touch your trigger without the order firing, because the mark did not get there.

Market or limit when triggered

Once triggered, the order can execute two ways.

  • Trigger market. It becomes a market order and fills against the book. You will almost certainly get out, but in a fast move the fill can be noticeably worse than your trigger price.
  • Trigger limit. It becomes a limit order at a price you set. You control the worst price, but if the market gaps through it, the order may sit unfilled while price keeps going.

For stop losses, most traders prefer trigger market: getting out matters more than the exact price. For take profits, a limit is often fine, since missing a fill in your favour costs nothing but the opportunity.

Attaching TP/SL to an entry

Hyperliquid groups orders with a grouping field on the order action:

GroupingMeaning
naplain orders, no link between them
normalTpslTP/SL orders attached to the entry order sent with them
positionTpslTP/SL orders attached to the whole open position

With normalTpsl, you send the entry and its TP and SL in one signed action. The TP and SL are sized to the entry and only become active as the entry fills. That closes the gap between "my order filled" and "I placed my stop".

The Leverra terminal uses normalTpsl when you fill in TP or SL fields in the order ticket. One signature, one request, three orders.

Where to put them

The stop

Put the stop where your trade idea is wrong, not at a round number of dollars. Then size the position so that a stop-out loses the amount you planned. The position sizing note has the formula.

Two hard rules:

  1. The stop must sit well before your liquidation price. If liquidation comes first, the exchange exits for you at a worse place. Check with the liquidation formula.
  2. Leave room for slippage. A trigger-market stop on a thin market can fill some distance past the trigger.

The take profit

A fixed take profit is a choice to cap the upside in exchange for certainty. Common approaches:

  • a fixed reward-to-risk multiple of the stop distance,
  • a level where the order book or recent price history suggests resistance,
  • a partial take profit, leaving the rest of the position running.

None is right in general. Pick one and apply it the same way every time, so you can judge the results.

Where TP/SL can surprise you

  • Gaps. If the mark jumps past your stop between two updates, a trigger market fills at whatever the book offers then.
  • Partial entries. With normalTpsl, if only part of a limit entry fills, the TP/SL cover the filled part.
  • Changing the position later. Adding to a position does not automatically resize TP/SL that were attached to the original entry. Check your open orders after you add.
  • Cancelling the entry. If you cancel an unfilled entry, check that its attached TP/SL were cancelled with it.

A note for builders

If you sign Hyperliquid orders yourself, the trigger part of an order is its own object with a fixed field order: isMarket, triggerPx, then tpsl ("tp" or "sl"). Because the action is hashed with MessagePack, which keeps key order, a different order produces a different hash and a signature the server will not accept. The note on agent keys explains the signing scheme.

In the Leverra terminal

TP and SL fields sit in the order ticket next to size and leverage. Fill them in, sign once, and the entry goes out with its exits attached. Open TP/SL orders appear in the Orders tab, where you can cancel them. Nothing here is financial advice.

Sources

Research note, for information only. Not financial advice. Leverra is a permissionless on-chain prop firm for perps: capital stays with partner pools, and Leverra never holds it or guarantees payouts.