Tracking strategy performance in Portfolio Trader  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 76 times
Contact:

Tracking strategy performance in Portfolio Trader

Postby fbertram » 25 Oct 2014

Dear MultiChart team,

let me first mention that I am really thrilled about the things I can do with the MultiCharts Portfolio Trader. It seems there is virtually nothing that can be done with Portfolio Trader - but I am stuck with a problem that seems more effort to solve than it needs to be. Unless I am missing a better way to do this, this is probably a feature request.

Here is what I would like to do:
* add some (maybe 200) instruments to the portfolio strategy
* add some signals (e.g. your readily supplied ones) to the strategy
* create my own money-management signal, which will be basing decisions on the individual instrument strategies

In order for this to work properly, I would need to report the trading performance of the individual instruments to the money-management _prior_ to enabling/ disabling/ resizing orders in the money-manager.

I have tried to set up a 'reporter signal' which reports the performance to the money-manager:

Code: Select all

variable: PortfolioValue(100);
variable: LastPosition(1);

while(LastPosition < MaxPositionsAgo) begin
var: bars_ago(0); bars_ago = MaxPositionsAgo - LastPosition;
var: myEntry (0); myEntry = EntryPrice(bars_ago);
var: myExit (0); myExit = ExitPrice (bars_ago);
PortfolioValue *= myExit / myEntry;
LastPosition += 1;
end;
if GetAppInfo(aiIsPortfolioMode) = 1 then pmm_set_my_named_num("PortfolioReporter-Value", PortfolioValue);
Unfortunately this doesn't work. The moment an instrument gets disabled, I stop seeing orders here - leading to my performance values for that instrument to being flat. I'd say that a strategy should behave exactly the same, regardless of it running in a chart window or in portfolio trader and would therefore tend to consider this behavior a conceptual problem.

What I am looking for is a call like this:

Code: Select all

pmms_get_strategy_current_value(strategy_index);
This function would return the current value of the strategy, regardless of any calls to pmms_strategies_deny_entries_all, pmms_strategy_set_entry_contracts or similar. Basically, the return value of this function would be identical to the performance you see when applying a signal to a single instrument in a chart window.

I could then do something like this in my money manager code:

Code: Select all

value[strategy_index] = pmms_get_strategy_current_value(strategy_index);
performance[strategy_index] = value[strategy_index][0] / value[strategy_index][60];
The current workaround requires the instrument strategy go report its performance to the money-manager as outlined in your PortfolioRankSignalBase code. This is not ideal, as a user can no longer freely combine all the existing strategies - but needs to write a new one that reports its performance to the money manager.

There is a similar problem for resizing positions. Your PortfolioRankSignalBase code currently reports the stock price to the money manager using a named num. It would be much cleaner if the money-manager could retrieve some information on potential entry costs for positions and resize based on that.

Looking forward to your feedback and thoughts!

Thank you,
best regards, Felix

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Tracking strategy performance of individual instruments

Postby Henry MultiСharts » 27 Oct 2014

Hello Felix,

In order to study this case please explain what you mean by "The moment an instrument gets disabled".

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

Re: Tracking strategy performance of individual instruments

Postby fbertram » 27 Oct 2014

Hi Henry,

thanks a lot for following up.

What I'd like to do, is to create a portfolio MM signal, which uses the trading performance (based on the signals used for entering raw orders) as the criterion to make portfolio decisions.

In order to do that, I need to be able to determine the 'raw' performance of the signals trading the instruments. There are ways to retrieve the performance of the signals, e.g. using pmms_strategy_netprofit. The problem why I can't use these, is that I can't use these, as the portfolio MM signal will influence the result of that, e.g. when issuing pmms_strategy_set_entry_contracts against that instrument. I would need to have access to the performance _prior_ to the portfolio MM signal making any adjustments.

Looking at portfolio trader, I really like the idea of keeping money management separate from the signals used to trade individual signals. Missing a way to feed back the raw performance to the money management code breaks with that idea, as I will now need to create specialized code to measure the raw performance (which needs to adapted to match the way the signals work). That's why I tried to create this reporter (or observer) signal. Unfortunately, that too will see altered results, based on calls to pmms_strategy_set_entry_contracts.

IMHO, the most orthogonal design for the Portfolio Trader would be to keep the signals running on the individual instruments completely sand-boxed. They should not know what the porfolio MM signal is doing and should not see any side effects from that. The only way to pinch holes through that sand box should be the named variables.

