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 sidlercom80, 10-28-2023, 08:49 AM
            168 responses
            2,262 views
            0 likes
            Last Post sidlercom80  
            Started by Barry Milan, Yesterday, 10:35 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by WeyldFalcon, 12-10-2020, 06:48 PM
            14 responses
            1,429 views
            0 likes
            Last Post Handclap0241  
            Started by DJ888, 04-16-2024, 06:09 PM
            2 responses
            9 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            41 views
            0 likes
            Last Post jeronymite  
            Working...
            X