Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 jackiegils, Yesterday, 11:05 PM
          0 responses
          5 views
          0 likes
          Last Post jackiegils  
          Started by cre8able, 05-09-2024, 09:15 PM
          2 responses
          17 views
          0 likes
          Last Post cre8able  
          Started by Trader146, Yesterday, 09:17 PM
          0 responses
          9 views
          0 likes
          Last Post Trader146  
          Started by ttrader23, 05-08-2024, 09:04 AM
          9 responses
          43 views
          0 likes
          Last Post ttrader23  
          Started by ZeroKuhl, 05-09-2024, 04:31 PM
          8 responses
          46 views
          0 likes
          Last Post ZeroKuhl  
          Working...
          X