How to determine total number of open orders for strategy?  [SOLVED]

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

How to determine total number of open orders for strategy?

Postby Xyzzy » 01 Sep 2013

I have a strategy that I'll be running simultaneously on a number of charts for different symbols. I would like for the strategy to determine how many orders are currently open (across all of the charts/symbols), and only enter a new position if there are fewer than X orders that are currently open.

I can simulate this in the Portfolio Backtester using the Portfolio_CurrentEntries keyword and the following logic (where MaxEntriesTotal is an input):

Code: Select all

Condition1 = Portfolio_CurrentEntries < MaxEntriesTotal;
Unfortunately, the Portfolio_CurrentEntries keyword only works in the Portfolio Backtester, not when applied to charts in MultiCharts.

One option is to have a counter that's stored in a global variable. However, this would be a bit of a bother -- I'd need to have code that determines when an order has been opened or closed for each symbol, and increase or decrease the counter accordingly.

I'm also aware of the MarketPosition_at_Broker_for_The_Strategy keyword. However, this appears to return the total number of contracts held. I'm looking instead for the total number of open orders.

Are there any easier ways to count the total number of entries that are currently open for a strategy, across all charts that are running that strategy?

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

Re: How to determine total number of open orders for strateg  [SOLVED]

Postby Henry MultiСharts » 18 Sep 2013

Hello Xyzzy,

There is no dedicated reserved word for getting the number of currently open orders across all charts. You can get the number of open entries for the current position with the help of CurrentEntries. Then use Global Variables to transfer the values between charts.


Return to “MultiCharts”