> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trinigence.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exit Logic

> How Trinigence evaluates conditions to close a trade.

## What exit logic is

Exit logic defines **when and how a trade is closed**.

A trade is considered complete only when an exit condition is met.
Without exit logic, a strategy cannot be executed or backtested.

<Warning>
  Every direction (long and short) must have a valid exit.
</Warning>

***

## Types of exit logic

Exit logic can be based on different mechanisms.

<Columns cols={2}>
  <Card title="Fixed exits" icon="percent">
    Take profit and stop loss defined as fixed percentages or values.
  </Card>

  <Card title="Indicator-based exits" icon="wave-square">
    Exits triggered by indicator conditions.
  </Card>

  <Card title="Time-based exits" icon="clock">
    Trades close after a defined duration.
  </Card>

  <Card title="Conditional exits" icon="code-branch">
    Exits that depend on market context or regime.
  </Card>
</Columns>

***

## Fixed exits (TP / SL)

The most common exit type.

Example:

```text theme={null}
Exit with a 5% take profit and a 1% stop loss.
```

Fixed exits are:

* easy to reason about
* deterministic
* comparable across strategies

They apply symmetrically to long and short trades unless specified otherwise.

***

## Indicator-based exits

Indicator exits close a trade when a condition becomes true.

Examples:

```text theme={null}
Exit long when RSI(14) crosses below 50.
Exit short when EMA(20) crosses above EMA(50).
```

Indicator exits:

* adapt to market behavior
* can shorten or extend trades
* are evaluated on candle close

***

## Time-based exits

Time-based exits close a trade after a certain duration.

Example:

```text theme={null}
Exit any trade after 12 hours.
```

These exits:

* cap exposure time
* prevent very long trades
* are often combined with TP/SL

***

## Multiple exit conditions

A trade may have multiple exit conditions.

Example:

```text theme={null}
Exit with a 6% take profit,
or a 1.5% stop loss,
or after 24 hours.
```

The **first exit condition met** closes the trade.

***

## Direction-specific exits

Exit logic may differ by direction.

Example:

```text theme={null}
For long trades use a 6% TP and 1% SL.
For short trades use a 4% TP and 1.5% SL.
```

This allows:

* asymmetric risk profiles
* adaptation to market behavior

***

## When exits are evaluated

Exit logic is evaluated:

* on every candle close
* while a trade is open
* before new entries are considered

<Info>
  Exit conditions always take priority over new entries.
</Info>

***

## Default behavior

If exit logic is:

* missing → strategy is invalid
* partially defined → ATI requests clarification
* clearly implied → ATI may infer conservatively

<Card title="What Trinigence fills automatically" icon="robot" href="/writing-ideas/what-trinigence-fills-automatically" horizontal>
  See how missing exit details are handled.
</Card>

***

## Common mistakes

<AccordionGroup>
  <Accordion title="Relying only on take profit">
    Strategies without stop loss usually produce misleading results.
  </Accordion>

  <Accordion title="Conflicting exit conditions">
    Multiple exits may interact in unexpected ways.
  </Accordion>

  <Accordion title="Expecting intrabar exits">
    Exits are evaluated on candle close by default.
  </Accordion>
</AccordionGroup>

***

## Best practices

* Always define both TP and SL
* Inspect exit timing visually
* Use time-based exits for safety
* Keep exits simpler than entries

<Card title="Risk management" icon="shield-halved" href="/strategy-structure/risk-management" horizontal>
  Learn how exits and risk work together.
</Card>

***

## What to read next

<CardGroup cols={2}>
  <Card title="Risk management" icon="shield-halved" href="/strategy-structure/risk-management">
    How losses are controlled.
  </Card>

  <Card title="Entry logic" icon="arrow-right-to-bracket" href="/strategy-structure/entry-logic">
    How trades are opened.
  </Card>

  <Card title="Direction: long & short" icon="arrows-up-down" href="/strategy-structure/direction-long-short">
    Direction-specific exits.
  </Card>

  <Card title="Strategy overview" icon="diagram-project" href="/strategy-structure/overview">
    Return to the big picture.
  </Card>
</CardGroup>

<Note>
  Entries decide *if* you trade.\
  Exits decide *how* you perform.
</Note>
