Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to access NtDirect from C#

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

    Unable to access NtDirect from C#

    Hi,

    I am trying to access the NtDirect functionality from within C# but am not meeting success so far.

    I have tried 2 methods;

    1) Add a reference to NtDirect.dll from within a C# project. I get the message;

    "A reference to 'C:\WINDOWS\System32\NtDirect.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."

    2) I tried a direct link from within the source using;

    using System.Runtime.InteropServices;

    class Test
    {
    [DllImport( "NTDirect.dll" )]
    public extern static int Connected( int showMessage );
    public static void Main( string[] args )
    {
    int connectStatus = Connected( 1 );
    }
    }

    I then get an error message saying;

    "Failed to initialize COM library (0x80010106)"

    I know that futures_shark says he has been able to get this method to succeed but I haven't. Similarly, including references to NinjaTrader.Client.dll (which I can get to successfully link in) as he suggests does not give access to the NtDirect functions.

    Any ideas as to what I'm doing wrong?

    many thanks
    Last edited by trader_rick; 01-31-2008, 11:09 AM.

    #2
    NTDirect is a plain, old C DLL, you can not access it like a C# assembly. You would need to make yourself familiar with the .NET interop concept to understand how you access plain, old C DLLs from C# (hint: search for dllimport in the MS docs).

    Comment


      #3
      Hi Dierk

      Thanks for quick response. My message got sent before I'd finished typing as you can see from the updated message. Yes, I have been trying DllImport as I wasn't sure whether NtDirect was a managed dll or not. Thanks for letting me know. I will go away and try again but if you have any additional quick suggestions, I would appreciate them.

      many thanks

      Comment


        #4
        Hmm ... COM setup always is weird. You could try going through a uninstall/reinstall cycle.

        Comment


          #5
          Tried that. No luck. Anybody else out there managed to get this working?

          Comment


            #6
            When adding a reference to your c# project, browse for Ninjatrader.Client.Dll

            then in your code put this line

            NinjaTrader.Client.Client NTClient = new NinjaTrader.Client.Client();

            and this line will submit an order.

            NTClient.Command("PLACE","Sim101","ES 03-08","BUY",1,"LIMIT",1245.00,0,"GTC","ax1234","","" ,"");

            ANother thing is to make sure you have the AT interface is selected on Ninjatrader otherwise your app is ignored with no error message.

            Comment


              #7
              Thanks buddy, that was what I needed to know.

              In the meantime I'd managed to get it working in Python!

              Thanks once again.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by zstheorist, Today, 07:52 PM
              0 responses
              3 views
              0 likes
              Last Post zstheorist  
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              149 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              5 views
              0 likes
              Last Post mattbsea  
              Started by RideMe, 04-07-2024, 04:54 PM
              6 responses
              33 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Started by tkaboris, Today, 05:13 PM
              0 responses
              5 views
              0 likes
              Last Post tkaboris  
              Working...
              X