Portfolio sizing question

Questions about MultiCharts and user contributed studies.
Xyzzy
Posts: 162
Joined: 19 Mar 2011
Has thanked: 43 times
Been thanked: 79 times

Portfolio sizing question

Postby Xyzzy » 09 Dec 2011

I'm developing a strategy that currently trades four e-mini futures symbols (@EMD, @ES, @NQ and @YM). It's a gap-open strategy that sometimes opens a position, and sometimes does nothing, depending on whether the "buy" criteria are met for any given symbol at the open of the day session.

I would like to set this up so that the strategy allocates 50% of the available equity to the first symbol that triggers an entry, allocates the remaining 50% of the available equity to the second symbol that triggers an entry, and does nothing for any remaining symbols that trigger an entry. For example, if I have $50K of available margin, it might place an entry for up to $25,000 worth of @EMD contracts, up to $25,000 worth of @ES contracts, and nothing for the remaining symbols (because the available margin is exhausted).

Can anyone point me in the right direction for code that would accomplish this? For example, are there any keywords to determine the total number of filled or pending orders for this strategy, for all symbols? I.e., so that I could determine whether zero, one, or two orders have already been placed?

Alternatively, are there any keywords that let met determine the total equity that is available for trading? Or would I just need to "roll my own" solution using the All Data Everywhere module to keep track of the total number of entries for the strategy?

If anyone can point me to any existing code, so that I don't need to reinvent the wheel, I'd greatly appreciate it. Many thanks in advance.

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

Re: Portfolio sizing question

Postby Henry MultiСharts » 09 Dec 2011

Unfortunately there are no such keywords at the moment to determine the total number of filled or pending orders for this strategy or for all symbols.

To determine the total equity that is available for trading you need to do the calculation:
TotalEquity = InitialCapital+NetProfit+OpenPositionProfit

PricePuzzle
Posts: 38
Joined: 21 Aug 2011
Has thanked: 14 times
Been thanked: 16 times

Re: Portfolio sizing question

Postby PricePuzzle » 09 Dec 2011

For example, are there any keywords to determine the total number of filled or pending orders for this strategy, for all symbols?
You can get unfilled order indirectly by
unfilled order = MarketPosition - MarketPosition_at_Broker_for_The_Strategy

MarketPosition is the position that shown on chart, to avoid the confusion, better to use the quantity that you need to buy.

Theorectically, you can adjust market position by ChangeMarketPosition keyword (I never try) to match your filled order (MarketPosition_at_Broker).
Last edited by PricePuzzle on 09 Dec 2011, edited 1 time in total.

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Portfolio sizing question

Postby furytrader » 09 Dec 2011

Another potential solution (although it might be a little unwieldy) would be to follow all four markets in each chart (with data1 being the market that you're trading in that chart, and data2, data3 and data4 being the other markets) and have the strategy evaluate each of the four markets in real time and determine whether the entry criteria is being hit on the other markets in order to determine how to size the trade for the primary (data1) market.

Xyzzy
Posts: 162
Joined: 19 Mar 2011
Has thanked: 43 times
Been thanked: 79 times

Re: Portfolio sizing question

Postby Xyzzy » 09 Dec 2011

Thanks everyone. Furrytrader, I had thought about something like you suggested. It's workable for four symbols, although it would get exponentially more difficult if I try to expand my strategy to trade more than four symbols.

I'll play with ADE for now to see if I can cobble together something that works.

As another possibility, would there be any downside if I just transmitted purchase orders to Interactive Brokers for the desired amount, and then let IB decide whether to accept or reject those orders? I.e., it should accept and fill the first two orders, and then decline any additional orders if they exceed my available equity. However, I don't know if that practice would be frowned upon.

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Portfolio sizing question

Postby furytrader » 09 Dec 2011

In re: to the idea of sending large order to IB, I don't think you want to get into that practice because, let's say that they didn't catch (due to a technical issue), you would be liable for any losses that result. It's better to have full control over the rules that govern how orders get executed on your behalf.

Xyzzy
Posts: 162
Joined: 19 Mar 2011
Has thanked: 43 times
Been thanked: 79 times

Re: Portfolio sizing question

Postby Xyzzy » 09 Dec 2011

Good point Furytrader. Thanks.


Return to “MultiCharts”