RSI
RSI
At a glance — the Relative Strength Index, Wilder-style smoothing. Returns a Series of
values in the [0, 100] range.
Signature
const rsi: Series = api.use(RSI, { period: 14, source: 'close' });Parameters:
| Field | Type | Description |
|---|---|---|
period | number (≥ 2) | Lookback window. Standard is 14. |
source | Source | Price source: open, high, low, close, hl2, hlc3, ohlc4. |
What it’s good for
- Mean-reversion entries when crossing back from oversold (
< 30) or overbought (> 70). - Confirming momentum direction alongside another trend indicator.
Examples
import { crossedOver, defineStrategy, RSI } from '@nexpips/sdk-trading';
/** * Achète quand le RSI(14) sort de la zone de survente (passe au-dessus de 30). */export default defineStrategy({ symbol: 'EURUSD', timeframe: 'M15', risk: { maxRiskPercentPerTrade: 0.5, maxOpenPositions: 1, maxDailyLossPercent: 3, }, setup: (api) => { const rsi = api.use(RSI, { period: 14, source: 'close' });
return { onBar(ctx) { if (!ctx.position.isFlat) return; if (ctx.position.hasPendingOrder) return;
if (crossedOver(rsi, 30)) { ctx.order.marketBuy({ riskPercent: 0.5, stopLoss: { type: 'atr', period: 14, multiple: 2 }, takeProfit: { type: 'rr', value: 1.5 }, }); } }, }; },});Buy when RSI(14) crosses back above 30.