• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NewOrderID() and OrderStatus(string)

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

    NewOrderID() and OrderStatus(string)

    Hi All,

    Super newbie with NT but I do have a lot of experience with Object Oriented Programming. Having a bit of a head scratching moment. I can successfully call many functions from the NTDirect dll, (SubscribeMarketData, MarketData, even Command("PLACE"...)), but when I call NewOrderId or OrderStatus( orderID ) my program crashes. It doesn't seem to even be throwing an exception (I have a try/catch around it).

    I simply have:

    string orderID = "";
    orderID = NewOrderId();

    crash.

    Any ideas?

    #2
    Hello AmandaMck,

    Welcome to the NinjaTrader Support Forums!

    The DLL Interface is not something that we can support but I would not expect it to crash your program.

    How are you using/importing the NinjaTrader DLL file?

    If you set a breakpoint to the OrderID string does it return a value at all?
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks for your quick response! Check out the following... when setting a breakpoint and stepping through, it crashed during the NewOrderId() call (it never returns).

      ````````````````````````````````````````````

      using System;
      using System.Runtime.InteropServices;
      using System.Threading;

      namespace NTAutoTrader
      {
      class AutoTrader
      {
      [DllImport("NTDirect.dll")]
      public static extern int SubscribeMarketData(string instrument);
      [DllImport("NTDirect.dll")]
      public static extern int UnsubscribeMarketData(string instrument);
      [DllImport("NTDirect.dll")]
      public static extern string NewOrderId();
      [DllImport("NTDirect.dll")]

      [STAThread]
      static void Main(string[] args)
      {
      SubscribeMarketData("$EURJPY");
      string orderID = "";
      orderID = NewOrderId();
      System.Console.WriteLine("OrderID is " + orderID);
      }
      }
      }


      `````````````````````````````````````````

      Comment


        #4
        Ahhhh.... I *think* it might have to do with the fact that you can't really pass strings back from dlls? Ints are no problem because they are fixed size, but strings are an array of chars that might be out of scope? If this is the problem, is there a trick to getting this info back from NewOrderId()?

        Comment


          #5
          Hello AmandaMck,

          It looks like you are using C# so I do not think it is the fact that you are passing strings back and forth.

          What version of .NET are you compiling your application in? Note that the NinjaTrader DLL interface only supports the 32-bit .NET 3.5 and below.

          Also, in your reference you have an extra "[DllImport("NTDirect.dll")]" , I take it your referencing all of the other methods after that correct?
          JCNinjaTrader Customer Service

          Comment


            #6
            I checked and I was using .NET4.5 Switched it to 3.5 and rebuilt. Now I can't even load the dll for some reason (dll not found exception). Is there a more appropriate forum to get support for the DLL Interface? Is using the DLL Interface an old solution? Should I be accessing these function some other way?

            Comment


              #7
              Hello AmandaMck,

              The DLL interface is not an old solution. There is not another forum that will support this but the only other forum that may help is the BigMikeTrading.com.

              With that said, if you want to either post the full message or a sample of the "form" or "program" that you have built I can try to take a further look into it for you.

              Note there is a sample reference that you can download and view at the following thread if you have not seen it.
              http://www.ninjatrader.com/support/f...?t=6971&page=2
              JCNinjaTrader Customer Service

              Comment


                #8
                Thanks, I'll fiddle around and get it working with .NET 3.5 and check out the sample reference you posted. I'll let you know where I'm at once I get there! Thanks for the advice so far.

                Comment


                  #9
                  Got it to work! Here was the solution in case anyone else has the same problem:

                  Target framework: .NET Framework 3.5
                  Platform Target: x86

                  After doing this I was still getting a crash, the solution was to disable "Enable the Visual Studio hosting process" under Project Properties->Debug

                  * I am using Visual Studio 2013 and Windows 7.
                  Last edited by AmandaMck; 04-03-2014, 08:01 PM. Reason: Adding information

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ralett, Today, 11:28 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post ralett
                  by ralett
                   
                  Started by ChazJ, Today, 09:59 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by Irukandji, Today, 09:34 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Started by lunardiplomacy, Today, 08:32 AM
                  3 responses
                  13 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Started by ralett, Today, 08:24 AM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Working...
                  X