> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/take-profit-and-stop-loss.md).

# Take-profit & stop-loss

Trigger orders close (part of) a position when the price crosses a level. Up to **5 TP + 5 SL** per market + side.

## At open time

Add `takeProfit` / `stopLoss` to the [open-position](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/open-and-close-positions.md) request — they're appended as trigger orders.

## On an existing position

**One trigger:**

```bash
curl -X POST $FLASH_API_URL/transaction-builder/place-trigger-order -d '{
  "marketSymbol": "SOL", "side": "LONG",
  "triggerPriceUi": "160.00", "sizeAmountUi": "0.5", "isStopLoss": false, "owner": "<WALLET>"
}'
```

`isStopLoss: false` = take-profit, `true` = stop-loss.

**TP and SL atomically:**

```bash
curl -X POST $FLASH_API_URL/transaction-builder/place-tp-sl -d '{
  "marketSymbol": "SOL", "side": "LONG",
  "takeProfitUi": "160.00", "stopLossUi": "140.00", "sizeAmountUi": "0.5", "owner": "<WALLET>"
}'
```

## Edit / cancel

```bash
# Edit replaces BOTH price and size (no keep-existing)
curl -X POST $FLASH_API_URL/transaction-builder/edit-trigger-order -d '{
  "marketSymbol": "SOL", "side": "LONG", "orderId": 0, "isStopLoss": false,
  "triggerPriceUi": "170.00", "sizeAmountUi": "0.5", "owner": "<WALLET>"
}'

# Cancel one (orderId 0–4), or all
curl -X POST $FLASH_API_URL/transaction-builder/cancel-trigger-order -d '{
  "marketSymbol": "SOL", "side": "LONG", "orderId": 0, "isStopLoss": false, "owner": "<WALLET>"
}'
curl -X POST $FLASH_API_URL/transaction-builder/cancel-all-trigger-orders -d '{
  "marketSymbol": "SOL", "side": "LONG", "owner": "<WALLET>"
}'
```

## Check before you place

Preview the PnL of a trigger price (or solve for the price that hits a target PnL/ROI) with [`preview/tp-sl`](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/preview-fees-and-pnl.md) before committing.

→ Full fields: [API reference › Trading › Trigger orders](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/trading.md#trigger-orders)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/take-profit-and-stop-loss.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
