octagonTrailing Stop Loss

Automated Trailing Stop Loss designed to secure profits when targets are not met

Trailing Stop loss is a feature coded into your Shotgun automated trading. Designed to give you the ability to secure profits autiomatically, if your set TP amounts are not met. Below is an example of how this works, in this example we are setting a 50% TSL (Trailing Stop Loss) Setup:

  • Buy price (token_usd_price): $1.00

  • Loss percentage: 50% (stop loss triggers if price drops 50% from peak)

  • Token: $TEST


Scenario: Price rises then crashes

Tick
Price
max_price_reached
threshold (peak × 0.5)
Trigger?

1

$1.00

$1.00 (initialized)

$0.50

❌ No

2

$1.50

$1.50 (updated)

$0.75

❌ No

3

$2.00

$2.00 (updated)

$1.00

❌ No

4

$1.80

$2.00 (unchanged)

$1.00

❌ No

5

$1.00

$2.00 (unchanged)

$1.00

SELL (1.00 ≤ 1.00)

The key here is tick 5 — even though $1.00 is the original buy price, the stop loss fires because the peak was $2.00, so a 50% drop from that peak = $1.00.


Scenario: Price dips but recovers (trailing protects gains)

Tick
Price
max_price_reached
threshold
Trigger?

1

$1.00

$1.00

$0.50

❌ No

2

$3.00

$3.00

$1.50

❌ No

3

$1.60

$3.00

$1.50

❌ No

4

$1.50

$3.00

$1.50

SELL (1.50 ≤ 1.50)

Here the user bought at $1, price tripled, then dropped 50% from the peak — the trailing stop locks in profit protection.

Last updated