Understanding strategy.exit parameters: trail_offset, trail_points, stop, and limit
When writing a strategy in Pine Script, managing risk requires balancing fixed initial defense against capturing trend extension. The built-in strategy.exit() function can evaluate four parameters simultaneously: a fixed stop-loss price, a profit target limit price, an activation threshold (trail_points), and a trailing pullback tolerance (trail_offset). When the position opens, the fixed stop protects against immediate adverse movement. If price surges past trail_points, the trailing stop activates and begins ratcheting forward with every new peak. If price hits the limit target first, it exits at full profit. If price retreats by trail_offset, it exits via trailing stop.
| Parameter | Value Type | Unit of measurement | Role in strategy.exit |
|---|---|---|---|
| stop | series float | Absolute price level (e.g. 152.50) | Fixed catastrophic stop loss protecting initial capital |
| limit | series float | Absolute price level (e.g. 165.00) | Fixed take profit price target |
| trail_points | series float | Ticks / points (price / syminfo.mintick) | Favorable distance required before trailing stop arms |
| trail_offset | series float | Ticks / points (price / syminfo.mintick) | Trailing distance maintained behind the extreme price |