Trade several instruments¶
A fixed universe applies your rules to several instruments. Choose independent allocations or one shared budget.
Independent positions¶
//@version=1
universe: [TCS, INFY, RELIANCE]
run: daily
size: 5% per instrument
entry:
long when: rsi(14) < 30
exit:
long when: rsi(14) > 55
Each entering instrument targets 5% of the strategy portfolio basis. Three entries desire 15% combined before capacity and rounding. Continuing positions do not shrink to fund a new signal.
The RSI rule is evaluated for each instrument using that instrument's data. A TCS signal does not enter INFY automatically. The list identifies eligible instruments; it does not force all of them to hold a position.
One shared budget¶
size: 30% in total
The full eligible list splits the budget equally by default: three names each receive a 10% assigned share. If one signals, inactive shares remain unused.
across active instruments divides the budget across active members and can resize continuing holdings. It is not a synonym for in total.
For a basis of 10,000 and the three-name list above:
| Scope | If only TCS signals | If TCS and INFY are active |
|---|---|---|
30% in total |
TCS desires 1,000; 2,000 stays unused. | Each desires 1,000; the remaining share stays unused. |
30% across active instruments |
TCS desires 3,000. | Each desires 1,500; the existing TCS holding can be resized. |
These are target amounts before capacity and rounding. Omitting the scope, as in size: 30%, means 30% per entering instrument in this conditional strategy. It can therefore desire 90% across three entries. Read position sizing before changing between these forms.
Assign unequal shares¶
size: 30% in total
allocate: {TCS: 50%, INFY: 30%, RELIANCE: 20%}
The weights divide the 30% budget, so the assigned targets are 15%, 9% and 6% of the basis. They are not independent portfolio percentages. With ordinary total scope, an inactive instrument's share stays unused. With active scope, the declared weights renormalize across the active names.
Include the exact full list of names and positive weights totaling 100%. Allocation is separate from a fixed quantity map; percentage weights belong in allocate:, while quantities belong in size:.
Different fixed quantities¶
size: {TCS: 2 units, INFY: 5 units, RELIANCE: 3 units}
Keys must match the full universe exactly and values must use one quantity type. A fixed target is admitted in full or skipped under known local limits; broker fills can still be partial.
In this map, TCS targets two units, INFY five and RELIANCE three whenever each has a new entry. Different prices mean different invested amounts. Map order does not change execution order, and the map does not top up an existing same-side position each bar.
Next topic Hold a portfolio →