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

Programmatic Access to Instruments Database

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

    Programmatic Access to Instruments Database

    I'm running NinjaTrader version 8.0.21.1 64-bit, and I'd like to programmatically read-from and write-to my local instrument database. I'd like to know if it's possible to do this, either internally to NT8 using NinjaScript, or externally to NT8 using Python/C#/VBA? If it is possible, then I'd appreciate any guidance you might provide for how to do it. Thank you.

    #2
    Hello NtFan,

    That really depends on what your local database format is, NinjaScript is just C# programming language so you could use any C# means to interface with external data. You can also reference libraries if needed in case you are using a database or something that requires an actual library to use.

    I would suggest to first review what you need to access the data and then search online for C# examples for that. For example if your database was a csv file you could search for "C# read csv file" to get some examples which would apply in NinjaScript.

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

    Comment


      #3
      Hi Jesse,

      The "local database" that I want to read-from and write-to is the NinjaTrader instrument database that is installed on my local computer. With regard to this database, here are two things I'd like to do:

      1a. Using NinjaScript, I'd like to read from it to check if an instrument having a specific name (i.e. ticker) exists; and
      1b. Ditto, but using Python/C#/VBA.

      And, here are two more things I'd like to do:

      2a. Using NinjaScript, I'd like to write to it to add an instrument that doesn't exist; and
      2b. Ditto, but using Python/C#/VBA.

      Are any/all of these four things possible? If yes, then I'd appreciate any guidance you might provide regarding how to do them.

      Thank you,

      NtFan

      Comment


        #4
        Hello NtFan,

        There is no suggestion I can make for accessing the NT databases directly, you could look up an instrument in NinjaScript using the method to do that but I could not advise for any external use case outside of NinjaScript. In general the database files and other data files NinjaTrader stores are not accessible from outside the platform.


        Creating instruments from NinjaScript is also very limited, technically you can try to Instrument.GetInstrument("name", true) and it will add a default stock type instrument but there is no supported way to modify/add instruments in the database through code. It is only suggested to manually define instruments so that you can ensure the configuration is correct before you try to use it.


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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        18 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        9 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        10 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X