Skip to content

Choose a position size

The entry rule decides when to trade. The size rule decides how much to allocate or how to calculate the quantity. Start with a percentage, then choose its money basis and whether instruments share the budget.

Read a percentage declaration

size: 5% of portfolio per instrument
Part Question it answers Meaning in this example
5% How much? Target five percent of the sizing basis.
of portfolio Five percent of what? This strategy's current marked equity, subject to its capital ceiling.
per instrument How is it applied? Each entering instrument gets its own target.

With a basis of 10,000, each entering instrument desires 500. This is a position allocation, not a 5% loss budget. It uses this strategy's funding and equity, not your entire broker account.

The percentage form has this order:

size: <percentage> [of <basis>] [<scope>]

Square brackets here mean optional words; do not type them. Accepted bases are portfolio, starting capital, and capital (an alias for starting capital). Accepted scopes are per instrument, in total, and across active instruments. Use those phrases exactly; in portfolio, per stock, and of account are not interchangeable spellings.

What can you leave out?

For a strategy with conditional entry: rules, these mean the same thing:

size: 5%
size: 5% of portfolio
size: 5% per instrument
size: 5% of portfolio per instrument

Omitting the basis always chooses portfolio. Omitting the scope depends on the strategy shape:

Strategy shape Meaning of size: 5%
entry: / exit: 5% for each entering instrument. A universe: does not change this default.
hold: One 5% budget shared by the selected portfolio.

In a hold strategy, adding per instrument changes the meaning: four selected names each target 5%, for a desired total of 20%. Write the full declaration while learning so the basis and scope are visible.

Percentage spelling

Write 5%, with the number next to %, and keep the colon in size:. size: 5 % is not accepted by the current sizing grammar. Decimals such as 2.5% work; percentages must be greater than 0% and at most 100%.

Choose independent or shared allocations

Suppose the basis is 10,000, the universe contains four instruments, and two of them signal. These are desired targets, before capacity, costs and quantity rounding:

Declaration Target for each active name Combined target Inactive instruments
size: 10% per instrument 1,000 2,000 Each future entry has its own target.
size: 40% in total 1,000 2,000 Four names split 4,000 equally; the two inactive shares stay unused.
size: 40% across active instruments 2,000 4,000 The active names share the entire budget.

With in total, a continuing holding is not resized just because another name enters. With across active instruments, membership changes can resize existing holdings: if a third name joins, equal targets become approximately 1,333 each. Choose this when that rebalance is intended.

Independent entries do not automatically top up on every bar when the signal stays true or more cash becomes available. A new entry or reversal recomputes sizing. Hold strategies evaluate a target book and can rebalance it; active scope is rejected with hold: because hold already determines membership.

Choose the money basis

of portfolio follows current marked strategy equity. of starting capital uses the smaller of original funding and current equity. Both respect an optional Max capital ceiling configured for the strategy.

For a strategy initially funded with 10,000, with no extra capital ceiling:

Current equity 5% of portfolio 5% of starting capital
12,000 600 500
10,000 500 500
8,000 400 400

Starting-capital sizing does not keep requesting 500 after equity falls to 8,000. If Max capital is 6,000, both bases above are capped at 6,000 and a 5% target becomes 300. A blank Max capital adds no extra ceiling.

Write a percentage strategy

//@version=1
universe: [AAPL, MSFT, NVDA, AMZN]
run: daily
size: 40% of portfolio in total
entry:
    long when: rsi(14) < 30
exit:
    long when: rsi(14) > 55

Each eligible name has a 10% assigned share. Its RSI signal activates that share; it does not redistribute inactive shares. Change the scope to across active instruments if you intend the active names to share the full 40% and rebalance as membership changes.

Change the split with allocate:

Equal allocation is the default for a shared percentage budget. To give two eligible instruments different assigned shares:

//@version=1
universe: [AAPL, MSFT]
run: daily
size: 40% of portfolio in total
allocate: {AAPL: 70%, MSFT: 30%}
entry:
    long when: close > ema(20)
