Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Connecting to NT8 from python

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

    Connecting to NT8 from python

    Hello,
    I've got an interface between python 2.7 and NinjaTrader 8 using the "NTDirect.DLL" approach.

    For the most part things are working, like, I can submit orders from the python code, and they get executed right away in NT8.

    However, for calls that return data, sometimes I don't get anything meaningful. For example, the Orders() and OrderStatus() calls in the DLL file return a same 8 or 9 digit number. Its always the same number, no matter if there are open positions, or not, and no matter how many there are.

    I know that NinjaTrader does not provide support for using this interface, but I was wondering if anyone here in the forum had any experience that they could pass along?

    A second question is when I use the CloseStrategy() call, it takes a LOONG time for the position to be closed and the ATM limit orders to be removed from the books... while all this time is passing the value of the position i wanted to exit can move all over the place. Anyone know why that happens? Am I using it for the wrong things? For the time being I am resorting to FlattenEverything(), or ClosePosition() which seem to work.

    Thanks!

    #2
    Hello Stephen,
    Thanks for your post and welcome to the NinjaTrader forum.

    I do not have any advice but I am very interested in what you are doing with Python code.

    As far as the length of time it should take to close a position with CloseStrategy() -- is this still within the context of using Python? Are you overriding this method?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,
      The python code gets market and indicators data from eSignal, monitors them, and if it sees a good setup, sends a buy/sell order to Ninja Trader to execute.

      Yes, the CloseStrategy() is called from the python code.

      Comment


        #4
        Hi ... I'm very interested in Python connecting to the NinjaTrader DLL ... do you have code on Github or are you otherwise interested in sharing it?

        Please advise! Thanks.

        Comment


          #5
          Hello PrecisionGuy,

          Thank you for your post.

          I'd recommend trying to PM the original poster of the thread if you don't get a response here.

          I do have a little information I can pass on regarding the DLL interface. The DLL interface is provided as-is and support is limited to the resources available below:

          DLL interface - https://ninjatrader.com/support/help.../functions.htm

          Example application (Unsupported example) - https://ninjatrader.com/support/foru...442#post514442

          Please let us know if we may be of further assistance to you.

          Comment


            #6
            I tried to load NtDirect.dll in Python, using pythonnet, but got an error. See below. I tried both x86 and x64 version of the dlls, using corresponding version of Python intepreters.
            Did anyone have success on this?

            Code:
            [FONT=courier new]pip install pythonnet
            
            import clr
            clr.AddReference('NtDirect')[/FONT]
            Error: System.IO.FileNotFoundException: Unable to find assembly 'NtDirect.dll'.
            at Python.Runtime.CLRModule.AddReference(String name)

            Comment


              #7
              Hello yubo27,

              Thank you for your post.

              This would be unsupported, so unfortunately I'm not able to give any advice. Perhaps another forum user may be able to shed light on this issue - you may want to try private messaging the original poster.

              Please let us know if we may be of assistance to you.

              Comment


                #8
                Hey All,

                Looking for people to test a new bridge connector between python and ninjatrader8, let me know if you can run a test.

                Thanks!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                88 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                48 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                31 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                34 views
                0 likes
                Last Post TheRealMorford  
                Started by Mindset, 02-28-2026, 06:16 AM
                0 responses
                69 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Working...
                X