Skip to content

stopSell

ctx.order.stopSell(price, params)

At a glance — place a pending sell order at price, below the current market: it triggers on a downside breakdown. Returns an OrderTicket.

Signature

stopSell(price: number, params: EntryParams): OrderTicket

Example

order/breakout-bracket
import { defineStrategy, DonchianChannel, type EntryParams } from '@nexpips/sdk-trading';
/**
* Straddle de cassure : un `stopBuy` au-dessus du canal de Donchian et un
* `stopSell` en dessous. Le premier niveau touché entre dans le sens de la
* cassure (l'autre ordre reste en attente — à annuler dans `onOrderFilled`
* dans une vraie stratégie).
*/
export default defineStrategy({
symbol: 'EURUSD',
timeframe: 'H1',
risk: { maxRiskPercentPerTrade: 1, maxOpenPositions: 1, maxDailyLossPercent: 5 },
setup: (api) => {
const dc = api.use(DonchianChannel, { period: 20 });
return {
onBar(ctx) {
if (!ctx.position.isFlat || ctx.position.hasPendingOrder) return;
const band = dc.at(0);
const entry: EntryParams = {
riskPercent: 1,
stopLoss: { type: 'atr', period: 14, multiple: 2 },
takeProfit: { type: 'rr', value: 2 },
};
ctx.order.stopBuy(band.upper, entry);
ctx.order.stopSell(band.lower, entry);
},
};
},
});

Straddle a Donchian breakout: stopBuy above, stopSell below.

To know

See also