Portfolio Trader--stop generation on partial fills  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Portfolio Trader--stop generation on partial fills

Postby darob » 07 Dec 2016

This may apply to chart trading too, but I've been running Portfolio Trader for a few months now and have noticed that if an order doesn't fill completely the stop that normally generates on the fill isn't generated until the current bar closes (these are limit orders). I'm using 15 min bars so the delay can be significant. What is a good way to deal with this programmatically?

Thanks

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Re: Portfolio Trader--stop generation on partial fills

Postby darob » 09 Dec 2016

I've been looking at this thread and even though it's regular MC it seems to relate to my question. It starts with a question specifically about Portfolio Trader but am I correct in thinking the solutions discussed are not? My understanding is IOG isn't supported.

Very interested in any ideas regarding the problem.

Thanks

Edit: forgot to post the thread! viewtopic.php?f=1&t=47959

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

Re: Portfolio Trader--stop generation on partial fills

Postby Henry MultiСharts » 09 Dec 2016

Hello darob,

There are two ways to address this situation:
1) Stop generating the order in the code if it is partially filled, then the exit orders will be generated.
2) Use Unmanged orders (TradeManager) to place the stop order to exit the position. You will need to monitor the open position size and adjust the quantity for the exit order accordingly.

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Re: Portfolio Trader--stop generation on partial fills

Postby darob » 09 Dec 2016

Hi Henry, I'm liking option 1 and now I'm reviewing my code and per the attached screenshot it already should only be generating the order if StrategyInfoMarketPositionAtBroker == 0. If I understand this correctly the script is acting on this information at Bar.Close. So how do I force this to happen intra-bar in Portfolio Trader? Sorry if I'm being clueless here and missing something obvious (highly likely).
Screen Shot 2016-12-09 at 4.09.26 PM.png
(9.57 KiB) Downloaded 1393 times
Edit: I assume there'd need to be a timeout so as to not sabotage orders that take a few seconds to fill completely? Thanks again.

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Re: Portfolio Trader--stop generation on partial fills

Postby darob » 11 Dec 2016

It looks like shifting the strategy references to another data series and generating the orders in a higher resolution may work. Still interested in any other simpler ideas if you've got any.

Thanks

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Re: Portfolio Trader--stop generation on partial fills

Postby darob » 11 Dec 2016

Is this simple change enough to force a recalculation at a higher resolution (assuming the 2nd data series is 30 sec or something) and give me quicker stop placement on partial fills? The backtest results are identical but I don't see a way to test this except in live trading.
BarsOfData(2).png
(17.15 KiB) Downloaded 1391 times

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

Re: Portfolio Trader--stop generation on partial fills

Postby Henry MultiСharts » 12 Dec 2016

Hello darob,

I have further discussed this inquiry with our engineers and apologize for confusion.
Unfortunately there is no way to have an order cancelled and exits sent inside a 15 min bar in Portfolio Trader.
The most efficient solution will be using a lower resolution on data1 for trading.
Using unmanaged orders will still work, but requires more programming.

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Re: Portfolio Trader--stop generation on partial fills

Postby darob » 12 Dec 2016

I was afraid you were going to say that. So in the following, how do you get m_averagefc1.length to act on BarsOfData(2)? I think I have m_averagefc1.price figured out.
Screen Shot 2016-12-11 at 6.02.04 PM.png
(9.87 KiB) Downloaded 1382 times
Many thanks

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

Re: Portfolio Trader--stop generation on partial fills  [SOLVED]

Postby Henry MultiСharts » 13 Dec 2016

I was afraid you were going to say that. So in the following, how do you get m_averagefc1.length to act on BarsOfData(2)? I think I have m_averagefc1.price figured out.

Screen Shot 2016-12-11 at 6.02.04 PM.png

Many thanks
Darob, you do not need to have Length of data2. You need to specify data2 in the function constructor. See example here.


Return to “MultiCharts .NET”