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

# Take-profit and stop-loss

A trigger closes a position automatically when the price crosses a level you set. Triggers live on-chain and are executed by the keeper, so they work while your browser is closed.

## Setting a trigger

* In the ticket, before opening: the take-profit and stop-loss fields go on-chain right after the position.
* In the positions table: click the TP or SL cell of an open position.
* On the chart: drag the TP or SL line.

Each set replaces the whole trigger, take-profit and stop-loss together, so the table always shows exactly what is armed. Setting both to nothing clears it.

A trigger closes the whole position by default. Partial triggers are supported by the contract; the terminal exposes full closes.

## Which price counts

A long is measured against the bid, a short against the ask, the same price a close would fill at. The bid and the ask are the oracle mid minus and plus Pyth's confidence band.

That has one consequence when you set a level: a stop inside the band would fire on the next tick, so the contract refuses it. On a liquid stock the band is a few basis points; on a $2,500 short that means a stop needs to sit at least a dollar or two above the mark.

## Execution

The keeper checks every armed trigger against each price it publishes on-chain, which is about once a minute during the session, and executes the ones that crossed; a slower safety pass reconciles with the book in case a check was missed. Anyone may execute a crossed trigger after a short priority window that starts when someone flags it, so a keeper outage does not strand a stop.

Execution is a market close. A stop through a gap fills at the market rather than failing, and the proceeds go to your wallet. The fill appears in History as a take-profit or a stop-loss.

Triggers on stock markets, like every close, only execute while the session is open. A stop set in the evening executes at the first print of the next session, at that price.

## Safety

A trigger belongs to the position it was set on. If you close the position by hand and open a new one later, the old trigger never fires on it.


---

# 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.jaawle.xyz/product/take-profit-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.
