Dsl Exit Engine logo

Dsl Exit Engine

Organization
Superior-Trade
dsl-exit-engine

Use when designing or tuning exit logic for a Freqtrade strategy — ratcheting trailing stop, two-phase exit, ALO-aware exit, dynamic stoploss DSL, ROI ladder, take-profit ladder, exit engine. Defines a three-phase exit that strategies compose: Phase 0 ROI ladder, Phase 1 hard stop, Phase 2 ratcheting trail.

Overview

PublisherSuperior-Trade
Repositorysuperior-skills
Skill namedsl-exit-engine
Stars
215
Forks
9
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Superior-Trade on GitHub. Read the source before you install it.

Installation

Install the Dsl Exit Engine AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Superior-Trade/superior-skills/tree/main/skills/dsl-exit-engine
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Superior-Trade/superior-skills.git /tmp/superior-skills
mkdir -p .claude/skills
cp -r /tmp/superior-skills/skills/dsl-exit-engine .claude/skills/dsl-exit-engine
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dsl Exit Engine in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dsl Exit Engine on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dsl Exit Engine is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

DSL Exit Engine — Three-Phase Exit Primitive

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.


Why a DSL

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:

  1. Phase 0 — Take-profit ladder (minimal_roi). Cash out winners at known target tiers, decaying over time. For mean-reversion / scalper strategies, this is the primary profit mechanism.
  2. Phase 1 — Survival (stoploss). A hard max-loss cutoff while the trade is underwater or barely above breakeven.
  3. Phase 2 — Ratchet (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.

Validated evidence

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:

StrategyTrailing-stop bucket PnLStrategy 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.

Spec

yaml
exit_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

Phase 0 vs Phase 2 — when to use which

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.

Reference implementation (drop into IStrategy)

python
stoploss = -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

Maker-first exit (pairs cleanly with 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.

Honest framing

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.

Tunables

ParameterTypical rangeNotes
max_loss_pct0.03 – 0.08Tighter than 0.03 over-stops on normal vol; wider than 0.08 turns small losers into account-killers
activate_at_pct0.015 – 0.04Below 1.5R of typical entry slippage = activates on noise
trail_offset_pct0.01 – 0.025Smaller = more clipped winners; larger = bigger give-back
min_step_pct0.001 – 0.005Anti-churn band; raise on illiquid pairs

Backtest harness

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.

Frequently asked questions

What does the Dsl Exit Engine AI skill do?

Use when designing or tuning exit logic for a Freqtrade strategy — ratcheting trailing stop, two-phase exit, ALO-aware exit, dynamic stoploss DSL, ROI ladder, take-profit ladder, exit engine. Defines a three-phase exit that strategies compose: Phase 0 ROI ladder, Phase 1 hard stop, Phase 2 ratcheting trail.

Why use Dsl Exit Engine on TypingMind?

Because you install it once and use it with any model. Dsl Exit Engine is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dsl Exit Engine in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Superior-Trade/superior-skills/tree/main/skills/dsl-exit-engine. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Dsl Exit Engine?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dsl Exit Engine?

As many as you like. As long as a model supports skills, you can use Dsl Exit Engine with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dsl Exit Engine AI skill free?

Yes. It is published on GitHub by Superior-Trade under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