CommunityGlossary › Strategy DSL
Strategy Engine

Strategy DSL

The small Python-style language TraderWe strategies are written in — rules, not code plumbing.

What it means

A domain-specific language (DSL) trades generality for clarity: instead of a full programming environment with data feeds and order APIs to wire up, you write only the decision — if these conditions hold, buy; if those hold, sell. The engine supplies the data, the clock and the execution.

A strategy is a pair of scripts — a buy strategy and a sell strategy, written in separate editors. The buy script is evaluated only while you hold no position; once a position opens, the sell script takes over. The same pair runs unchanged in live trading, paper trading and the backtester — that is what makes "what you tested is what you trade" literally true.

Why traders care

  • Low surface area: fewer places for bugs than a general-purpose script.
  • The editor validates factor names as you type — typos surface before they trade.

In a TraderWe strategy

# Buy strategy (entry editor)
if Price > Sma(60) and Strength > 120 and ChangePct > 3:
    Buy()

# Sell strategy (exit editor — a separate script)
if ProfitPct <= -2 or HoldTime >= 1800:
    Sell()
A complete strategy: one entry rule and one exit rule, each in its own editor.

Educational content, not investment advice. Engine details describe how TraderWe computes this value; other platforms may define it differently.