Portfolio Money Management questions

Questions about MultiCharts and user contributed studies.
TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Portfolio Money Management questions

Postby TraderWalrus » 04 Aug 2017

I just started to work with this tool. A few unclear points:

1. Using pmms_strategy_set_entry_contract (see code below) only works starting from the second trade onwards, for each symbol. At the first trade of a certain symbol the trade size is determined according to the properties of the specific strategy. Shouldn't it work starting from the first trade?

2. In the code below I used 10 contracts for testing purposes. I want however to set the trade size using a calculation that needs to know the price of the instrument. For example, with a capital of $10,000 and 5 positions, I will allocate $2,000 per each and then divide that by the instrument price to get to the required trade size. How do I access that figure?

Code: Select all

var: curPos(0), curStrategyIndex(0), positions(0);

array: strategyIndexes[](0);

positions = pmms_strategies_in_positions_count(strategyIndexes);

for curPos = 0 to array_getmaxindex(strategyIndexes)
begin
curStrategyIndex = strategyIndexes[curPos];
pmms_strategy_set_entry_contracts(curStrategyIndex,10);
end;

User avatar
Anna MultiCharts
Posts: 418
Joined: 14 Jul 2017
Has thanked: 30 times
Been thanked: 105 times

Re: Portfolio Money Management questions

Postby Anna MultiCharts » 07 Aug 2017

Hello, TraderWalrus!

Let me address your questions in order:

1. pmms_strategy_set_entry_contract is called when the strategy has already entered a position.

2. You can do that through Global Variables — the strategy should calculate the trade size and then send it to PMMS through GV or it can take the current Close through GV and then PMMS will calculate the Trade Size itself.

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Portfolio Money Management questions

Postby TraderWalrus » 07 Aug 2017

Thanks Anna. So, the followup question to (1) will naturally be, how do you set the size before the strategy enters a position?
Same issue applies to question (2).

Do you have more documentation available apart from the keywords page and the examples detailed in the following link?
https://www.multicharts.com/trading-sof ... y_Examples

I see this was a request in the thread below. It is really tricky to understand how to use this tool with the current documentation.
viewtopic.php?t=49965

User avatar
TJ
Posts: 7181
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: Portfolio Money Management questions

Postby TJ » 07 Aug 2017

[FAQ] Portfolio Trader / Portfolio Backtester
viewtopic.php?t=47045

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Portfolio Money Management questions

Postby TraderWalrus » 07 Aug 2017

Thanks TJ, however apart from the two links I mentioned (keywords list and 3 examples) there is very little in hte FAQ regarding using pmm in code.

Specifically, how to set positions sizes by pmm signals (and obviously it needs to be set before the strategy enters a position rather then after it does).

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 73 times
Contact:

Re: Portfolio Money Management questions

Postby fbertram » 08 Aug 2017

Specifically, how to set positions sizes by pmm signals (and obviously it needs to be set before the strategy enters a position rather then after it does).
that is actually not what's happening. The process is like this:
1) the strategy creates an order
2) the money-management strategy can now adjust the position size on that order (or deny it)
3) the adjusted order gets executed

this code example might help:
viewtopic.php?t=50184


Cheers, Felix

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Portfolio Money Management questions

Postby TraderWalrus » 08 Aug 2017

Thanks Felix, this is very helpful.

I replied to your post with a follow up question.

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Portfolio Money Management questions

Postby TraderWalrus » 08 Aug 2017

A minor point, looks like a bug, regarding backtesting in Portfolio Trader:

When working with daily bars, the last bar isn't processed if backtesting is done before midnight, even though the bar is already closed according to the default session. Backtesting done on a chart with the same signal and instrument does process the last bar at those times.

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Portfolio Money Management questions

Postby TraderWalrus » 09 Aug 2017

Another question on this topic - how, from the pmm signal, can I get the number of strategies with orders that should be executed, before the strategies are in a position?

I tried using pmm_set_my_named_str at the trading signal to flag whenever an order is sent. But then I print the results and find out that sometimes the same bar is evaluated by the pmm signal twice (daily bars, all default sessions), and so I get two different values for the flag, for the same bar!

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 73 times
Contact:

Re: Portfolio Money Management questions

Postby fbertram » 09 Aug 2017

you should be able to set a flag using pmm_set_my_named_num, and check that flag from the portfolio signal.

User avatar
Anna MultiCharts
Posts: 418
Joined: 14 Jul 2017
Has thanked: 30 times
Been thanked: 105 times

Re: Portfolio Money Management questions

Postby Anna MultiCharts » 09 Aug 2017

Hello, Trader Walrus!

Keeping in mind that pmms_strategies_in_positions_count refers to the strategies that already have open positions, you need to modify your script the way that pmms_strategy_set_entry_contracts is not called under the condition, but at the exact moment. You need to make so that your PMM signal could modify orders' volumes from the first calculation of the strategy.
Here's an example:

Code: Select all

var: curStrategyIndex(0), MaxStrategyes(0);

array: strategyIndexes[](0);

MaxStrategyes = pmms_strategies_count;

for curStrategyIndex= 0 to MaxStrategyes - 1
begin
pmms_strategy_set_entry_contracts(curStrategyIndex, 10);
end;
All of the PMM related articles can be found down this link:
https://www.multicharts.com/trading-sof ... =PMM&go=Go
Unfortunately, at the moment this is all information we can provide on this matter.


Return to “MultiCharts”