Hi All,
I would like to perform some calculations on positions I currently hold at my broker. I have no problem getting the broker position data I need (updated in real time) in a Multicharts Order and Position Tracker window. I don't anticipate any problem doing all the calculations I need to do in a Real-Time Market Scanner window. But, I can't figure out how to get the data from the Order and Position Tracker window over to the Real-Time Market Scanner window. I am hoping there is an easy way to do this that I haven't been able to find in the documentation or online.
Does anyone have any pointers or suggestions on how I might go about doing this?
Thanks!
Eric
Additional info:
(1) For my calculations, I need the following data from my broker: (i) the list of instrument names, (ii) quantity held (long or short), and (iii) average price paid. All other data (historical data, and real-time market data) I need, I can easily get in to the Real-Time Scanner (or perhaps into Portfolio Backtester, if that is a better way to go).
(2) I am not using Multicharts to drive the actual trading in this account.
(3) I typically have about 100 positions, so I can't use an approach that requires a chart per instrument, or manually entering instrument names.
(4) I'd like to avoid an approach that requires exporting the open positions data to a file and then importing that file into the scanner, if that loses the real time updating capability. But, if that is the only way to go, that is better than nothing.
Positions at broker into Scanner?
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Positions at broker into Scanner?
As far as I know, that can't be pulled from the broker through PowerLanguage. However, if you make an indicator that shows the current market position (see below), you could auto-sort the Real-time market scanner on this, so that it would be relatively easy to see which instrument has an open position and which not.(1) For my calculations, I need the following data from my broker: (i) the list of instrument names,
You could use the I_CurrentContracts and I_MarketPosition for this (when used in an indicator).(ii) quantity held (long or short),
You could use I_AvgEntryPrice, I_AvgEntryPrice_at_Broker, or I_AvgEntryPrice_at_Broker_for_the_Strategy for this (see this wiki page).and (iii) average price paid.
In theory MultiCharts should be notified about the orders placed by another application, so the market position according to MultiCharts will then the same as the broker position (though this depends on correct symbol mapping settings).(2) I am not using Multicharts to drive the actual trading in this account.
I'm not sure though what the I_MarketPosition function will return then; the MultiCharts strategy position (which would be sure in such a case) or the broker position.
I thought it's possible to insert multiple instruments at once for the real-time market scanner, but I'm not sure.(3) I typically have about 100 positions, so I can't use an approach that requires a chart per instrument, or manually entering instrument names.
An approach with an indicator that you may try is: (untested)
Code: Select all
Plot1(I_CurrentContracts * I_MarketPosition, "Quantity");
Plot2(I_AvgEntryPrice_At_Broker, "AvgEntryPrice");
Re: Positions at broker into Scanner?
Thanks for suggesting this great approach, Josh. I think this will work well.
Thanks!
Eric
I see that the Real-Time Market Scanner will support up to 5000 Instruments, so I can just input the entire universe of potential Instruments into the list, and then sort based on a non-zero market position value at the broker, as you suggest. I'll make all the other calculations contingent on that non-zero value, so things don't bog down, and I don't hit the limits from my data providers.ericvp wrote:
(1) For my calculations, I need the following data from my broker: (i) the list of instrument names,
As far as I know, that can't be pulled from the broker through PowerLanguage. However, if you make an indicator that shows the current market position (see below), you could auto-sort the Real-time market scanner on this, so that it would be relatively easy to see which instrument has an open position and which not.
Thanks!
Eric
Re: Positions at broker into Scanner?
I feel like I must be missing something obvious here.
When I attempt to use any of the functions suggested by JoshM, I do not seem to be able to pull data from my broker (IB). I am still able to pull all position information from my broker through the Multicharts Order and Position Tracker. But, I get "0" returned for each Instrument using using each of the following functions:
i_CurrentContracts
i_CurrentShares
i_MarketPosition
i_MarketPosition_at_Broker
i_AvgEntryPrice_at_Broker
After reviewing the documentation and searching online, I suspected something to do with Auto Trading being turned off. I do not see a way to turn it on from within the Real-Time Market Scanner. When I turned it on for one Instrument from within a Chart window in the same workspace, I still got zero values returned by the above functions.
Any thoughts on what I might be missing?
Eric
When I attempt to use any of the functions suggested by JoshM, I do not seem to be able to pull data from my broker (IB). I am still able to pull all position information from my broker through the Multicharts Order and Position Tracker. But, I get "0" returned for each Instrument using using each of the following functions:
i_CurrentContracts
i_CurrentShares
i_MarketPosition
i_MarketPosition_at_Broker
i_AvgEntryPrice_at_Broker
After reviewing the documentation and searching online, I suspected something to do with Auto Trading being turned off. I do not see a way to turn it on from within the Real-Time Market Scanner. When I turned it on for one Instrument from within a Chart window in the same workspace, I still got zero values returned by the above functions.
Any thoughts on what I might be missing?
Eric
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Positions at broker into Scanner?
Nope, you're not missing anything. I'm mistaken here - the indicator reserved words (with I_ ... ) don't work in an indicator for the Market Scanner. That's quite a disappointment and a problem for your goal.I feel like I must be missing something obvious here.
An alternative would be to create a chart for each instrument, and use a global variable to send the data from that chart to the market scanner - however that's not a real solution since you already said that's not doable for your situation/setup.
So I'm out of ideas, perhaps other users have an idea? Alternatively, you can wait for the portfolio trading to be implemented or you can add a feature request (you certainly would have my vote ) but this all is quite a lengthy road.
Re: Positions at broker into Scanner?
JoshM, thanks for the response. I guess I'll go with my non-ideal plan B that requires an intermediary file output from my broker's software, and read in by Multicharts.
Like you, I am anxiously awaiting the Portfolio Trader functionality. I just hope they make it workable for portfolios on the order of 100 Instruments (ie, too large to have a chart per Instrument).
Thanks,
Eric
Like you, I am anxiously awaiting the Portfolio Trader functionality. I just hope they make it workable for portfolios on the order of 100 Instruments (ie, too large to have a chart per Instrument).
Thanks,
Eric
Re: Positions at broker into Scanner?
A small MC .NET PR
MultiCharts .NET will help you. There are low-level trading infrastructure ("PowerLanguage.TradeManager") accessible from any type of study. Access to trading capabilities of any broker (profile) and access to all trading events (order statuses, position's updates, connection states, etc.)
MultiCharts .NET will help you. There are low-level trading infrastructure ("PowerLanguage.TradeManager") accessible from any type of study. Access to trading capabilities of any broker (profile) and access to all trading events (order statuses, position's updates, connection states, etc.)