View Full Version : Unable to access Performance.LosingTrades
trader_rick
05-07-2008, 05:54 PM
Hi guys,
I can successfully access the Performance.AllTrades collection but when I reference Performance.LosingTrades or Performance.WinningTrades in my code I get the following error message on compilation:
NinjaTrader.Strategy.SystemPerformance does not contain a definition for 'LosingTrades'
CS0117
All I'm trying to access is Performance.LosingTrades.Count.
Have these collections been withdrawn or something?
regards
NinjaTrader_Dierk
05-07-2008, 10:33 PM
Nothing has changed on this property on NT6.5. Could be typo in your code. Please consult the docs and use the editor intellisense to resolve this issue.
trader_rick
05-08-2008, 09:39 AM
There are no typos.
I have consulted the docs.
The intellisense does not list WinningTrades or LosingTrades as members of Performance.
On experimenting I have found that the problem is in your documentation.
The only reference to these objects is in the help on TradeCollection Class. However, your examples are incorrect. WinningTrades and LosingTrades are members of Performance.AllTrades NOT Performance as stated in the help.
Please update your documentation.
regards
NinjaTrader_Ray
05-08-2008, 09:59 AM
The documentation for the Performance class does not list WinningTrades as property and is accurate.
The only thing I do see is a typo in some sample code in the TradeCollection class and this will be changed. Thanks.
mgbloomfield
05-11-2008, 02:38 AM
What's the code for accessing Performance.AllTrades? Mine throws an error.
protected override void OnPositionUpdate(IPosition myPosition)
{
string myTradePnL = Performance.AllTrades[0].ProfitPoints.ToString();
...
...
}
The error is (from the log): Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
OnPositionUpdate() is called because the strategy reversed the trade so there should be at least one trade where I can grab the ProfitPoints of the recent trade.
NinjaTrader_Dierk
05-11-2008, 02:41 AM
Will not work as Performance.AllTrades had no items. You'll need to add some code like
if (Performance.AllTrades.Count == 0)
return;
Please make sure you understand how collections work in .NET before you get into coding at that detailed level. Please consult the MS docs for details.