> For the complete documentation index, see [llms.txt](https://docs.valhallaindicator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.valhallaindicator.com/smc-indicator/tp-sl-engine.md).

# TP / SL Engine

Every signal generates a complete trade setup with an entry level, stop loss, and up to three take-profit targets. Lines extend from the signal bar until the next signal replaces them.

<figure><img src="/files/Lib2ekX4DRGgu1hNcHtf" alt=""><figcaption></figcaption></figure>

#### <mark style="color:cyan;">Stop Loss Placement</mark>

For **CHOCH entries**, the SL is placed at the swing that created the CHOCH, the structural invalidation level. If the broken swing was a swing low (for a BULL signal), the SL sits at that swing low minus an optional ATR buffer. This is the price level where the structure thesis is definitively wrong.

For **continuation entries**, the SL mode is configurable: either tight to the band (Band + Buffer) or at the recent swing (Recent Swing).

#### <mark style="color:cyan;">Trade Lifecycle</mark>

A trade is "active" from the moment its signal fires until the next signal replaces it. During this time:

* Entry, SL, and TP lines extend rightward each bar
* Labels follow the rightmost bar
* TP hit markers fire when price reaches each level (if enabled)

#### <mark style="color:cyan;">SL Visibility</mark>

The <mark style="color:cyan;">`Show SL Level`</mark> toggle controls whether the SL line is drawn on the chart. When hidden, the trade stays active until TP3 is hit or a new signal fires, you manage your own stop.&#x20;

#### <mark style="color:cyan;">TP Hit Markers</mark>

When <mark style="color:cyan;">`Show TP Hit Markers`</mark> is enabled, small labeled markers (`TP1`, `TP2`, `TP3`) appear on the bar where each target level is reached. Once the SL is hit (when visible), no further TP markers will appear, the trade is considered dead.

#### <mark style="color:cyan;">Line Cleanup</mark>

The <mark style="color:cyan;">`Keep Lines After Trade Resolves`</mark> setting controls whether old setups remain on the chart as frozen history or are removed when the next signal fires.