Thank you,
best regards, Felix

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Tracking strategy performance of individual instruments

Postby Henry MultiСharts » 28 Oct 2014

Hello Felix,

Have you tried adding a condition to your PMM signal to execute it's logic only after this condition is met (after you get the 'raw' performance of the signals)?

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

Re: Tracking strategy performance of individual instruments

Postby fbertram » 28 Oct 2014

Hi Henry,

I am not sure I fully understand what you are suggesting. In case I misunderstood you, please clarify a bit more what you had in mind.

To measure the 'raw' performance, I need to have the signals associated with the instruments run undisturbed. Unfortunately, that is not the case. The signals see the effects of the PMM signal altering the number of contracts and enabling/ disabling trades. Therefore, I could only measure the raw performance for a little while... until the PMM starts moving the portfolio around and making that raw measurement impossible for the future.

Maybe I should try to describe what I am trying to do once more and in a different way:
* I am looking at a number of stocks, let's say 200
* I am using signals to trade these stocks, I'd like to use a lot of your built-in standard signals
* I am writing my own PMM code, which is denying entries for poor performers, enabling entries for top performers and adjusting order sizes based on the total portfolio value

Now here is the problem I have: the decision which stocks to deny entries for and which orders to allow entries is based on the performance of the signals with that specific stock. There is no simple indicator to measure that, e.g. the trading performance is probably completely independent from than the stock performance. I also cannot retrieve the 'raw' performance by using any other pmm functions, as these will return results _after_ the denying/ enabling entries and adjusting order sizes.

That's exactly where the proposed additional keyword comes in. It's a feature request. The feature will help to further separate signals from PMM signals, make them more independent from each other and make the Portfolio Trader more useful to the customer.

Let's look at your Portfolio Rank example. It would be great if you could use the PMM signal as is and combine it with virtually any of the signals from your library. Based on the historic performance of the trading signals for that specific stock, the PMM signal would make a decision which stocks to enable entries for and which ones to deny. Right now, you can't do that. Instead you need specialized trading signals, which pass information up to the PMM signal. Please kindly consider this feature request.


Thank you,
best regards, Felix

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Tracking strategy performance of individual instruments   [SOLVED]

Postby Henry MultiСharts » 29 Oct 2014

Felix, thank you for your suggestion. Implementation of such functionality is not a trivial task and it requires significant changes in current implementation of MultiCharts components. You may want to submit a feature request to the Project Management of our web site so other users can vote for it: https://www.multicharts.com/pm/

strelow

Re: Tracking strategy performance of individual instruments

Postby strelow » 29 Oct 2014

Very good your Idea . I´m trying something similar with same problem. I will vote for this in next release.

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

Re: Tracking strategy performance of individual instruments

Postby fbertram » 29 Oct 2014

filed as issue MC-1789.

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

Re: Tracking strategy performance of individual instruments

Postby fbertram » 02 Nov 2014

I have submitted some demo code, showing how this feature would be used:
https://www.multicharts.com/pm/viewissu ... no=MC-1789

Please vote!

Thank you,
best regards, Felix

strelow

Re: Tracking strategy performance of individual instruments

Postby strelow » 02 Nov 2014

I tried to open this file but I can´t (sa_PerlStocka20Generica20MM.el)

This is not a pla file ? to read inside editor ?

This example is not write in Multichart.net correct ?

Thanks.

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

Re: Tracking strategy performance of individual instruments

Postby fbertram » 02 Nov 2014

Hi Strelow,

the sample is in PowerLanguage (aka EasyLanguage) for the regular MultiCharts edition.

Thank you,
best regards, Felix

strelow

Re: Tracking strategy performance of individual instruments

Postby strelow » 02 Nov 2014

Hello Felix

Could you export in "pla" format ? than I can read inside MultiCharts64 PowerLanguage Editor.

Thanks.

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

Re: Tracking strategy performance of individual instruments

Postby fbertram » 02 Nov 2014

Hi Strelow,
I uploaded the files as PLA to the bug:
https://www.multicharts.com/pm/viewissu ... no=MC-1789

Thank you,
best regards, Felix

strelow

Re: Tracking strategy performance of individual instruments

Postby strelow » 03 Nov 2014

Thanks Felix .

Regards


Return to “MultiCharts”