# Take-Profit and Stop-Loss Guide

## What are take-profit and stop-loss orders?

Take-profit and stop-loss orders are conditional trigger orders that automatically close your position when the market reaches a price you set in advance. You do not need to be watching the market for them to fire.

**A take-profit order** closes your position when the price reaches your target profit level. For a long position, the take-profit triggers when the price rises to your target. For a short position, it triggers when the price falls to your target.

**A stop-loss order** closes your position when the price moves against you by a set amount. For a long position, the stop-loss triggers when the price drops to your floor. For a short position, it triggers when the price rises to your ceiling.

Together, TP and SL let you define the range you are comfortable with before you enter a trade, so your exits are handled automatically regardless of what happens while the position is open.

## How are they different from regular sell orders?

This distinction is critical and a common source of mistakes.

A **limit sell** at a given price means "sell at that price or higher." If the market is already above that price when you place the order, it fills immediately at market price. This is not a stop-loss.

A **stop-loss** waits. It is a conditional trigger that only fires when the market reaches your specified level. It does not execute until that condition is met.

Using a limit sell to simulate a stop-loss is one of the most common mistakes in perps trading. If you set a limit sell below the current price, it fills immediately because the market is already above it.

## How to attach TP/SL when opening a position

Add `--tp` and `--sl` to any order market or order limit command. This places your main order and the trigger orders together as a group, so your exits are set from the moment the trade opens:

```bash
byreal-perps-cli order market long 0.01 BTC --tp 110000 --sl 90000
byreal-perps-cli order limit buy 1 ETH 3000 --sl 2800
```

The trigger orders are reduce-only, meaning they can only close your position. They cannot accidentally open a new one.

## How to set TP/SL on a position you already have open

Use `position tpsl` with the coin name and your target prices:

```bash
byreal-perps-cli position tpsl BTC --tp 110000 --sl 90000
```

To set only a stop-loss without a take-profit, use `--sl` on its own. To view what you currently have set, run `position tpsl BTC` with no flags. To cancel one or both:

* `byreal-perps-cli position tpsl BTC --cancel-tp` removes the take-profit
* `byreal-perps-cli position tpsl BTC --cancel-sl` removes the stop-loss

When you set new TP/SL on a position that already has them, the old orders are cancelled first before the new ones are placed. The CLI retries up to twice and restores the old orders if the new ones fail to place.

## Common mistakes to avoid

| Situation                                  | Wrong approach                       | Why it fails                                              | Correct approach                        |
| ------------------------------------------ | ------------------------------------ | --------------------------------------------------------- | --------------------------------------- |
| Set a stop-loss on an open BTC long        | Place a market sell order            | Closes the position immediately at market price           | `position tpsl BTC --sl 90000`          |
| Open a long with a stop-loss               | Place a limit sell at the stop price | If price is already above that level, it fills right away | `order market long 0.01 BTC --sl 90000` |
| Update a stop-loss on an existing position | Place a new sell order               | Opens a new short or closes the position at market        | `position tpsl BTC --sl <new price>`    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.byreal.io/byreal-perps-agent-skills/tp-sl-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
