Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when designing or tuning exit logic for a Freqtrade strategy on Superior Trade — anything described as ratcheting trailing stop, two-phase exit, ALO-aware exit, dynamic stoploss DSL, ROI ladder, take-profit ladder, exit engine. Specifies a three-phase exit (Phase 0 ROI ladder, Phase 1 hard stop, Phase 2 ratcheting trail) that strategies compose. The Phase 2 ratchet was the most consistently profitable primitive across 21 validation backtests; the Phase 0 ladder is what makes mean-reversion s
.claude/skills/superior-trade-dsl-exit-engine/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 41% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 13% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 23% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 30% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 34% | 0% |
A reusable exit primitive that any strategy skill can compose. Replaces the ad-hoc trailing-stop logic currently duplicated inside breakout with a single, declarative spec.
Other names this is searchable under: ratcheting trailing stop, two-phase exit, ALO-aware exit, dynamic stoploss DSL, ROI ladder.
The Freqtrade IStrategy lifecycle gives you stoploss, trailing_stop, trailing_stop_positive, minimal_roi, and custom_exit. Each strategy ends up reimplementing the same three-phase shape:
minimal_roi). Cash out winners at known target tiers, decaying over time. For mean-reversion / scalper strategies, this is the primary profit mechanism.stoploss). A hard max-loss cutoff while the trade is underwater or barely above breakeven.trailing_stop). Once unrealized PnL clears an activation threshold, switch to a trailing stop that only tightens, never loosens. For trend-follow strategies, this is the primary profit mechanism.This file specifies all three. Strategies declare the parameters and inherit the behavior.
Across 21 backtests on the Nov 2025 → May 2026 window, the trailing_stop_loss exit-reason bucket was positive in every single backtest where Phase 2 activated:
| Strategy | Trailing-stop bucket PnL | Strategy total PnL | |---|---|---| | Funding-fader minimal BTC | +$108 | -$8 | | Funding-fader v3 BTC | +$75 | -$11 | | Striker v1 multipair | +$373 | -$112 | | Striker v2 multipair | +$170 | -$26 | | Donchian 4h BTC baseline | +$78 | +$13 | | Donchian 4h quick-exit BTC | +$36 | +$19 | | Donchian strong-regime BTC | +$10 | +$10 |
The Phase 2 ratchet is the most consistently profitable primitive in the entire toolkit. The strategies that lost did so via Phase 1 stops or signal exits, not because the trailing stop misfired.
Inverse finding for minimal_roi: the standard template minimal_roi = {"0": 100.0} (used in most repo strategies) effectively disables Phase 0. For mean-reversion and scalp strategies this leaves money on the table — wins that should have been taken at +2.5% kept giving back. The bollinger-reverter-4h strategy's edge depends entirely on its minimal_roi ladder.
yamlexit_engine: phase_0: roi_ladder: "0": 0.025 # take 2.5% immediately "60": 0.012 # 1.2% after 60 minutes "180": 0.005 # 0.5% after 3 hours "360": 0.0 # breakeven after 6 hours phase_1: max_loss_pct: 0.05 # hard stoploss while underwater (Freqtrade `stoploss`) phase_2: activate_at_pct: 0.025 # unrealized PnL that flips to trailing trail_offset_pct: 0.015 # distance from peak; ratchet only tightens min_step_pct: 0.002 # ignore noise below this when ratcheting exit_pricing: mode: "maker_then_taker" # ALO post; if unfilled within timeout, fall through to taker maker_timeout_sec: 30
Use Phase 0 (minimal_roi ladder), skip Phase 2: mean-reversion, scalp, range strategies. Target moves are small (sub-3%), the trailing stop's +2-3% activation threshold rarely fires, and trailing stops give back too much when they do.
Use Phase 2 (trailing), skip Phase 0: trend-follow, breakout, momentum strategies. Winners can run 5-20%, locking in fixed ROI cuts the right tail.
Use both: strategies that catch both small mean-reversions AND occasional runners. Configure Phase 0 with longer time tiers and Phase 2 with higher activation so they don't compete.
Use neither (minimal_roi = {"0": 100.0} + trailing_stop = False): signal-exit-only strategies that rely entirely on populate_exit_trend. This is the most common pattern in the repo today and is frequently sub-optimal — most strategies benefit from at least one of Phase 0 or Phase 2.
IStrategy)pythonstoploss = -0.05 # phase_1.max_loss_pct trailing_stop = True trailing_stop_positive = 0.015 # phase_2.trail_offset_pct trailing_stop_positive_offset = 0.025 # phase_2.activate_at_pct trailing_only_offset_is_reached = True # do not trail until activate_at hit def custom_exit(self, pair, trade, current_time, current_rate, current_profit, **kw): # Optional: enforce min_step_pct so micro-jitters do not churn orders. peak = trade.max_rate or trade.open_rate move_from_peak = (peak - current_rate) / peak if current_profit > 0.025 and move_from_peak >= 0.015 + 0.002: return "ratchet_trail" return None
fees-optimizations)For strategies that can tolerate a few seconds of fill latency on exit, post the trail as ALO first and only escalate to taker if maker_timeout_sec elapses:
json"exit_pricing": {"price_side": "same", "use_order_book": true, "order_book_top": 1}, "unfilledtimeout": {"entry": 3, "exit": 1, "unit": "minutes"}
Required pairing — without unfilledtimeout, a maker exit stalls indefinitely in trending markets and blocks the per-pair single-trade slot.
This primitive does not improve a losing strategy. Backtests on breakout show the trailing stop clips winners more often than it saves losers when the regime is wrong — that is expected. Use Phase 2 to lock in asymmetric R after the trade has already proven the thesis, not as a substitute for a regime filter.
| Parameter | Typical range | Notes | |---|---|---| | max_loss_pct | 0.03 – 0.08 | Tighter than 0.03 over-stops on normal vol; wider than 0.08 turns small losers into account-killers | | activate_at_pct | 0.015 – 0.04 | Below 1.5R of typical entry slippage = activates on noise | | trail_offset_pct | 0.01 – 0.025 | Smaller = more clipped winners; larger = bigger give-back | | min_step_pct | 0.001 – 0.005 | Anti-churn band; raise on illiquid pairs |
Run a 3-variant parameter sweep on activate_at_pct × trail_offset_pct (Superior backtester supports parallel sweeps natively):
variants:
- {activate_at_pct: 0.020, trail_offset_pct: 0.010}
- {activate_at_pct: 0.025, trail_offset_pct: 0.015} # reference
- {activate_at_pct: 0.040, trail_offset_pct: 0.025}Compare on profit factor and avg_winner / avg_loser ratio, not raw return — the engine's job is shape, not direction.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | fail→pass | 19,092 | 16,641 | -13% | 1 | 1 | 0% | 3,135 | 4,428 | +41% | 0 | 0 | — |
case-01 | fail→fail | 19,658 | 32,485 | +65% | 1 | 1 | 0% | 3,598 | 6,519 | +81% | 0 | 0 | — |
case-02 | fail→pass | 41,474 | 15,578 | -62% | 1 | 1 | 0% | 3,921 | 4,446 | +13% | 0 | 0 | — |
case-04 | pass→pass | 80,228 | 6,647 | -92% | 1 | 1 | 0% | 1,246 | 3,092 | +148% | 0 | 0 | — |
case-05 | fail→pass | 102,987 | 23,012 | -78% | 1 | 1 | 0% | 4,356 | 5,368 | +23% | 0 | 0 | — |
case-06 | pass→pass | 14,148 | 9,533 | -33% | 1 | 1 | 0% | 1,906 | 3,799 | +99% | 0 | 0 | — |
case-07 | fail→pass | 20,929 | 14,154 | -32% | 1 | 1 | 0% | 3,364 | 4,370 | +30% | 0 | 0 | — |
case-08 | fail→pass | 41,160 | 16,037 | -61% | 1 | 1 | 0% | 3,130 | 4,183 | +34% | 0 | 0 | — |
case-09 | pass→pass | 12,424 | 9,509 | -23% | 1 | 1 | 0% | 1,741 | 3,513 | +102% | 0 | 0 | — |
case-10 | fail→pass | 12,043 | 4,603 | -62% | 1 | 1 | 0% | 1,765 | 2,776 | +57% | 0 | 0 | — |
case-11 | pass→pass | 14,930 | 17,383 | +16% | 1 | 1 | 0% | 2,367 | 4,326 | +83% | 0 | 0 | — |
case-12 | fail→pass | 16,838 | 13,404 | -20% | 1 | 1 | 0% | 2,543 | 4,117 | +62% | 0 | 0 | — |
case-13 | fail→pass | 13,188 | 14,804 | +12% | 1 | 1 | 0% | 2,174 | 3,943 | +81% | 0 | 0 | — |
case-14 | pass→pass | 21,001 | 16,740 | -20% | 1 | 1 | 0% | 2,788 | 4,371 | +57% | 0 | 0 | — |
case-15 | fail→pass | 18,543 | 5,944 | -68% | 1 | 1 | 0% | 2,555 | 2,875 | +13% | 0 | 0 | — |
case-16 | fail→pass | 9,697 | 2,925 | -70% | 1 | 1 | 0% | 1,715 | 2,402 | +40% | 0 | 0 | — |
case-17 | fail→pass | 12,833 | 2,520 | -80% | 1 | 1 | 0% | 2,028 | 2,412 | +19% | 0 | 0 | — |
case-18 | pass→pass | 20,308 | 16,133 | -21% | 1 | 1 | 0% | 2,440 | 3,986 | +63% | 0 | 0 | — |
case-19 | fail→pass | 21,131 | 18,953 | -10% | 1 | 1 | 0% | 3,325 | 5,224 | +57% | 0 | 0 | — |
case-20 | fail→fail | 13,524 | 3,797 | -72% | 1 | 1 | 0% | 1,905 | 2,378 | +25% | 0 | 0 | — |
case-21 | pass→pass | 165,001 | 15,393 | -91% | 1 | 1 | 0% | 2,597 | 4,695 | +81% | 0 | 0 | — |
case-22 | fail→pass | 16,570 | 14,868 | -10% | 1 | 1 | 0% | 2,615 | 3,976 | +52% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +59 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.