dynamic-stop-loss

πŸ“˜ Master Smart Dynamic Stoploss in Freqtrade: Only Cut Loss When Necessary

This article was produced by the Quantitative Trading Lab at https://www.itrade.icu. Visit for more benefits. In automated trading, stoploss is key to controlling losses and protecting capital. Compared to fixed stoploss, Freqtrade's custom_stoploss allows dynamic, flexible stoploss design, helping you protect profits during uptrends and exit quickly during losses.


✳️ What is custom_stoploss?

custom_stoploss dynamically calculates and returns a stoploss price based on position status, time, market conditions, etc.

  • Return type: float (new stoploss price)

  • Return -1 to continue using the default stoploss mechanism

⚠️ Note: Only for stoploss, not take profit. Use custom_exit for exit strategies.


πŸ“Œ Typical Use Cases

  • Trailing stoploss

  • Multi-level dynamic stoploss (move stoploss up with profits)

  • Profit protection at highs

  • Tiered stoploss (wide to tight)


πŸ§ͺ Example 1: Classic Trailing Stoploss

Move stoploss up with price, always keeping 2% below current rate:

βœ… Stoploss always rises with price; never decreases. ⚠️ Stoploss only moves up, never down.


πŸ§ͺ Example 2: Profit-Tiered Stoploss

Define stoploss according to profit tiers:

  • Profit 0~5% β†’ Stoploss -2%

  • Profit 5~10% β†’ Stoploss 0% (break-even)

  • Profit >10% β†’ Lock in 5% profit


πŸ§ͺ Example 3: Tolerate Small Drawdowns

Some coins are prone to quick pullbacks (β€œstop hunting”). Set stoploss only if loss exceeds 3%:


πŸ“Š Stoploss vs Take Profit

Feature

Take Profit (custom_exit)

Stoploss (custom_stoploss)

Trigger exit

βœ… Immediate sell

βœ… Set new stoploss price

Frequency

Evaluated each period

Evaluated each period

Purpose

Lock profits

Limit loss / protect capital

Return value

True / False / float

Stoploss price (float) / -1

Complementary

Can work with custom_exit_price

Can work with trailing_stop


🧰 Suggested Use with trailing_stop

  • Let custom_stoploss manage initial stoploss,

  • Then let trailing_stop take over to protect profits as price rises.


🧭 Configuration Tips

  • Define custom_stoploss in your strategy; no extra activation needed.

  • Recommended settings:


πŸ“ˆ Trailing Stop Illustration

Stage
Price
Stoploss
Notes

Initial entry

100

98

Initial stoploss

Price ↑

105

102.9

Stoploss moves up

Price ↑

110.25

107.945

Locking more profit

Price ↑

115.76

113.45

Continue trailing stop


πŸ“Œ Key Reminders

  • Return value is stoploss price, not percentage.

  • Return -1 to skip changes; default stoploss applies.


πŸ“¦ Summary

  • custom_stoploss is one of Freqtrade’s most powerful risk management tools

  • Supports trailing stop, multi-level logic, and profit protection

  • Combined with trailing_stop and custom_exit, it forms a complete capital defense system

Last updated