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

Performance.AllTrades. class

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

    Performance.AllTrades. class

    Is there any reference as to the options available for the Performance.AllTrades. class?? I'm interested in how to calculate the "Realized" and "Unrealized" that shows on the strategy tab..
    I do have the samplePNL script which has good stuff, but cant seem to calculate the above mentioned.
    i also checked lot http://www.ninjatrader-support.com/H...ollectionClass but kinda slim on whats available
    Last edited by gg80108; 04-21-2009, 11:55 AM.

    #2
    Trades class shows you end of trade results where you can aggregate to get Realized PnL. http://www.ninjatrader-support.com/H...nceValuesClass

    For Unrealized PnL you need to use this: http://www.ninjatrader-support.com/H...?GetProfitLoss
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Is there anyway to get Unrealized PnL intrabar? I'm running it " Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) " in "OnMarketData" with a Print and it doesn appear to be updating until endofbar. Thx.

      Comment


        #4
        BradB,

        If you run your strategy CalculateOnBarClose = false you should get it updated every single tick.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Yeah Josh, that's what I'm doing now. I didn't want my order routing firing off orders every new tick update, but I got around that. Sorry for not explaining myself very well.

          Thx.

          Comment


            #6
            Ok, I guess I'm back to the original question. If I use CalculateOnBarClose = false it throws of my evaluation criteria, such as a CCI zero corss that may happen numerous times intrabar. It appears I need to run this Strategy with CalculateOnBarClose = true.

            That being the case, is there a way I can the Unrealized PnL intrabar? Shouldn't it work by putting it in "OnMarketData"?

            Comment


              #7
              No, GetProfitLoss() is calculated based off of Close[0]. If you are only updating at the end of each bar, well, Close[0] is only updated once and as such GetProfitLoss() updates once.

              Run with CalculateOnBarClose = false and then just filter parts of your code to calculate once at the end of the bar.

              Code:
              if (FirstTickOfBar)
              {
                   // Do something at the end of the bar. All bar referencing needs to be indexed back one so [0] would now be [1]. FirstTickOfBar is the same event as the closing of the prior bar.
              }
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by zstheorist, Today, 07:52 PM
              0 responses
              5 views
              0 likes
              Last Post zstheorist  
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              150 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              6 views
              0 likes
              Last Post mattbsea  
              Started by RideMe, 04-07-2024, 04:54 PM
              6 responses
              33 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Started by tkaboris, Today, 05:13 PM
              0 responses
              6 views
              0 likes
              Last Post tkaboris  
              Working...
              X