limitSell
ctx.order.limitSell(price, params)
At a glance — place a pending sell order at price, above the current
market: it fills only if price rallies up to your level. Returns an
OrderTicket for later
cancel.
Signature
limitSell(price: number, params: EntryParams): OrderTicketExample
import { BollingerBands, defineStrategy, type EntryParams } from '@nexpips/sdk-trading';
/** * Fade de range sur bandes de Bollinger : un `limitBuy` sur la bande basse * (repli acheteur) et un `limitSell` sur la bande haute (repli vendeur), * tous deux visant un retour vers la moyenne. */export default defineStrategy({ symbol: 'EURUSD', timeframe: 'M15', risk: { maxRiskPercentPerTrade: 1, maxOpenPositions: 1, maxDailyLossPercent: 5 }, setup: (api) => { const bb = api.use(BollingerBands, { source: 'close', period: 20, stdDev: 2 });
return { onBar(ctx) { if (!ctx.position.isFlat || ctx.position.hasPendingOrder) return;
const band = bb.at(0); const entry: EntryParams = { riskPercent: 1, stopLoss: { type: 'atr', period: 14, multiple: 2 }, takeProfit: { type: 'price', value: band.middle }, };
ctx.order.limitBuy(band.lower, entry); ctx.order.limitSell(band.upper, entry); }, }; },});Fade a range: limitBuy on the lower band, limitSell on the upper.
To know
- A
limitSellpriced below the market is a code bug and throwsStrategyInvariantError.