Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Export directly into excel

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

    Export directly into excel

    Do you have anything that can export the trade performance data directly into excel? I just want to click export and excel opens up with all the data already populated and I can just crack on with doing what I need to instead of messing around with the whole importing routine.

    Or if you have sample code that shows how to extract the data I need, I can do the excel part.

    Thank you.

    #2
    I use StreamWriter to write to .CSV files, which I then open directly in Excel. No import necessary.

    Comment


      #3
      Hello GrantX,

      For Performance grids, basically any "Grid" you see within the platform you can Right click -> Export. This would create an Excel sheet of the grid that was right clicked.

      For an automated way to export results, you can use the code as well using tools like the SampleStreamWriter example we have:


      or also using more advanced approaches like the ones mentioned here http://ninjatrader.com/support/forum...407#post212407

      If you would be using code to do this, you cannot directly export a grid but would need to either access the values needed if possible or calculate the value yourself if it is not available for access. You can access account performance values using the following information: http://ninjatrader.com/support/helpG...erformance.htm



      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Originally posted by tradesmart View Post
        I use StreamWriter to write to .CSV files, which I then open directly in Excel. No import necessary.
        What do you connect to in order to retrieve the data? I want to pull specific metrics out, pre-format it and then send it directly to an excel file. The problem is currently when I open the CSV, all the columns are configured as text so I have to go through and change everything to numbers. On top of that, if there is a $ sign anywhere, excel makes life very difficult.

        Comment


          #5
          In the indicator's code, I configure the string to be exported with commas separating the values using string.Format(), for example:
          Code:
          PrintToFile(false, @"bin\Custom\", cs_exportfilename, "CSV", 
                                  string.Format("{0},{1},{2},{3},{4}",
                                  Time[0].ToString("HH:mm"),
                                  Time[0].ToString("MM/dd/yy"),
                                  Instrument.MasterInstrument.Name,
                                  Volume[0],
                                  High[0] - Low[0]));

          Comment


            #6
            Originally posted by Grantx View Post
            What do you connect to in order to retrieve the data? I want to pull specific metrics out, pre-format it and then send it directly to an excel file. The problem is currently when I open the CSV, all the columns are configured as text so I have to go through and change everything to numbers. On top of that, if there is a $ sign anywhere, excel makes life very difficult.
            Which version of excel are you using?

            You could write a macro.

            I only remember one issue a while ago with export to excel that was fixed. I've been using excel 2016,and some open office on other machines.

            Comment


              #7
              Originally posted by tradesmart View Post
              In the indicator's code, I configure the string to be exported with commas separating the values using string.Format(), for example:
              Code:
              PrintToFile(false, @"bin\Custom\", cs_exportfilename, "CSV", 
                                      string.Format("{0},{1},{2},{3},{4}",
                                      Time[0].ToString("HH:mm"),
                                      Time[0].ToString("MM/dd/yy"),
                                      Instrument.MasterInstrument.Name,
                                      Volume[0],
                                      High[0] - Low[0]));
              Thank you! Ill look a bit further into that. How do you handle the Dollar sign though?

              Comment


                #8
                Originally posted by sledge View Post
                Which version of excel are you using?

                You could write a macro.

                I only remember one issue a while ago with export to excel that was fixed. I've been using excel 2016,and some open office on other machines.
                Excel 2007 ... I know, I should upgrade.

                Comment


                  #9
                  Originally posted by Grantx View Post
                  Thank you! Ill look a bit further into that. How do you handle the Dollar sign though?
                  In this article, learn to use standard numeric format strings to format common numeric types into text representations in .NET.


                  You can format the strings any way you like by using appropriate ToString() formats, such as d_price.ToString("F3") that would return the string 2052.500 if d_price = 2052.5.

                  For price formatting to tick size, you could use Bars.Instrument.MasterInstrument.FormatPrice(d_pri ce)

                  If you want dollar signs (I realize that you do not, but if you did) you could use d_price.ToString("C").

                  Comment


                    #10
                    Originally posted by tradesmart View Post
                    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

                    You can format the strings any way you like by using appropriate ToString() formats, such as d_price.ToString("F3") that would return the string 2052.500 if d_price = 2052.5.

                    For price formatting to tick size, you could use Bars.Instrument.MasterInstrument.FormatPrice(d_pri ce)

                    If you want dollar signs (I realize that you do not, but if you did) you could use d_price.ToString("C").
                    Thanks for all your help tradesmart.

                    Comment


                      #11
                      Originally posted by Grantx View Post
                      Do you have anything that can export the trade performance data directly into excel? I just want to click export and excel opens up with all the data already populated and I can just crack on with doing what I need to instead of messing around with the whole importing routine.

                      Or if you have sample code that shows how to extract the data I need, I can do the excel part.
                      I see that the difference between NT7 and NT8 export to Excel is the addition of those pesky $ symbols, which were not included in NT7.

                      What I do with the export file is copy and then paste special into another Excel workbook, which is where I do my analysis. So, for me, the exported file is merely a source to be copied. The dollar signs are eliminated automatically thereby.

                      Here's a little Excel 2007 subroutine that does the copying:
                      Code:
                      Sub PasteFromClipboard()
                      On Error Resume Next
                      ' Keyboard Shortcut: Ctrl+v
                      
                      ' Paste Special Unicode Text from output window or text file
                      ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, DisplayAsIcon:=False
                      ' Paste Special Values from another spreadsheet
                      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                      
                      End Sub

                      NT Staff: Please eliminate currency symbols in the trade performance export facility.

                      Comment


                        #12
                        Originally posted by tradesmart View Post

                        What I do with the export file is copy and then paste special into another Excel workbook, which is where I do my analysis. So, for me, the exported file is merely a source to be copied. The dollar signs are eliminated automatically thereby.
                        I have tried exactly that but the $ remains!
                        I have to use =VALUE(SUBSTITUTE(I7,"$","",1)) just to get rid it.
                        Im not sure how to implement your code sample.

                        Comment


                          #13
                          Make sure you export to a CSV file, not an Excel file. Then Paste Values into your analysis spreadsheet. All strings that look like numbers or dates will be converted to numbers as shown in the attached screenshot.
                          Attached Files

                          Comment


                            #14
                            In NT7 it was such an easy thing. I just had to click ctrl + M and the data was exported to excel. Now I have to click on Export and select the file, etc...

                            When you have to export many grids is annoying.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by BarzTrading, Today, 07:25 AM
                            2 responses
                            26 views
                            1 like
                            Last Post BarzTrading  
                            Started by devatechnologies, 04-14-2024, 02:58 PM
                            3 responses
                            20 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by tkaboris, Today, 08:01 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post tkaboris  
                            Started by EB Worx, 04-04-2023, 02:34 AM
                            7 responses
                            163 views
                            0 likes
                            Last Post VFI26
                            by VFI26
                             
                            Started by Mizzouman1, Today, 07:35 AM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Working...
                            X