The system I am testing opens random number of positions every day (Long only), and closes at the end of the day (yesterday bought 4 stocks, today bought 10 stocks, etc.). I am trying to allocate the same % of equity to each position, but since the number of positions is different every day I am not sure how to do it.
I used:
SetPositionSize(10,spsPercentOfEquity)
- but it didn't solve the problem as it always allocates 10% of equity to each position, no matter how many positions it is going to open.
What I need is (for example):
- when the system buys 4 stocks it should assign 25% of equity to each stock
- when it buys 10 tocks it should assign 10% of equity to each stok
- when it opens 20 positions it should assign 5% of equity to each stock, etc.
Is there any way to code it?
Thank you in advance
Daniel
I used:
SetPositionSize(10,spsPercentOfEquity)
- but it didn't solve the problem as it always allocates 10% of equity to each position, no matter how many positions it is going to open.
What I need is (for example):
- when the system buys 4 stocks it should assign 25% of equity to each stock
- when it buys 10 tocks it should assign 10% of equity to each stok
- when it opens 20 positions it should assign 5% of equity to each stock, etc.
Is there any way to code it?
Thank you in advance
Daniel