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

need Performance.SessionTrades

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

    need Performance.SessionTrades

    Why isn't there a Performance.SessionTrades object? You've got All, Real, Long, Short, but it would sure help if you tracked one just for the current Session that automatically reset at the FirstBarOfSession.

    How do I make one?

    I need the count of trades since the beginning of the session, and the Performance data: profit, etc.

    #2
    LostTrader, you would need to check the profit/loss value at the beginning of every session and then you can subtract that amount from the entire profit/loss value to get each individual session's p/l. Please take a look at the reference sample that tracks session profit and loss for money management purposes to get an idea of how to accomplish this - http://www.ninjatrader.com/support/f...ead.php?t=4084.
    AustinNinjaTrader Customer Service

    Comment


      #3
      I've seen that sample, Austin. Simply put, it seems a tad clumsy, and is VERY incomplete.
      It would be simple for y'all to make this. Meanwhile I will try something else.

      Please add a TradeCollection object for SessionTrades to your future enhancements.
      Thank you.

      Comment


        #4
        Originally posted by Lost Trader View Post
        I've seen that sample, Austin. Simply put, it seems a tad clumsy, and is VERY incomplete.
        It would be simple for y'all to make this. Meanwhile I will try something else.

        Please add a TradeCollection object for SessionTrades to your future enhancements.
        Thank you.
        You could always write a function/method to handle this, but I do agree that having it as a property or method of the Performance object would be a whole lot nicer.

        May I add my voice to the feature request?

        Comment


          #5
          when is existing TradeCollection updated?

          Yea, I am trying to write one using the existing structure.

          I need to know when the existing TradeCollection (AllTrades) is updated with the last trade.
          Is it OnExecution(), OnPositionUpdate(),what? When can the last Trade object in the TradeCollection be guaranteed to be the one just closed?

          As long as TradeCollection is akin to C# collections (i.e., Add() and Clear() are TradeCollection methods) then a private TradeCollection can add the last trade from AllTrades and clear itself at every start of Session.

          Comment


            #6
            Checking with development. Will get back to you.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              It will come after OnPositionUpdate().
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Josh View Post
                It will come after OnPositionUpdate().
                AFTER?

                Which On Event method can be used to know that a trade has been added to the Collection and that the statistics are now valid?

                Comment


                  #9
                  Lost Trader, yes, after OnPositionUpdate(), the trade performance collection will be 100% updated and valid.

                  You could make a call to your custom function at the very end of OnPositionUpdate() to get this data.
                  AustinNinjaTrader Customer Service

                  Comment


                    #10
                    Austin,
                    does this specifically mean during OnPositionUpdate() when (Position.MarketPosition == MarketPosition.Flat) ? That does sound more realistic than after.

                    More important, are there any other times or condition checks for when a trade is added to the Collection?

                    Can a position have multiple trades? and if so, MarketPosition.Flat would be an incomplete check. What else should be checked?

                    Comment


                      #11
                      Hello,

                      It would be after OnPositionUpdate() runs that everythings good to go. Can't guarentee anything during OnPositionUpdate() this is why we say after.

                      Also, if you need to track this more advanced then long/short/flat you can check the QTY. If this works for your method if it doesn't then you will need to use ATM Strategies. Or track the positions yourself with your own code. Let me know if you need more information on ATM Strategies and I can supply.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by FrancisMorro, Today, 03:24 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post FrancisMorro  
                      Started by Segwin, 05-07-2018, 02:15 PM
                      10 responses
                      1,770 views
                      0 likes
                      Last Post Leafcutter  
                      Started by Rapine Heihei, 04-23-2024, 07:51 PM
                      2 responses
                      31 views
                      0 likes
                      Last Post Max238
                      by Max238
                       
                      Started by Shansen, 08-30-2019, 10:18 PM
                      24 responses
                      944 views
                      0 likes
                      Last Post spwizard  
                      Started by Max238, Today, 01:28 AM
                      0 responses
                      11 views
                      0 likes
                      Last Post Max238
                      by Max238
                       
                      Working...
                      X