• 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

C# Client API Problems

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

    C# Client API Problems

    Sorry I think I posted this in the wrong section.

    I'm currently using the NinjaTrader.Client.dll to do some remote trading and came across a few problems.

    I am able to connect via (Client).SetUp("127.0.0.01",36973) and returned 0 (which is documented as successful), but afterwards no other API calls were able to pass through and resulted in "-1" as a response.

    I've tried to send orders via _client.Command and the returned value was "0", which means it was successful, though no new trades were seen in the Control Center.

    Then I tried to place a bunch of trades and call the orders method and it returns an empty/null string.

    I'm guessing something is wrong with the connection when I call SetUp.
    I've also tried to use NTDirect.dll and loaded it via DllImports but that had the same results as previous.

    Some sort of help would be appreciated.

    -Kelvin

    Code:
    var client = new Client();
    
    var setupResult = client.SetUp("127.0.0.7", 36973);
    
    Console.WriteLine("Setup Result: {0}",setupResult);
    
    for (var i = 0; i < 5; i++)
    {
        var order = client.NewOrderId();
    
        var result = client.Command("PLACE", "Sim101",
            "ES 06-14", "BUY", 5, "MARKET", 0, 0, "DAY",
            string.Empty, order, string.Empty, string.Empty);
        Console.WriteLine("Order Result: {0} | {1} of 5",result, i + 1);
    }
    
    var orders = client.Orders("Sim101");
    Console.WriteLine("Orders: {0}",string.IsNullOrEmpty(orders) ? "EMPTY" : orders);
    Resulting Code:
    Code:
    Setup Result: 0
    Order Result: 0 | 1 of 5
    Order Result: 0 | 2 of 5
    Order Result: 0 | 3 of 5
    Order Result: 0 | 4 of 5
    Order Result: 0 | 5 of 5
    Orders: EMPTY

    #2
    Hello krodriguez,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    Do you see any errors or messages in the NinjaTrader Control Center when the orders should have been submitted or filled? If so, what do these errors or messages report?

    Are there any newly created Positions for the ES on the Positions tab of the Control Center? And you mentioned no new trades show, but do market orders appear as filled on the Orders tab of the Control Center?

    I look forward to your response.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Patrick!

      I've figure out the problem.
      I forgot to turn on the AT Interface in the menu and has solved this issue.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by RobertoPaez, Today, 06:47 PM
      0 responses
      1 view
      0 likes
      Last Post RobertoPaez  
      Started by catinabag, Today, 06:45 PM
      0 responses
      1 view
      0 likes
      Last Post catinabag  
      Started by darkgreen, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post darkgreen  
      Started by GTBrooks, Today, 02:44 PM
      3 responses
      14 views
      0 likes
      Last Post GTBrooks  
      Started by GLFX005, Today, 12:22 PM
      4 responses
      41 views
      0 likes
      Last Post NinjaTrader_Kate  
      Working...
      X