exit:
    long when: close < ema(20)

The weights divide the 40% budget: AAPL desires 28% of the basis and MSFT 12%. If only MSFT signals, its 12% share is used and AAPL's stays unused. With active scope, weights instead renormalize among the active names.

Keys must match the entire eligible list exactly, and positive weights must total 100%. allocate: requires a compatible shared objective; do not attach it to independent percentages, fixed quantities or stop-risk. Dictionary allocation with hold: is unsupported. See allocation details for a volatility-based split.

Use a fixed quantity instead

size: 10 units
size: 10 units per instrument
size: {AAPL: 10 units, MSFT: 5 units}

The first two request the same target: ten units for each entering position. unit, share and shares are accepted spellings. Counts must be positive whole numbers. Ten units stays ten units as the price or portfolio changes; the required money changes with the price.

A quantity map supplies a target for each instrument. Include every exact name from symbol: or universe:, with no extra or duplicate names. Use one quantity kind throughout, and do not combine a map with local quantity overrides or allocate:.

An entry can instead override the global size with long 2 units when: ... or short 2 units when: .... This replaces that entry's size; it does not add two units repeatedly while the same-side position remains open. Local quantities cannot be combined with a shared sizing objective.

For supported Forex currency pairs, size: 0.1 lots means 10,000 base-currency units. One standard lot is 100,000 base units; leverage changes margin rather than multiplying the quantity. Equity lots are unsupported. See Forex lot details.

Size from a planned stop loss

//@version=1
symbol: TCS
run: daily
size: risk 1% of portfolio with stop 5%
entry:
    long when: close > ema(20)
exit:
    long when: close < ema(20)

Here 1% is the planned loss budget, while 5% is the distance from entry to the stop. The inline stop supplies both the sizing distance and protection.

For a basis of 10,000 and an entry price of 100:

  1. Planned risk is 1% × 10,000 = 100.
  2. A 5% stop is 5 per unit from entry.
  3. Desired quantity is 100 ÷ 5 = 20 units, before venue rules and admission.

The desired position value is 2,000, so risk 1% differs from allocating 1%. A wider stop gives a smaller quantity for the same planned risk. Each simultaneous trade has its own budget; this declaration does not create a combined open-risk cap.

The basis may be omitted or set to starting capital; legacy per trade is accepted after it. You may also use size: risk 1% with a separate stop: 5%. A fixed percentage stop is required. Contradictory stops, ATR/points/absolute-price stops for this sizing method, and risk-sized hold strategies are unsupported. Gaps, slippage and costs can make actual losses differ from planned risk.

Target volatility

size: vol target 10% annualized over 63 daily bars per instrument

This calculates quantity from a volatility objective rather than allocating 10% or risking 10% at a stop. annualized and over 63 daily bars are the defaults. You can choose monthly or daily instead; these percentages describe different volatility horizons.

The default needs 63 completed daily returns, requiring at least 64 valid daily closes. This daily history is separate from the signal interval. Missing or invalid estimates block new exposure rather than falling back to a fixed allocation.

Independent volatility sizing happens at entry. Add resize: daily or resize: weekly to schedule size adjustments; only volatility sizing supports it. Scheduled size-only changes of 5% or less of held notional are skipped. Membership changes and required exits/reductions have different rules. Read volatility and resize before using a combined active/hold objective.

Targets, caps and actual fills

size: describes the desired target. A supported risk: declaration adds exposure caps:

risk: max 20% per instrument, gross <= 80%

These are exposure limits, not stop-loss budgets. Available capacity, pending orders, costs and legal quantities can constrain an order. A percentage target can be reduced to fit capacity. Fixed units, lots and stop-risk require their full calculated target under known local limits or skip. Confirmed broker fills can still differ from submitted orders.

Forex percentage sizing also depends on deployment leverage mode: Max uses desired margin, while fixed leverage scales desired exposure. Fixed units, lots and risk-derived quantities are not multiplied again. See Forex deployment modes and the complete sizing reference for exact constraints.