// strategy.mjs: what the agent runs on every closed 15-minute SOL-USD bar. export const config = { rsiLen: 7, rsiBuy: 30, emaLen: 96, volMult: 1.2, stop: 0.02, trail: 0.015, risk: 0.7, cooldown: 8, maxHold: 64, }; export function onBar(s, f) { const r = f.rsi(config.rsiLen); const trend = f.bar.close > f.ema(config.emaLen).value; const busy = f.vol.now > f.vol.avg(24) * config.volMult; if (s.flat) { if (s.sinceLoss < config.cooldown) return; if (r.crossUp(config.rsiBuy) && trend && busy) { return s.long(config.risk); } return; } const stopPx = s.entry * (1 - config.stop); if (f.bar.low <= stopPx) return s.close("stop", stopPx); if (f.bar.close <= s.peak * (1 - config.trail)) return s.close("trail"); if (s.held >= config.maxHold) return s.close("timeout"); }