PositionSize is an older way to do the same thing, but seems a bit more complicated.
The positionSize requires a sort of special "encoding":
From the documentation:
values below -2000 encode share count
values between -2000 and -1000 encode % of current position
values between -1000 and 0 encode % of portfolio equity
values above 0 encode dollar value
if you want to buy 150 shares you should assign to positionSize a value of -2150
if you want to set your position to 10% of the current posizion (for example to scale in/out) you should assign to positionSize a value of -1010
if you want to buy a new position for a value of 20% of the equity you should assign to positionSize a value of -20
if you want to invest 3000 USD (or other currency) to buy some shares you simply set it to 3000
By the way, the same "encoding" is used in the CBT phase to optionally change the Signal object .posSize from the default position size (for example for very volatile stocks) or/and to assign to it a specific number of shares to rebalance positions.