Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to access Performance.LosingTrades

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Unable to access Performance.LosingTrades

    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

    #2
    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.

    Comment


      #3
      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

      Comment


        #4
        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.
        RayNinjaTrader Customer Service

        Comment


          #5
          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.

          Comment


            #6
            Will not work as Performance.AllTrades had no items. You'll need to add some code like
            Code:
            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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,602 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X