Skip to content

EntryParams

EntryParams

The arguments you pass when opening a position (for example via marketBuy). You declare riskPercent and a stopLoss PriceLevel — never a raw lot size, the engine sizes the volume from your risk. takeProfit and a free-text comment are optional.

Signature

export interface EntryParams {
riskPercent: number;
stopLoss: PriceLevel;
takeProfit?: PriceLevel;
comment?: string;
}

Example

order/market-buy-simple
import { defineStrategy } from '@nexpips/sdk-trading';
/**
* Acheter au marché si on est flat, avec un stop-loss à 20 pips.
*
* Pattern : entrée propre — vérifier `hasPendingOrder` ET `isFlat`
* pour éviter d'envoyer un ordre alors qu'un précédent est encore
* en attente de confirmation broker.
*/
export default defineStrategy({
symbol: 'EURUSD',
timeframe: 'H1',
risk: {
maxRiskPercentPerTrade: 1,
maxOpenPositions: 1,
maxDailyLossPercent: 5,
},
setup: () => ({
onBar(ctx) {
if (!ctx.position.isFlat) return;
if (ctx.position.hasPendingOrder) return;
ctx.order.marketBuy({
riskPercent: 1,
stopLoss: { type: 'pips', value: 20 },
takeProfit: { type: 'rr', value: 2 },
});
},
}),
});

Open a position by risk percent with a stop-loss.

See also