# Exit rules

## Overview

**Exit rules** define **when your agent closes a position**, whether it's a buy (Long) or a sell (Short). Like entry rules, they are part of the [description](/agents/create-an-agent/description.md) in natural language.

Everything that applies to entry rules also applies to exit rules.

{% content-ref url="/pages/HjEGwH9R01mVnZelOkWD" %}
[Entry rules](/agents/create-an-agent/entry-rules.md)
{% endcontent-ref %}

{% hint style="info" %}
**Good to know:**

* In **trading**, an agent must include both **entry and exit rules** to manage positions actively.
* In **investing**, you can define entry rules only if you wish to accumulate assets without systematic selling. In other words, **it's possible to have no exit rules**.
  {% endhint %}

Your exit rules can be based on technical indicators, patterns, units of measure, or any other **condition already used in the entry rules**.

You can also use a **stop-loss** as well as **take-profits**.

It's also possible to perform **partial exits** of your positions, allowing you to lock in gains or minimize losses before fully closing a position.

***

## Using a stop-loss

To limit the loss on a trade, a stop-loss can be specified in your exit rules. The stop-loss can be expressed as a percentage, in price, in price change, in ticks, in pips, in points, in indicator value change, or in ATR multiples.

You can also place your stop-loss on a technical level, such as the high or low of the last X days.

The stop-loss can be fixed, trailing, or moved to breakeven if needed. Just specify what you want. The possibilities are wide.

{% hint style="success" %}
Obside's AI knows that for a buy trade, the stop-loss goes below the entry price, and for a sell trade, it goes above the entry price.
{% endhint %}

You can however dissociate buy and sell trades, giving a different stop-loss for each side.

{% hint style="info" %}
**Examples:**

"Place a stop-loss at 2 ATR below the low or above the high of the last 5 days."

"Cut the trade if the price moves 4% against us."

"Trailing stop-loss at 1%, moved to breakeven once we reach 1.5% profit."

"SL on the low of the last 10 candles for a buy trade. SL on the high of the last 10 candles for a sell trade."
{% endhint %}

***

## Using a take-profit

As the name suggests, **take-profit** is meant to "take your profits", i.e. close your trade to lock in gains.

It can also be expressed as a percentage, in price, in price change, in ticks, in pips, in points, in indicator value change, or in ATR multiples.

Another notable unit is the **R**, which represents the gain/risk ratio. In other words, it's the distance between the entry price and the stop-loss on your trade. By expressing the take-profit in multiples of R (e.g. 1 R, 2 R, 2.5 R), your trade closes when the specified gain/risk ratio is reached.

The take-profit can be full or partial, depending on whether you want to lock in all or part of the gains on each trade. Like the stop-loss, it can also be trailing.

{% hint style="info" %}
**Examples:**

"Take-profit at 2 R."

"Partial TP of 50% when the price has risen by 10 pips, and 50% when it has risen by 20 pips."

"Set a take-profit at 5% from our entry price."

"TP at 1 R with a 0.25 R trailing."

"Take profits at +2 ATR."
{% endhint %}


---

# 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.obside.com/agents/create-an-agent/exit-rules.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.
