Getting opened positions with TradeManager  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
Fabrice
Posts: 182
Joined: 14 Jun 2011
Has thanked: 44 times
Been thanked: 30 times

Getting opened positions with TradeManager

Postby Fabrice » 16 Oct 2013

Hello,
I am trying to get info about opened positions using ITradeManager. But positions.Items.Count() remains at 0. I have 1 opened position for this symbol displayed in OTM window.

Code: Select all

if (prof.ConnectionState == ATCenterProxy.interop.ETM_ConnectionChanged.eTM_CC_Connected)
{
var acc = prof.Accounts[0];
var symbol = new MCSymbolInfo(Bars.Info.ASymbolInfo2, Bars.Info.DataFeed);

// Règle le profile
prof.CurrentAccount = acc;
prof.CurrentSymbol = symbol;
Output.WriteLine("symbol = {0}", symbol.symbol.SymbolName);

// Règle la position
pos.ProfileFltr.CurrentValue = prof.Name;
pos.AccountFltr.CurrentValue = acc;
pos.SymbolFltr.CurrentValue = symbol.symbol.SymbolName;

Output.WriteLine("Nombre de positions = {0}", pos.Items.Count());
}
prof.Name, acc, symbol are all ok.
Thanks.

Dru
Posts: 107
Joined: 28 Aug 2007
Has thanked: 4 times
Been thanked: 171 times

Re: Getting opened positions with TradeManager  [SOLVED]

Postby Dru » 16 Oct 2013

All of the above mentioned events are generated at strictly defined moments, for example, when a position or order update event is received from the broker. Respectively, the updating of the collection elements that are accessed via the Items property is also performed at a strictly defined moment. This moment is defined by calling the ITradeManager.ProcessEvents() method.
All collected events, elements collection changes, events from IDataSource<T> interface that start being generated, on all the elements for a current moment start being applied within this call and the current thread. The chronological order of the events within a single collection stays the same. The reason for this is that the indicator/signal is not a stand-alone application but a component that should be executed in certain conditions and environment.

Fabrice
Posts: 182
Joined: 14 Jun 2011
Has thanked: 44 times
Been thanked: 30 times

Re: Getting opened positions with TradeManager

Postby Fabrice » 16 Oct 2013

I have been able to make it work.
Thank you very much Dru.


Return to “MultiCharts .NET”