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

trade lifecycle analysis - log file

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

    trade lifecycle analysis - log file

    NT Support,

    Could you please provide some advice?

    I’m struggling to understand the data / object architecture between Positions and Trades. I would like to map between the two, but I’m not sure I understand the structure here.

    The objective I’m trying to achieve is this;

    I’m looking to build a log file which details the lifecycle of a trade. I’ve attached a sample file which is a single instrument strategy. As each bar is processed within a trade a line is added to a log file which details the PnL at each bar. I’m trying to build a file which replicates Striasman’s bar by bar analysis of the trades recommended in this book: http://www.amazon.co.uk/Tradings-Sys...4349297&sr=8-1 (see Chapter 9 – pp 143 – 165).

    Given that I’ve looking at a multi-instrument system I need a method for tracking the Trades and Positions – and logging their relationships. I.e. if a trade is open but not closed it is only listed in the Positions connection and not in the Performance.AllTrades collection. What is the relationship between Trades and Positions and is there any other documentation on that data architecture?

    Thanks and regards,

    drolles

    #2
    Hi drolles,

    Correct, that's the general usage. Position refers to open trades, and is not included in Performance results until it is closed. Documentation for these is available here:

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan,

      Thanks for that.

      I’m aware of the documentation in the standard help file. My question was more if there is anything additional?

      Secondly, I was looking for more explaination of the linkage and data architecture here. Can you (or someone) please elaborate on the Trade / Performance / Order architecture and the linking of these events and objects?

      Thanks and regards,

      Dan

      Comment


        #4
        Unfortunately we don't have additional documentation beyond what is in the help guide. Trade Performance is expanded upon in the reference samples if you are looking for usage help. If you run into any issue using these, please let us know and we can look into.
        Last edited by NinjaTrader_RyanM1; 05-02-2011, 04:55 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Ryan,

          Thanks for the reply.

          As you are obviously unwilling or unable to answer the question, can you please escalate it that is able and willing?

          Thanks and regards,

          drolles

          Comment


            #6
            drolles,

            Open positions are tracked by Position.GetProfitLoss() and completed trades will have their performance stored in Performance.AllTrades.TradesPerformance.

            Orders are placed, as orders get filled you get execution events, as executions open positions the position object gets updated, as exit orders get filled the positions get closed out, as the positions close out the Trade objects then contain their performance stored in the TradeCollections objects.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh,

              Thanks for the reply and helping Ryan.

              Thanks for reiterating the chain of events.

              I’m wondering is there any data element which can track through those events – i.e. link an entry order to a position to a trade?

              After inspecting the objects within Visual Studio the data relationship I can’t appear to connect is Positions to Trades. I would expect some sort of data link and I can’t seem to find one.

              Thanks and regards,

              drolles

              Comment


                #8
                drolles,

                No, there is no "link" between a specific trade and a specific position. You know which is which because of the IOrder on the IExecution that just took place which will be followed by the update of IPosition.

                There is no one to one relationship between trade and position objects. You can have 20 trades and still only one position.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Josh,

                  Thanks for your reply.

                  Ok, there isn’t a one to one relationship. Do you think there should be a data relationship between trades and positions?

                  Kind regards,

                  drolles

                  Comment


                    #10
                    No, because positions, as a concept, is on a per instrument basis, not a per trade basis. You don't have a position for every single trade you make on AAPL. You have a single position of AAPL and another position in MSFT no matter how many trades you placed on AAPL or MSFT.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Josh,

                      Thanks for your reply.

                      Interesting view, it is helping me to understand the logic of the design.

                      Possibly my confusion is in the definition of Position.

                      If I have a trade to open long on AAPL don’t I have a Position (by your definition)?

                      Thanks and regards,

                      drolles

                      Comment


                        #12
                        drolles,

                        You place a trade to open long AAPL = you update your AAPL position. If this is your first trade on AAPL then you get a new position. If you already had a position prior to the long trade, all it does is update the preexisting position. Position updates could be in the form of adding to the position, decreasing the position size, or even closing the position.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Josh,

                          Thanks again for your reply.

                          If I read your logic correctly, there is a relationship between Trades and Positions then? I.e. you place a trade to open a position against a instrument. Even part of the NT architecture agrees with this, one can transverse the Performance object to get a TradeCollection giving Entry and Exit Trades.

                          Have I missed something?

                          Thanks and regards,

                          drolles

                          Comment


                            #14
                            drolles,

                            There are Order objects, Execution objects, Position objects, and Trade objects. The only way to get positions is to place orders. The only way to close positions is also to place orders. The orders placed would obviously need to be filled for you to get executions and those executions will in turn be what updates the positions from. When you have a paired set of executions to enter and exit the market (a.k.a. position) that makes a Trade.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Josh,

                              Thanks for your reply.

                              I couldn’t agree more with your logic. So there is a relationship between all those elements when?

                              Thanks and regards,

                              drolles

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by traderqz, Yesterday, 09:06 AM
                              2 responses
                              15 views
                              0 likes
                              Last Post traderqz  
                              Started by traderqz, Today, 12:06 AM
                              3 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by RideMe, 04-07-2024, 04:54 PM
                              5 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by f.saeidi, Today, 08:13 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by DavidHP, Today, 07:56 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Working...
                              X