Strategy Playbook

Automated Trailing Stop & Partial Take-Profit AI Agent on Eterna MCP

Even manual traders lose edge by forgetting to trail stops overnight. An Eterna MCP guardian agent manages exits mechanically across every open crypto and xStocks position 24/7.

Updated: By Eterna Quant & AI Team (Agent Strategy Playbooks)Read as Markdown
Strategy Summary

Run a lightweight portfolio-guardian agent every 15 minutes via Eterna CLI or n8n: read all open positions with `eterna.getPositions()`, move stops to breakeven once unrealized PnL exceeds +1R, and ratchet stops behind the 1h EMA 20 with `eterna.setTradingStop()`.

Primary SDK MethodsgetPositions + setTradingStopZero new entry risk
CadenceEvery 15m or 1hIdeal for CLI cron or n8n
Rule 1Never widen stopsMonotonic stop tightening only
CoverageCrypto + 24/7 xStocksProtects weekend equity moves
https://mcp.eterna.exchange/mcp

1. Monotonic Trailing Stop Guard (`execute_code`)

trailing-stop-guard.ts
const positions = await eterna.getPositions();
const actions = [];

for (const pos of positions) {
  const ema20 = await eterna.getEma({
    symbol: pos.symbol,
    interval: "60",
    period: 20,
  });
  const entry = Number(pos.avgPrice);
  const mark = Number(pos.markPrice);
  const currentSl = Number(pos.stopLoss || 0);
  const isLong = pos.side === "Buy";

  const candidateSl = isLong
    ? Math.max(entry, ema20.value * 0.995)
    : Math.min(entry, ema20.value * 1.005);

  const shouldTighten = isLong
    ? mark > entry * 1.015 && (currentSl === 0 || candidateSl > currentSl)
    : mark < entry * 0.985 && (currentSl === 0 || candidateSl < currentSl);

  if (shouldTighten) {
    actions.push({
      symbol: pos.symbol,
      side: pos.side,
      currentSl,
      proposedSl: Number(candidateSl.toFixed(4)),
    });
  }
}

return { openCount: positions.length, actions };
FAQ

Frequently asked questions

Can this agent manage trades that I opened manually in the Eterna web app?
If opened in the same account or sub-account, yes. Keeping a dedicated read-and-manage guardian script lets humans pick entries while the AI enforces disciplined exits.
Primary Sources

References & verification links

Start Trading via MCP

Connect your AI agent in 30 seconds

One remote MCP URL. 800+ USDT perpetuals, 380+ spot pairs, 0.014% maker / 0.035% taker, no KYC.

View on GitHub