Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to connect to adapter class due to dll issue

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

    Unable to connect to adapter class due to dll issue

    Hello, I am new to Ninja Script and Ninja Trader. Can anyone please help me to fix this issue I'm getting while trying to establish a connection to Ninja Trader Adpater class using NinjaTrader.Core.dll.

    Here is what I am doing. I am creating a new ProviderApi Class by using the methods of existing Ninja Trader Adapter class. The order of steps I need to do is 1. Create Connection() using Connection Class 2. Execute any other methods like GetSymbolInfo() 3.DisConnect().

    I had also created a Xunit testing to test these methods. While I'm trying to those methods Connect() is not working to establish the connection. And throwing this exception

    Message: System.TypeInitializationException : The type initializer for '<Module>' threw an exception.
    ---- System.ArgumentNullException : Value cannot be null.
    Parameter name: ptr

    Please find attachements for the code and Exception details. And please let me know how can I fix it.

    Thanks in advance.
    Attached Files

    #2
    Hello kiran7212,

    Support for the API is limited and our NinjaTrader support staff is not able to assist with external programs that are not NinjaScripts run in NinjaTrader.

    This thread will remain open for any community members that would like to assist.

    That said, I have an example project that demonstrates how to connect and how to receive data.


    Do you have NinjaTrader 8 open?
    May I also confirm NinjaTrader 7 is closed?

    Are you using the default port or have you attempted to change the API port at all?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you NinjaTrader_ChelseaB.

      First I had worked on the method which is generated by the NinjaScript for connection establishment. But even with this method also I got the same exception as

      Message: System.TypeInitializationException : The type initializer for '<Module>' threw an exception.
      ---- System.ArgumentNullException : Value cannot be null.
      Parameter name: ptr

      Later I had tried with some other way by checking in to Ninja support forums. Can you please let me know that Can I establish a connection using NinjaScipt generated method as follows. Or suggest me any other way using ninja script.

      Here is my ninja script method.
      /// <summary>
      /// Establish the connection. This method is called only once during the lifetime of an adapter.
      /// </summary>
      public void Connect(Cbi.IConnection connection)
      {
      // Connection.Options holds all relevant information to establish/manage the connection.
      myConnection = connection;

      // Cast this object to the appropriate type.
      options = (SampleOpenConnectOptions)myConnection.Options;

      // Trace any relevant connection option settings. Be sure to provide the appropriate CultureInfo so values are formatted as you expect.
      if (myConnection.Trace.Connect)
      myConnection.TraceCallback(string.Format(CultureIn fo.InvariantCulture, $"({options.Name}) SampleOpenConnect.Connect: user='{options.User}'"));

      // Initialize and connect to the provider API (if necessary)
      api = new ProviderApi();

      // Notify NT if any API call fails
      if (!api.Connect(options.User, options.Password))
      {
      // primary and price feeds are disconnected
      myConnection.ConnectionStatusCallback(Cbi.Connecti onStatus.Disconnected, Cbi.ConnectionStatus.Disconnected, Cbi.ErrorCode.LogOnFailed, "Unable to connect to provider.");
      return;
      }
      // Let NT know we're connected
      myConnection.ConnectionStatusCallback(Cbi.Connecti onStatus.Connected, Cbi.ConnectionStatus.Connected, Cbi.ErrorCode.NoError, string.Empty);
      return;
      }

      And the quesries u asked me
      Do you have NinjaTrader 8 open? - Yes
      May I also confirm NinjaTrader 7 is closed? - Yes

      Are you using the default port or have you attempted to change the API port at all? - No I did not changed anything.

      Thanks

      Comment


        #4
        Hello kiran7212,

        Unfortunately, there is not enough information here for me to say.

        However, I am not recognizing any of the code you have provided using methods from the NinjaTrader API.

        Is this for a different program that is not NinjaTrader?

        May I confirm you have modeled your code after the working example I have provided you a link to?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        26 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by bmartz, 03-12-2024, 06:12 AM
        3 responses
        30 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by Aviram Y, Today, 05:29 AM
        2 responses
        10 views
        0 likes
        Last Post Aviram Y  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X