RSI Mean-Reversion (Oversold/Overbought)
Waits for extreme RSI readings and trades counter-trend — low risk if paired with position sizing. Great for range-bound markets.
What it demonstrates: built-in RSI via ind.add
When to use: This bot is good for range-bound markets. Use conservative sizing.
const oversold = 30;const overbought = 70;const amountPercent = "5%";
function setup() { ind.add({ name: "rsi", alias: "rsi", inputs: ["close"], options: { period: 14 }, });
}
// Called on each market update (e.g., new candle or tick)async function update() { const rsi = ind.get('rsi'); const prevRsi = ind.prev("rsi"); // Wait until there is enough data if (!prevRsi) return; // bullish signal: previous RSI < oversold and current RSI rising const bullish = prevRsi < oversold && rsi > prevRsi; const bearish = prevRsi > overbought && rsi < prevRsi;
if (bullish) { await order.buy(null, amountPercent) } else if (bearish) { await order.sell(null, amountPercent); }
}