Difference between Setpositionsize function and PositionSize

Greetings all,

Could you please guide me on the difference between Setpositionsize function and PositionSize= in a formula.

Setpoistionsize function is very well explained in the https://www.amibroker.com/guide/afl/setpositionsize.html

However, I have less clarity on positionsize= .

Regards,
Vijay

@VIJAYK, actually it is explained in the same document you linked.

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.

2 Likes

thank you very much @beppe I will look into it in more details.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.