Page 1 of 1

Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Feb 13 2017
by dnickless
Hi all

I am running a 1d strategy in Portfolio Trader that selects some Nasdaq 100 components and takes a buy/sell/do nothing decision for each of them.

Using a Money Management Signal, I try to maximize my exposure in a smart way across all symbols. In order to do so, what I would want to make sure is that all SELL orders get executed before all BUY orders so I can use my full buying power. Otherwise BUY orders might get rejected because the pending SELLs have not been executed at the point in time when a BUY hits the broker.

How would I do that?

Thanks!

Re: Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Feb 13 2017
by Angelina MultiСharts
Hello dnickless,

If by SELL order you mean exiting the position, then we'd recommend checking the market position before generating the Entry.

It is also possible to check the state of the particular orders in your script. Please see the following examples, demonstrating how to get the order info from Order and Position Tracker:
viewtopic.php?t=10730
viewtopic.php?t=11028

Re: Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Feb 13 2017
by dnickless
Thank you! Let me try to be a bit more precise:

Imagine, the strategy buys one single stock today and it decides to put all my cash into it. Then tomorrow, it decides to sell the entire position and buy something else instead. In this case, while I'm still 100% invested, the broker potentially rejects the second attempt to buy stock because I'm out of cash. So I would want to execute the sell order first (so I would have cash again) and then buy again.

Re: Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Feb 14 2017
by Angelina MultiСharts
Dnickless,

It is not possible to set the execution order for the orders generated on one calculation.
Your strategy has to generate all the exit orders first, and the entry ones after checking the market position or Sell order statuses.

Re: Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Feb 14 2017
by dnickless
Thank you so far! How would I best go about implementing this logic? I basically have only one triggering event (bar close) where I take all my decisions at the moment.

Would I need to first process only sells in the bar close event and then use the RecalcAfter feature to trigger another event some seconds later? Would those orders still be sent to the broker even though the session is technically over?

Or can I use a session template to somehow define two points in time at which I run the calculation? E.g. 3:58pm (sells only) and 3:59pm (buy orders only)?

Or is there another way?

Re: Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Feb 17 2017
by Angelina MultiСharts
dnickless,

In this case the only solution I see is to use a more detailed resolution.
RecalcLastBarAfter will lead to strategy recalculation, but the the orders are not going to be sent intrabar.

Re: Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Feb 17 2017
by dnickless
Is every symbol calculated in its own thread and independent from other symbols? In this case, I might simply attempt to do a Thread.Sleep(10000) to pause for ten seconds when I want to buy. The sell orders would not get paused so they should be executed straight away. Could that work?

Re: Portfolio Trader + Money Management Signal: Sequence of order submission to broker

Posted: Mar 09 2017
by dnickless
Well, to answer my own question: All symbols run on the same thread, the Money Management signal runs on another one. So my idea did not work. ;(

@Angelina, regarding your idea of using a more detailed resolution: How exctly would that work? I need daily bars to take a trading decision at the end of a day (a few seconds before the Exchange closes - currently 1 minute with a session template that is configured to signal the session end at 15:59).