This is a follow up to the thread created a year ago: viewtopic.php?t=47676
I figured I'll give the Portfolio feature another chance as the problem in the previous thread is supposed to be resolved, but I quickly found another limitation that have been left out - the feature to adjust position size for exits in the same way as for entries.
Consider a long only ranking strategy, that ranks 4 markets and invests 40% in rank 1, 30% in rank 2, 20% in rank 3 and 10% in rank 4. In the strategy signal we don't know what position size we want, as it depends on that particular markets rank in relation to the others, hence we can't specify the position size here. We can only create a sell order, with the intention of adjusting the order size in the MM signal.
Once we're in the MM signal, after the markets have been ranked, this is when we know what position size we want. Adding to a signal (if the rank has improved) is no problem as we set AllowEntriesLong = true and specifies the difference between the desired and current position with EntryContracts.
If we need to decrease the position however, there is no equivalent to EntryContracts for Exits (and EntryContracts doesn't work for exits). When the sell order is allowed through it closes the full position, and then next bar reopens the position to the desired size. Note that specifying the size of the sell order in the strategy signal is not an option since we don't know the size at this time.
How can I place partial exits via the MM signal?
Partial exits in MM Strategy for Portfolio [SOLVED]
I should add that I'm using the latest version of .Net (as of today).
You wrote in the other thread:
"QGroup, we are going to add ability to allow/disallow and get/set position size for exit orders in MM signal in MultiCharts .NET 9.1."
.. so I assume there is a way to set the exit order position size in the MM signal? I've gone through the wiki, programming guide and PowerLanguage documentation but failed to find any.
You wrote in the other thread:
"QGroup, we are going to add ability to allow/disallow and get/set position size for exit orders in MM signal in MultiCharts .NET 9.1."
.. so I assume there is a way to set the exit order position size in the MM signal? I've gone through the wiki, programming guide and PowerLanguage documentation but failed to find any.
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Hello QGroup,
The ability to allow/deny all exits or specific long/short exits was indeed added in MultiCharts 9.1. As for the ability to get/set the exit order size through the PMM signal - explicit solution was not added due to the complexity and variety of existing exit commands and difference in order live handling. But there is an implicit solution which is similar and solves its purpose - you can calculate the order size of the exit in the PMM signal and send this value to the trading signal which in turn will generate and send the appropriate order.
The ability to allow/deny all exits or specific long/short exits was indeed added in MultiCharts 9.1. As for the ability to get/set the exit order size through the PMM signal - explicit solution was not added due to the complexity and variety of existing exit commands and difference in order live handling. But there is an implicit solution which is similar and solves its purpose - you can calculate the order size of the exit in the PMM signal and send this value to the trading signal which in turn will generate and send the appropriate order.
Thank you Henry,
can you please provide an example of such implicit solution? It's my understanding that the trading signals are always run first, and then the PMM in the end, hence sending information back to the trading signal will be with one bar delay? I can't find any methods accessible from the PMM that would allow me to set the order size of a trading signal other than EntryOrder.
Furthermore, what is the difference between CommonPortfolioData and MyPortfolioData? Both seems to share data between the signal and MM?
can you please provide an example of such implicit solution? It's my understanding that the trading signals are always run first, and then the PMM in the end, hence sending information back to the trading signal will be with one bar delay? I can't find any methods accessible from the PMM that would allow me to set the order size of a trading signal other than EntryOrder.
Furthermore, what is the difference between CommonPortfolioData and MyPortfolioData? Both seems to share data between the signal and MM?
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Hello QGroup,
Please find sample signals attached.
Please find sample signals attached.
- Attachments
-
- PortfolioSetExitSize_Ex.pln
- (2.41 KiB) Downloaded 589 times
Thank you Henry,
but unfortunately it doesn't work - it suffers from the problem I mentioned in the previous post. If you send data from the MM to the signal it won't be available until the follow bar, hence any partial exits have a 1 bar delay.
If you run it on 1h data, then strategy for each contract is run first (ie 8am), followed by the MM (8am) which sends the partial exit size to the signal. This is available in the strategy for each contract at 9am, but not 8am, hence suffers from a 1 bar delay..
To be able to properly use the Portfolio Manager we either need access to the order generation in each contract from the MM, or some kind of helper function where this can be set explicitly...
but unfortunately it doesn't work - it suffers from the problem I mentioned in the previous post. If you send data from the MM to the signal it won't be available until the follow bar, hence any partial exits have a 1 bar delay.
If you run it on 1h data, then strategy for each contract is run first (ie 8am), followed by the MM (8am) which sends the partial exit size to the signal. This is available in the strategy for each contract at 9am, but not 8am, hence suffers from a 1 bar delay..
To be able to properly use the Portfolio Manager we either need access to the order generation in each contract from the MM, or some kind of helper function where this can be set explicitly...
I take the lack of reply as it's indeed not possible to control partial exits one the correct bar? Is this a feature that is planned to be implemented, or will it be left out as it's too 'complex' as you say?
Without this feature the Portfolio Trader can unfortunately not use its full potential... too bad for an otherwise good product/idea.
Without this feature the Portfolio Trader can unfortunately not use its full potential... too bad for an otherwise good product/idea.
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Hello QGroup,
The code posted above is just an example of the order management code.
You need to make the necessary adjustments in the code to make it work the way you need it.
Please study the information in the following post for a better understanding of the Portfolio Trader mechanics:
viewtopic.php?f=19&t=49748#p121158
The code posted above is just an example of the order management code.
You need to make the necessary adjustments in the code to make it work the way you need it.
Please study the information in the following post for a better understanding of the Portfolio Trader mechanics:
viewtopic.php?f=19&t=49748#p121158
It still doesn't work properly. By adding a lower timeframe as data2 I can get the signal to calculate more than once per bar, so that after the MM has been run once the signal is run again and the partial exit is updated to the correct size. However, the change of partial exit size is ignored and it's the size specified when the signal first ran on the bar that is executed (for both MarketThisBar and MarketNextBar). Is this because IOG isn't available in portfolio backtesting?
If I add a flag so that the signal knows that the MM has been run first every bar (such as comparing the dates), then the code for sending the correct partial order is run through. However, no orders are executed at all since the sell order wasn't sent on the first time the signal was run the bar (same problem as above).
I've wasted too much time on this now. I will have to solve it with static classes instead of using the portfolio backtester..
If I add a flag so that the signal knows that the MM has been run first every bar (such as comparing the dates), then the code for sending the correct partial order is run through. However, no orders are executed at all since the sell order wasn't sent on the first time the signal was run the bar (same problem as above).
I've wasted too much time on this now. I will have to solve it with static classes instead of using the portfolio backtester..
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Hello QGroup,
There are no technical limitations that can prevent you from implementing such strategy. Please contract us directly if you need our programmers assistance with this development.
There are no technical limitations that can prevent you from implementing such strategy. Please contract us directly if you need our programmers assistance with this development.