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.
          Kate W.NinjaTrader Customer Service

          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.
              Kate W.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              12 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              11 views
              0 likes
              Last Post terofs
              by terofs
               
              Started by nandhumca, Today, 03:41 PM
              0 responses
              7 views
              0 likes
              Last Post nandhumca  
              Started by The_Sec, Today, 03:37 PM
              0 responses
              3 views
              0 likes
              Last Post The_Sec
              by The_Sec
               
              Started by GwFutures1988, Today, 02:48 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Working...
              X