DocsRisk ManagementPosition Sizing

Position Sizing

SizingRisk Management

The Position Sizing node answers the question "how many units should I buy?" by dividing the dollar amount you are willing to risk by the price distance between your entry and stop-loss. It enforces the fixed-fractional position sizing model: risk exactly N% of your account on every trade, regardless of volatility.

Formula

Risk Amount=accountEquity × (riskPercent / 100)
Stop Loss Price=close × (1 − stopLossPercent / 100)
Price Risk=close − Stop Loss Price
Position Size=floor(Risk Amount / Price Risk)

Position size is floored to a whole number of units. Bars where priceRisk ≤ 0 or the close is null produce null.

Parameters

NameTypeDefaultDescription
accountEquitynumber10 000Total account value in quote currency.
riskPercentnumber1.0Percentage of account equity to risk per trade (e.g. 1 = 1%).
stopLossPercentnumber2.0Stop distance expressed as % below entry. Used to compute priceRisk.

Inputs & Outputs

PortTypeDescription
Input
input(number | null)[]Close price series (entry price at each bar).
Outputs
positionSizenumber | nullInteger unit count to purchase at the most recent bar.
riskAmountnumber | nullDollar amount risked (accountEquity × riskPercent / 100).
entryPricenumber | nullLast valid close price used as entry.
stopLossPricenumber | nullStop price: entry × (1 − stopLossPercent / 100).
priceRisknumber | nullPrice distance between entry and stop (entry − stopLossPrice).
values(number | null)[]Per-bar position size array (floor of riskAmount/priceRisk, null if invalid).
timestampsnumber[]UNIX ms timestamps aligned 1-to-1 with values.

Use Cases

Fixed-fractional sizing with Stop Loss node

Connect the close price output to Position Sizing and use the same stopLossPercent as your Stop Loss node. The positionSize output then tells the execution layer exactly how many units to place while ensuring the trade cannot lose more than riskPercent of equity.

Dynamic sizing on volatile assets

On high-volatility assets, a fixed unit count is dangerous. Position Sizing automatically reduces the unit count when the asset is expensive or volatile (large stop distance), and increases it when conditions are calm — keeping dollar risk constant across all entries.