Portfolio Trader - % Equity Doesn't Seem to Work as Expected
Posted: Nov 02 2021
Hello,
(Sorry, long post here!)
I'm trying to understand how the allocation of capital works with the Portfolio Trader as it doesn't seem to be working as I'd expect.
I've created a simple buy and hold strategy to test this using a collection of stocks that simply buys as soon as the Barnumber is >= 0.
I use the Portfolio Trader reserved words for determining the capital. Here is my sample code:
Now, I have 30 stocks loaded in my portfolio. Each trade that I take uses 3% of available equity. This should mean every stock has enough room to be added (with 30 stocks at 3% I will be at 90% capacity).
I then use these settings in Portfolio Settings:
Exposure (% of Portfolio Capital): 100%
Max % of Capital at Risk per Position: 100%
Initial Capital: 100,000
Margin Value: 100%
Max Potential Loss: 100%
When I load the strategy I can see that it indeed allocates the 3% of the value for each trade. But, it stops adding new stocks after only 19 stocks have been taken - so 57% of capital only. I thought perhaps the equity curve had dropped significantly, but no, this didn't happen and in fact 19 stocks is all that the strategy ever takes.
So, I thought I would change the Max % of Capital setting from 100% to 3% (even though I've already set 3% in the strategy). Now, every stock has been added to the strategy (despite the lower %) BUT the amount of capital per trade is wrong (by a multiple of about 0.5x); it completely ignores my number of shares setting in the strategy.
I think I have probably misunderstood how the portfolio's equity is used against the number of shares traded in the strategy? How does the Max % of Capital relate to what is specified in the strategy?
Any ideas please?
Many thanks,
Peter.
(Sorry, long post here!)
I'm trying to understand how the allocation of capital works with the Portfolio Trader as it doesn't seem to be working as I'd expect.
I've created a simple buy and hold strategy to test this using a collection of stocks that simply buys as soon as the Barnumber is >= 0.
I use the Portfolio Trader reserved words for determining the capital. Here is my sample code:
Code: Select all
Variables: NumContracts(0), PercentPerTrade(3);
If GetAppInfo(AiIsPortfolioMode) = 1 then
Numcontracts = (Portfolio_Equity * (PercentPerTrade / 100)) / Close
Else
Numcontracts = 1000 / Close;
If BarNumber >= 0 Then Buy NumContracts Shares Next Bar Market;
If LastBarOnChart Then SetExitOnClose;
I then use these settings in Portfolio Settings:
Exposure (% of Portfolio Capital): 100%
Max % of Capital at Risk per Position: 100%
Initial Capital: 100,000
Margin Value: 100%
Max Potential Loss: 100%
When I load the strategy I can see that it indeed allocates the 3% of the value for each trade. But, it stops adding new stocks after only 19 stocks have been taken - so 57% of capital only. I thought perhaps the equity curve had dropped significantly, but no, this didn't happen and in fact 19 stocks is all that the strategy ever takes.
So, I thought I would change the Max % of Capital setting from 100% to 3% (even though I've already set 3% in the strategy). Now, every stock has been added to the strategy (despite the lower %) BUT the amount of capital per trade is wrong (by a multiple of about 0.5x); it completely ignores my number of shares setting in the strategy.
I think I have probably misunderstood how the portfolio's equity is used against the number of shares traded in the strategy? How does the Max % of Capital relate to what is specified in the strategy?
Any ideas please?
Many thanks,
Peter.