Language reference
Describe the strategy.
Driver trades it.
DexScript is a small, Pine-inspired language for writing a Solana trading strategy as a set of rules. You don’t pick a token; you describe the behavior, and Driver continuously scouts the best-matching token and trades it within your risk limits. Write it by hand, or describe it in plain English and let the AI draft it.
Anatomy of a strategy
Every strategy is one block with a few labelled sections.
// A complete strategystrategy "SOL Trend Rider" { universe: auto // best market match, scouted continuously timeframe: 15m buy: when rsi(14) < 32 and crossover(ema(9), ema(21)) size: 20% of allocation sell: when rsi(14) > 70 stop_loss: 8%}strategy "name" { }- The wrapper. Required; the name is any quoted string.
universe: auto- What to trade. auto lets Driver scout the best match continuously.
timeframe: 15m- The candle interval rules run on, like 5m, 15m or 1h.
buy:- When to open (buy) a spot position. Required.
sell:- When to close (sell) it. Required.
when …- The condition that triggers a buy or sell.
size: 20% of allocation- How much of your funds to commit per position.
stop_loss: 8%- Risk exit if the trade moves against you.
The vocabulary
Keywords & values
strategyuniversetimeframebuysellentryexitwhenandorsizeofallocationstop_losstrailing_stoppriceautotruefalseCombine conditions with and / or, compare with < > =. Numbers, percentages and quoted strings are literals; // starts a comment.
Indicator functions
The vocabulary you build conditions from.
rsi(14)Relative Strength Index. Overbought / oversold.ema(9) · sma(20)Exponential / simple moving averages.macd()MACD line vs signal. Momentum.bbands(20, 2)Bollinger Bands.atr(14)Average True Range. Volatility.volume() · avgVolume(20)Current volume and its average.crossover(a, b)True when a crosses above b.crossunder(a, b)True when a crosses below b.stoch()Stochastic oscillator.funding()Perp funding rate.forecast(24)Predicted price 24 bars ahead (TimesFM).
Common patterns
The four signal families Driver runs. Each token is scored 0 to 100%, and bought at 100%.
RSI reversion
Buy dips, sell ripsbuy: when rsi(14) < 30sell: when rsi(14) > 70EMA momentum
Ride trendsbuy: when crossover(ema(9), ema(21))sell: when crossunder(ema(9), ema(21))MACD momentum
Trade the crossbuy: when crossover(macd(), 0)sell: when crossunder(macd(), 0)Breakout
Buy strengthbuy: when price > bbands(20, 2) and volume() > avgVolume(20)sell: when crossunder(price, ema(20))Forecasting with TimesFM
Beyond reacting to indicators, Driver can act on a prediction. forecast(n) returns the token's expected price n bars ahead from Google's TimesFM, a 200M-parameter time-series model, so a rule can trade what the model sees coming.
// Trade the model's forecaststrategy "SOL Forecast" { universe: auto timeframe: 1h buy: when forecast(24) > price * 1.03 // model sees +3% over 24h size: 20% of allocation sell: when forecast(12) < price // forecast turns down stop_loss: 8%}Zero-shot, numeric
TimesFM forecasts the price series directly. It is a dedicated time-series model, not an LLM, so predictions stay quantitative and reproducible.
Point and range
forecast(n) is the point estimate; the model also yields P10–P90 quantiles Driver uses to gauge confidence before sizing a trade.
Composable
Mix it with indicators: gate a breakout on a positive forecast, or tighten exits when the forecast rolls over.
Forecasting runs as an opt-in agent skill (off by default). It needs a TimesFM inference service; until that is wired, forecast() validates and highlights but returns no live prediction.
Generate from a prompt
Describe the strategy in a sentence or two and the AI drafts the DexScript, which you can then edit. Good prompts name four things: the edge, the entry trigger, the exit, and the risk appetite. The risk level you pick also tunes sizing and stops.
- “Buy oversold pullbacks within an uptrend, take profit quickly, cut losers fast.”
- “Momentum: enter when the 9 EMA crosses above the 21 EMA on 15m, exit on the reverse cross, aggressive sizing.”
- “Mean-reversion on high-volume memecoins: buy when RSI is under 30 with above-average volume, sell at RSI 65, tight 5% stop.”
Write it by hand
Pick Write DexScript in the create wizard for a starter template, syntax highlighting, and a live function reference. The editor validates as you type and blocks publishing until the script is valid.
A valid script needs
- A strategy "name" { … } block
- An entry rule
- An exit rule
- Balanced { } and ( )