Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

C# How do I get last price.

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

    C# How do I get last price.

    Hello,
    I am new to NT API.
    I have added as a reference client.dll, then got connected.
    Managed to send order.
    I need to get either subsbscription or getting last price of an instrument.

    And,
    Do NT has a complete C#.NET sample code that do basic functions?

    Thanks in advance.

    Isaac

    #2
    Hello ieitani,

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

    Are you using the NTDirect.dll located in the C:\WINDOWS\system32 folder?
    Have you reviewed the functions available at the following link?

    Comment


      #3
      Not exactly, answer here. close ticker. Thank you.

      Hello,
      I did not find "NtDirect.dll" in System32 like your documentation suggesting.
      I did find it however on:
      C:\Windows\SysWOW64

      p.s. My installation did not installed on Program Files, but did on Program Files (x86) folder.

      I run Visual Studio 2013, and when I did attempt to add NTDirect.dll, it gotten rejected by VS. With the message.
      'FileLocation\NTDirect.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

      I saw some other place another dll of yours "NinjaTrader.Client.dll"...I found it on your Ninja Trader folder on my Program Files (x86) folder \bin directory.

      I have added it smoothly (as reference), then set:
      using NinjaTrader.Client;
      for reference.
      then could set a variable:
      var client = new Client();
      and then got connect:
      NinjaClient.Connected(1);
      returned 0 for success, was so smooth, no time no delay..
      It show that your API is highly robust (as far as I understand programming).

      I manage to send an order:
      success = client.Command("PLACE", "sim101", "NameOfContract", "BUY", 1, "MARKET", 0, 0, "DAY", string.Empty, "1", string.Empty, string.Empty);

      The line above send a Buy order in Market price, I got the popup from NT to confirm the Buy, which I need somewhat to not raise, it since if I will let the code open a position, I won't need to confirm every time, only to have it in a silent mode (if you have it).
      If you could answer to it, then I am interested in this answer, but it don't hold in my way now.

      You could close this thread/question.

      The original quesiton was about getting the last price, and I did manage to find out how, since I don't rest if I post a question.

      The code is:
      //consider that contract, and success are local variables that are set before the code.
      I found out that I need to set subscription before requesting the price.
      The number 0, meaning Last Price, and 1 and 2, could mean Ask and Bid (check which).

      success = client.SubscribeMarketData(contract);
      ///get last price.
      var lastPrice = client.MarketData(contract, 0);
      ////unsubscribe
      success = client.UnsubscribeMarketData(contract);



      I need as well a feed of the change in price, in another Api I was delegating an event, with the signature of the function, and then when subscribing, this function was triggered any time a change in price was made, so I need something similar.

      I need as well, a delegation to methods that will confirm to me that an order was filled.

      I could post another post, but for who ever started to read this post, maybe the information can be valuable.
      As I do intent to contribute with information, as I know when I need them.

      Hope I was clear in what ever information I have provided, and technically answered my quesiton.

      Good luck to all Api Developers..
      Make money, and Ninja is Good. Thanks God.

      Isaac

      Comment


        #4
        Hello Isaac,

        Thank you for your update on this matter.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        8 responses
        31 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by helpwanted, Today, 03:06 AM
        2 responses
        21 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by DayTradingDEMON, Today, 09:28 AM
        0 responses
        7 views
        0 likes
        Last Post DayTradingDEMON  
        Started by navyguy06, Today, 09:28 AM
        0 responses
        2 views
        0 likes
        Last Post navyguy06  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        77 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Working...
        X