Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetTrades

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

    GetTrades

    Hi,

    I'm interested in use of the function:

    <TradeCollection>.GetTrades(string instrument, string entrySignalName, int instance)

    What happens if instance = 0? Will I get back *all* of the trades associated with instrument/entrySignalName?

    #2
    instance=0 is outside the scope of the logic provided by .GetTrades. Thus behavior is undefined. Please stick with the functionality documented: instance >= 1.

    Comment


      #3
      Originally posted by NinjaTrader_Dierk View Post
      instance=0 is outside the scope of the logic provided by .GetTrades. Thus behavior is undefined. Please stick with the functionality documented: instance >= 1.
      Well, let me ask the question this way then.

      How do I retrieve all trades associated with a particular instrument or signal?

      Comment


        #4
        You will likely need to loop through the Performance.AllTrades collection and build your own collection of trade objects.
        RayNinjaTrader Customer Service

        Comment


          #5
          Rebuilding a Collection of Trades outside a strategy with GetTrades()

          Hi!
          I want to access the Collection of Trades for a strategy outside the strategy, from an indicator or from another strategy.

          (The reason for this is that my strategy runs on a 3 min primary time frame but executes trades on a seccondary 1 min time frame. To be able to check backtesting results I want to visualize my money mangement functions by backcoloring another chart with a 1 min time frame, i e stop trading after X consecutive losses.)

          I understand that I have to loop through the Performance.AllTrades collection of a specific strategy and use the GetTrades() method to rebuild the collection of trade objects.
          Code:
          <TradeCollection>.GetTrades(string instrument, string entrySignalName, int instance)
          Questions:
          1. Can I use the Strategy Performance methods and Properties in an Indicator or do I have to use a strategy?

          2. Since the "Performance.AllTrades.Count" isn't available outside the strategy, how would I know when I have retrived the last trade in the Performance.AllTrades collection and have to stop the loop? Can I check for a "null!" value?

          3. My strategy uses three different entrySignalNames. Therefore the trades probably wont be added in the original order in the rebuilt ciollection. Is it important to sort the collection somehow before using it in calculations? How should it be sorted?

          4. Since the GetTrades() method only uses signal names to distinguish between different strategies of the same instrument, I suppose that it's important to use unique entrySignalNames in strategies, to avoid a mix of trades from different strategies in the new collection?

          /Regards

          Comment


            #6
            poseidon_sthlm, you would need to do this directly in the strategy placing those trades, as NinjaScript strategies would not cross communicate, thus not allowing you to access the performance class stats via an indicator unfortunately.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X