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

writing all Trades to a file

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

    writing all Trades to a file

    Hi,

    I need to export all the trades with date/time, entry price and exit price to a file

    I'm looking at the TradeCollection and it would be simple if I can just get hold of it at the end of the backtest and loop over it then. Is there an Event that I could use?

    Alternatively, what Event would be best suited ? onExecution? Presumably I'd have to keep a tally of which trade I'd printed so that it doesn't get printed on the Entry and the Exit.

    Thanks

    #2
    adamus, there's unfortunately no event for the backtest ending - do you need this programmatically via code?

    If not you could just export via right clicking on the performance data tabs in the Strategy Analyzer and then use our 'Export to Excel' feature.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      You just made me realise - I only want to do it during a walk-forward.

      There are about 500 walk-forwards in the batch, so it would take days to export it manually from the trades tab.

      However, when the walk-forward optimisation is running, I don't want the trades to be output when the run is only optimising - the trades must be from the walk-forward with the chosen parameters. I'm not interested in details from all the optimisations and it would probably slow NT down a lot too if every optimisation run wrote the trades.

      Is there a performance class or similiar that I can refer to in the code to tell if this is the walk-forward?

      Comment


        #4
        adamus, thanks for clarifying, but unfortunately you can't check the Performance class for the individual walk forward results.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand,

          I'm using NT7 b16.

          I just googled and found Dispose() which looks promising. When does that get triggered?

          Comment


            #6
            adamus, this method could be used in 6.5 to release custom resources you've used in your code (by overriding it), for NT 7 this should be done in OnTermination() then.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              adamus, thanks for clarifying, but unfortunately you can't check the Performance class for the individual walk forward results.
              Bertrand,

              is there really no way of knowing if the system is being backtested or traded live?

              I also see that the variables in the strategy are reset between optimization runs, so I can't store any info from one run to the next during the batch.

              I'll have to write the data to a file and check it each time to see whether it's optimizing or walking forwards.

              Any advice would be appreciated!

              Thanks

              Comment


                #8
                There is no variable to tell if you are in the Strategy Analyzer backtesting or if you are on a live chart.

                The only thing available is if you want to distinguish between historical bars and real-time bars. That is done through "if (Historical)".
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  There is no variable to tell if you are in the Strategy Analyzer backtesting or if you are on a live chart.
                  You mean between 'backtesting or walk-forwards'?

                  Is there an API documentation for StrategyBase? For instance, it'd be interesting to know what BackTestMode is for.

                  Thanks

                  Comment


                    #10
                    Hi adamus, unfortunately not, as this is not supported NinjaScript.

                    For the 'Historical' properly Josh mentioned you can review this info -

                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      So you can't tell me anything about

                      Code:
                      if (base.BackTestMode == BackTestMode.WalkForward)
                      {
                             // do stuff....
                      }

                      Comment


                        #12
                        Unfortunately not adamus, as this territory is non documented and outside of our supported scope.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          The whole of NT7 beta is virtually undocumented as far as I can tell at the moment.

                          Would you be able to ask the NT7 developers if this is something that is intended for support at some stage, and at least whether this does "what it says on the tin"? i.e. it is what it looks like. My testing backs it up but I am currently running long batches of walk-forwards and I'd hate to find out I'd started mixing up the trade data I'm writing out to file.

                          Thanks

                          Comment


                            #14
                            adamus,

                            This is as Bertrand has mentioned outside the scope of what we can support. What is supported in terms of NinjaScript is already documented. Working outside of those bounds can be done on your own, but we unfortunately will not be able to offer you any guidance in those regions.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Josh,

                              just looking at this again and I want to point out that the index tab in the NinjaTrader help app is empty except one entry: "Indicators".

                              Is this a problem with my installation or is it like this for you as well? It needs to be indexed before it's packaged for deployment, right?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by giulyko00, Today, 11:49 AM
                              2 responses
                              11 views
                              0 likes
                              Last Post giulyko00  
                              Started by Aviram Y, Today, 06:03 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post Aviram Y  
                              Started by FishTrade, Today, 03:42 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post FishTrade  
                              Started by Richozzy38, Today, 01:06 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post Richozzy38  
                              Started by ttrader23, Today, 09:04 AM
                              2 responses
                              12 views
                              0 likes
                              Last Post ttrader23  
                              Working...
                              X