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

Excel to NT8 interface possibilities

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

    Excel to NT8 interface possibilities

    I built my ES day trading execution platform using Excel VBA and Tradestation Chart Trading/Easy Language. I'd like to understand options for porting this to NT8, or perhaps it's not feasible.

    All I really need is the ability from NT8 to read and write to Excel to read order prices and write fills, times, new prices if an order is moved. I've seen there's no readily available Excel library.

    Excel has a lot to add to NT8 with just a simple ReadCell(R,C), WriteCell(R,C) kind of simple API, which has added a lot to TradeStation for me with little programming cost. Excel cannot initiate contact with TS but I'm fine without that. I can see that would be more complicated.

    Has anyone done something like this?

    #2
    I did find this thread for some NT unsupported code:

    Updated to: https://ninjatraderecosystem.com/use...wnload/excel8/

    showing use of:
    excelSheet.Cells[rowCount,1] = ToDay(Time[0]);
    and:
    double example = double.Parse((excelSheet.Cells[rowCount, 6] as Excel.Range).Value.ToString());

    How useable is this? NinjaTrader_JessicaP​ has left Ninja Trader's employ! NinjaTrader_Kate​ gave it a glowing review... "I have this installed and can confirm it should work for you." :-)

    Is this state-of-the-art Ninja level stuff?

    I'm expecting to read/write some 5-10 values periodically... 10 seconds to 10 minutes between read/writes. Easy stuff.

    Comment


      #3
      Yes, you can read/write from Excel using normal C# programming techniques. Google how to read/write Excel from C# and whatever works there should work in NinjaTrader.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        The simplest way to read/write a file for use in Excel is to treat it as a .csv file; i.e. a simple text file. With a well-defined structure, it will work well. It does not give you all the bells and whistles in the file, so if you need a truly Excel file that is not csv, you'll need to use the suggested ways above. But even then, if you have an "analysis" file (.xlsx) that has the same structure for the data, but with all the bells and whistles built-in, it's not too tedious to simply copy/paste from .csv to corresponding .xlsx locations when needed. ... Whatever works best for you though.

        Thanks.
        Multi-Dimensional Managed Trading
        jeronymite
        NinjaTrader Ecosystem Vendor - Mizpah Software

        Comment


          #5
          Welcome to the forums!

          I use and highly recommend EPPlus.

          The last free version 4.5.3.3 should work fine for your needs.

          Comment


            #6
            Hello TurtleInTheSky,

            Thanks for your posts.

            Having a custom NinjaScript read and write values to Excel would require the use of unsupported code. This goes beyond the level of support we would be able to assist you with from the Support department at NinjaTrader.

            This forum thread will be open for Forum community members to share their insights on possible unsupported code to accomplish this.

            You may also find this script from the Ecosystem User App Share to be helpful: https://ninjatraderecosystem.com/use...wnload/excel8/


            The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Oh, and I'm assuming the source code the NT chart trading is available.

              In TradeStation, their chart trading was a 28,000 lines of pretty good code to learn easy language and how to do useful stuff to my kind of trading (nothing algorithmic).

              Comment


                #8
                Hello TurtleInTheSky,

                Thanks for your note.

                Are you asking if specifically NinjaTrader's Chart Trader feature's source code is open-source or closed-source?

                NinjaTrader's Chart Trader feature source code is closed source and cannot be viewed.

                The supported NinjaScript code could be found in the NinjaTrader help guide.

                Language Referece: https://ninjatrader.com/support/help...erence_wip.htm

                Educational Resources: https://ninjatrader.com/support/help..._resources.htm
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_BrandonH View Post
                  Hello TurtleInTheSky,

                  Are you asking if specifically NinjaTrader's Chart Trader feature's source code is open-source or closed-source?
                  Yes.Well, if I have to start from scratch from the language reference manual, that's a deal breaker I think. Also, it really looks like tradestation based their Excel library on the same Microsoft.Office.Interop.Excel library. It works but has bugs and stability, robustness is poor. I suspect it would be the same on NT and I'm on my own trying to creating something with it.

                  Originally posted by NinjaTrader_BrandonH View Post
                  The supported NinjaScript code could be found in the NinjaTrader help guide.
                  "Supported" mean closed source NinjaScript included in the license level? Is anything open source?



                  Comment


                    #10
                    Hello TurtleInTheSky,

                    Thanks for your notes.

                    NinjaTrader utilizes the C# programming language for developing indicators and strategies.

                    Supported code refers to code that is in the NinjaTrader 8 help guide that we would be able to provide you support with, such as if you have questions about certain NinjaScript methods or functions.

                    No closed-source NinjaScript code is publicly available to view and our Support team cannot view closed-source scripts either.

                    You could use unsupported code in your script but our Support department would not be able to assist you with using the unsupported code. It would be up to your discretion to use unsupported code in your custom NinjaScript.

                    Open source code can be viewed in the NinjaScript Editor to see examples of creating say NinjaScript indicators, strategies, drawing tools, etc.

                    We also have reference samples on the help guide listed here: https://ninjatrader.com/support/help...ce_samples.htm

                    Note that using Microsoft.Office.Interop.Excel would go beyond the support we would be able to provide you with. Other NinjaTrader Forum community members may share their insights on how to use this in a custom NinjaScript. Or, you could do some research on how this could be used, such as by doing a Google search for something like 'How to use Microsoft.Office.Interop.Excel C#'.

                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you for the quick replies with details. That's helpful to a point. I'm quite familiar with what you're talking about generally. Basically, you're guaranteeing the language works as documented and not that my code will work like I intended! Buying a dictionary does not mean you'll win a Pulitzer prize for your words, :-)

                      Easy language gets difficult because details fairly often are not clarified by documentation or examples. You just have to try things and find out, even with simple constructs, let alone dealing with the order, quote and position server objects. Examples of well written, robust code are very helpful.

                      Is there a bigger , "robust" example of NinjaScript using say the OrderUpdate, PositionUpdate and other methods to create say an OSO order, track fills and position to completion (back to zero position)? More than:





                      Details emerge like, in TradeStation, the position provider is not synchronized to the order status provider so for example, when you get an update event for an order fill, you cannot query the position provider for an up to date position. It may have changed the position already or not. Of course, it will, "quickly", in milliseconds, but your coding must know these details.

                      Robust means, for example, a network disconnect/reconnect is handled correctly. Do order events get "replayed"? Does your code check and handle network status changes correctly?

                      20 issues like this and your development project will take months to learn from scratch. An example, well, saves a ton of forum questions.

                      Comment


                        #12
                        Hello TurtleInTheSky,

                        By OCO are you referring to OCO (One-Cancels-Others)?

                        Below is a link to an example named ProfitChaseStopTrailUnmanagedExample_NT8 that uses OCO for exit orders.


                        As well as another example for entries.


                        As far as disconnections, this will cause the strategy to become disabled. Once re-enabled, the strategy will reprocess historical data and recalculate the position.


                        With a connection loss, this will attempted to be resumed. There is connection loss handling for the number of reconnection attempts allowed before the strategy is disabled.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Yes, One-Cancels-Others.

                          What does "unlock a strategy" refer to? It sounds like the Ninjascript environment has locks hiding how objects work preventing modifications.

                          Comment


                            #14
                            Unlocking a strategy means you made it with Strategy Builder, but you want to "unlock" it so you can edit its code directly instead of just using the helper app Strategy Builder to edit it.
                            Bruce DeVault
                            QuantKey Trading Vendor Services
                            NinjaTrader Ecosystem Vendor - QuantKey

                            Comment


                              #15
                              Hello TurtleInTheSky,

                              Thanks for your note.

                              As stated by QuantKey_Bruce, a strategy made in the Strategy Builder is considered a locked script since it is locked to the Strategy Builder and must be edited by using the Strategy Builder. An unlocked script refers to a script that is not locked to the Strategy Builder and this script can be manually modified in the NinjaScript Editor window.

                              To unlock a script in the Strategy Builder you could click the 'Unlock code' button.

                              Let me know if I may assist further on this.
                              Brandon H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pibrew, Today, 06:37 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post pibrew
                              by pibrew
                               
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              14 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              11 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              16 views
                              0 likes
                              Last Post AaronKoRn  
                              Working...
                              X