> For the complete documentation index, see [llms.txt](https://docs.afx.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.afx.xyz/trading-rules/take-profit-and-stop-loss-tp-sl.md).

# Take profit and stop loss (TP/SL)

AFX provides flexible Take Profit (TP) and Stop Loss (SL) options that can be set when placing an order or added to an existing position.

## Setting TP/SL on Orders

When placing a Market or Limit order, you can attach TP and SL triggers. The default mode is **Entire Position** — the TP/SL applies to your full position for that symbol. The trigger price type defaults to **Last Price**.

TP/SL can be defined using four methods:

### 1. Trigger Price

Set a specific price at which the TP or SL should trigger. The system displays which direction (Long/Short) the TP/SL applies to and the estimated PNL.

### 2. Price Change (%)

Define the TP/SL as a percentage change from the estimated entry price.

* Long TP: Trigger Price = Entry Price × (1 + change%)
* Long SL: Trigger Price = Entry Price × (1 - change%)
* Short TP: Trigger Price = Entry Price × (1 - change%)
* Short SL: Trigger Price = Entry Price × (1 + change%)

### 3. ROI (%)

Define the TP/SL based on the return on investment, which factors in leverage.

* Long TP: Trigger Price = Entry Price × (1 + ROI% / Leverage)
* Long SL: Trigger Price = Entry Price × (1 - ROI% / Leverage)
* Short TP: Trigger Price = Entry Price × (1 - ROI% / Leverage)
* Short SL: Trigger Price = Entry Price × (1 + ROI% / Leverage)

### 4. PNL (USDC)

Set the TP/SL based on a specific profit or loss amount in USDC.

* Long: Trigger Price = PNL / Order Size + Entry Price
* Short: Trigger Price = Entry Price - PNL / Order Size

## Setting TP/SL on Positions

You can add or modify TP/SL on an existing position from the position panel. When setting TP/SL on a position:

* You can choose **Entire Position** mode or specify a custom size (**Partial** mode).
* Trigger price type supports both **Last Price** and **Mark Price**.
* The system displays estimated PNL based on the trigger price and current position parameters.

## TP/SL Behavior in One-Way Mode

In One-Way mode, TP/SL interactions follow specific rules when new orders are placed:

* **Adding to a position (same direction):** Existing TP/SL is preserved. If the new order also has TP/SL, the new settings override the existing ones.
* **Closing/reversing a position (opposite direction):** If the existing position has TP/SL, those TP/SL orders are automatically cancelled when the position is closed.
* **Partial close:** Existing TP/SL remains active and applies to the remaining position.

## Execution

When a TP/SL is triggered, it submits a **Market Order** to close the position (or the configured portion). Standard slippage protection applies.


---

# 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:

```
GET https://docs.afx.xyz/trading-rules/take-profit-and-stop-loss-tp-sl.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.
