AI Strategy Playbook
EMA 20/50 Trend-Following AI Crypto Trading Agent (MCP Script)
Crypto markets trend hard once breakouts clear range resistance. An EMA ribbon agent filters out choppy sideways pairs and keeps capital focused on the strongest directional movers.
Strategy Summary
Use `eterna.getEma()` with periods 20, 50, and 200 inside one `execute_code` call to rank trending perpetual pairs where price pulls back toward the 20 EMA inside an established 20 > 50 > 200 ribbon, then manage winners with `eterna.setTradingStop()`.
IndicatorsEMA 20 / 50 / 200Computed server-side via getEma()
Stop ManagementsetTradingStop()Trail stop beneath swing / EMA 50
Best PairsBTC, ETH, SOL, TAODeep liquidity + clean trends
Perp Fees0.014% / 0.035%Low drag on swing holds
https://mcp.eterna.exchange/mcp1. Runnable EMA Ribbon Pullback Scanner
const symbols = ["BTCUSDT", "ETHUSDT", "SOLUSDT", "TAOUSDT", "SUIUSDT", "LINKUSDT"];
const setups = [];
for (const symbol of symbols) {
const [t, ema20, ema50, ema200] = await Promise.all([
eterna.getTickers({ symbol }),
eterna.getEma({ symbol, interval: "60", period: 20 }),
eterna.getEma({ symbol, interval: "60", period: 50 }),
eterna.getEma({ symbol, interval: "60", period: 200 }),
]);
const price = Number(t[0].lastPrice);
const e20 = Number(ema20.value ?? ema20.latest);
const e50 = Number(ema50.value ?? ema50.latest);
const e200 = Number(ema200.value ?? ema200.latest);
const distToE20Pct = Math.abs(price - e20) / e20;
if (e20 > e50 && e50 > e200 && distToE20Pct < 0.008) {
setups.push({ symbol, bias: "BULL_PULLBACK", price, e20, e50, e200 });
} else if (e20 < e50 && e50 < e200 && distToE20Pct < 0.008) {
setups.push({ symbol, bias: "BEAR_PULLBACK", price, e20, e50, e200 });
}
}
return setups;Returns: Trending markets currently pulling back within 0.8% of the 1h 20 EMA.
2. Entry & Trailing Stop Discipline
- Prefer pullback limit entries near EMA 20 instead of chasing candles extended 5% above the average.
- Invalidate the trade below EMA 50 and set `stopLoss` immediately on order placement.
- Once price moves +1.5R in favor, ask the agent to call `eterna.setTradingStop()` to trail the stop to breakeven.
FAQ
Frequently asked questions
Can an AI agent trail stop-losses automatically on Eterna?
Yes. On scheduled check-ins, the agent reads `eterna.getPositions()` and `eterna.getEma()`, then updates the stop price with `eterna.setTradingStop()` when the trend advances.
Primary Sources
References & verification links
- Eterna SDK ReferenceDocumentation for getEma and setTradingStop.
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.