Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Last trade winner/loser

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

    Last trade winner/loser

    Hi,

    Having difficulty trying to understand how i could do this. Nothing seems to be working. Not relling following the trades /performance parts.

    I'm sure this has been done 1000 times before. Can someone please help?

    Just want to know if last trade was win or loss

    Thanks

    #2
    Hello,

    Not sure if you've had a chance to take a look at this post but it should help you with tracking trade performance: http://www.ninjatrader.com/support/f...ead.php?t=4084

    Specifically: http://www.ninjatrader.com/support/h...ningtrades.htm

    Let me know if I can be of further assistance.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Hi Lance,

      Have already looked at those sections, but not seeing it.

      Cheers anyway

      Comment


        #4
        Hello,

        You would use something similar to the code here: http://www.ninjatrader.com/support/h...ningtrades.htm

        Code:
            // Accesses the last winning trade in the strategy (oldest trade is at index 0)
               if (Performance.AllTrades.WinningTrades.Count > 1)
              {
                   Trade lastTrade = Performance.AllTrades.WinningTrades[Performance.AllTrades.Count - 1];
         
          
                //Instead of printing the value out like here you could check to see if > 0
                  Print("The last winning trade's profit was " + lastTrade.ProfitCurrency);
              }
        LanceNinjaTrader Customer Service

        Comment


          #5
          Thanks Lance,

          Still dont get that one, well it didn't work out how i wanted anyway. Might come back to it later, but for now i've just used

          if ((Performance.AllTrades.Count ==0)
          || (Performance.AllTrades.Count >=
          1) && BarsSinceExit(0,"",0) >5)

          As a primary decider if to enter a trade. Wanted to prevent re-entry again and again, and this covers it. Not getting genuine re-entries i want inside 5 bars after wins so it works fine.

          Cheers

          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