Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    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 helpwanted, Today, 03:06 AM
      0 responses
      3 views
      0 likes
      Last Post helpwanted  
      Started by Brevo, Today, 01:45 AM
      0 responses
      7 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      5 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      242 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      384 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X