Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetTrades()

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

    GetTrades()

    Hi,

    I am trying to use GetTrades() to get a TradeCollection of trades from a given IOrder (o) Name using the code below in OnPositionUpdate once the trade is flat.

    TradeCollection currentTrades = Performance.AllTrades.GetTrades("6E 12-10", o.Name, 1);

    I have also tried this using Instrument.FullName instead of the literal. I get 0 entries in my TradeCollection. However, if I use

    currentTrades = Performance.AllTrades
    foreach(Trade t in currentTrades)
    {
    if (t.Entry.Name == o.Name)
    {
    lastProfit = t.ProfitCurrency * t.Quantity;
    totalProfit += lastProfit;
    Print("ShortTrade P&L " + lastProfit.ToString("##,###.00"));
    }
    }

    I get exactly what I expect. I prefer the GetTrades() approach as this trade list can get quite large by the end of the day.

    Can anyone point out what is wrong with my GetTrades() statement?

    Thanks in advance.

    Scott

    #2
    Scott,

    The GetTrades() approach uses the entry signal's name. A trade is a pair of an entry and an exit. You will need to pass in the name of the entry order and not the exit order for it to find it.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh, thanks for getting back to me so quickly. o.Name is the name of the entry order. Can you think what else the issue might be?

      Scott

      Comment


        #4
        Scott,

        Unfortunately I would not know without seeing complete code and seeing exact output. Were there any errors in Control Center logs?
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          No errors but I understand about seeing the code. Rather than go through all that, am I correct in using the signalName from the SubmitOrder method and does my syntax look correct? I am using the unmanaged approach if that matters.

          Once those questions are cleared up, I am good to go.

          Thanks

          Comment


            #6
            Syntax looks fine; you are correct in submitting it as the entry signal name (you could just try typing a string directly like "someSignalName" to see what happens); don't think unmanaged should matter.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            88 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            48 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            30 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            34 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            68 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X