list_templates
The three starter Rhai strategies an agent can copy, and the execution gate that stands behind them.
Returns the starter Rhai strategies as {name, code} rows. Offline — no server, no key, no
argument. Each starter is parameterized via param(), so it drops straight into
run_sweep without editing.
{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"list_templates","arguments":{}}}What comes back
{ "templates": [ { "name": …, "code": … }, … ] }. The sources are static data in mcp.rs's
TEMPLATES, so the payload is fixed by the build rather than by anything on disk. On the wire
each code is a JSON string with escaped newlines; unescaped, the three rows are:
SMA cross
let fast = param("fast", 5.0);
let slow = param("slow", 20.0);
fn on_bar() {
let f = sma(fast.to_int()); let s = sma(slow.to_int());
if s.is_nan() { return; }
let target = if f > s { 1.0 } else { -1.0 };
let delta = target - position();
if abs(delta) > 1e-12 { market(if delta > 0.0 { 1 } else { -1 }, abs(delta)); }
}RSI reversion
let len = param("len", 14.0);
let lo = param("lo", 30.0);
let hi = param("hi", 70.0);
fn on_bar() {
let r = rsi(len.to_int());
if r.is_nan() { return; }
if r < lo && position() <= 0.0 { market(1, 1.0); }
if r > hi && position() >= 0.0 { market(-1, 1.0); }
}Donchian breakout
let len = param("len", 20.0);
fn on_bar() {
let h = sma(len.to_int()); // symmetric proxy. donchian is NOT bound: it is multi-output
// (upper/mid/lower) and the bridge binds single-output indicators
// only, so `donchian(len)` is a function-not-found at the first
// call rather than a silent upper-band read.
if h.is_nan() { return; }
if high() > h && position() <= 0.0 { market(1, 1.0); }
if low() < h && position() >= 0.0 { market(-1, 1.0); }
}Read all three as shapes, not as edges: each guards its warm-up with an is_nan() early return,
each reads its knobs at the top level where param() runs, and each does its trading inside
fn on_bar().
The gate that makes this list safe to copy
Two tests stand behind the rows, and the second is the one that matters. One compiles every
template and asserts it exposes param() knobs and defines on_bar. The other,
every_shipped_template_reaches_the_broker, mounts each one as a real RhaiStrategy over a
broker double, drives 80 strictly-rising bars through it, and asserts an order actually arrives —
routed to the bar's own symbol, with a side of exactly ±1 and a positive quantity.
Compiling is the wrong bar for a surface an agent copies from. The compile path runs a script's
top level only, so every call inside on_bar is unchecked, and an unbound name, a wrong arity or
a wrong argument type all compile cleanly and then raise on every bar until the strategy disables
itself. Only execution distinguishes that from a strategy that simply saw no signal — which is why
the gate runs the templates rather than parsing them.
The Donchian starter does not call donchian, and its source says why
It stands in with sma, symmetrically. A bare multi-output call binds only when line 0 is the
indicator's namesake line, and donchian declares upper/mid/lower — so donchian(len) is a
function-not-found on the first bar rather than a silent upper-band read. Every line is separately
reachable through a per-line accessor (donchian_mid() is the spelling). The template's own
comment says "the bridge binds single-output indicators only", which was the rule when it was
written: the host used to reject every multi-output indicator outright and has since narrowed to
the namesake test — a multi-output indicator whose line 0 is its namesake now binds under its
bare name, and donchian still does not. The conclusion the comment draws is unchanged. Check any
indicator name against
list_indicators before you edit one in.
Two copies of these sources exist, and they are edited together
The MCP copy is a hand copy of vike-studio-core's templates, because importing that crate
would drag DataFusion into a deliberately DataFusion-free CLI. There is no cross-crate drift gate
— each side instead carries its own execution gate over its own copy. If you are changing a
starter in the product tree, change both.
The prompt
Show me the Vike Trader strategy templates and explain what each one trades.
The natural next step is to edit one and run
validate_strategy, then
discover_params to confirm the knobs a [sweep] may vary.
Scripting is the language reference; the same starters are what the Studio's
templates dropdown renders.
discover_params
Read back the tunable param() knobs a Rhai strategy declares, with their defaults, in declaration order — offline, with no server of any kind.
list_indicators
The host-bound indicators a Rhai strategy can actually call — a compact roster by default, detail pulled per name or per family.