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

NT8-API NinjaTrader.Client.dll demo

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

    NT8-API NinjaTrader.Client.dll demo

    Hi. I follow the NT8-API NinjaTrader.Client.dll demo sample but I can not get the results. I have NT lifetime license.

    I put my file reference in: C:\Program Files\NinjaTrader 8\bin\NinjaTrader.Client.dll
    However, I supose this reference does not work very well

    Please I need to connect my program with NT8 in my laptop for my own use.

    There is a update demo because this is from 2016-12-06.


    Here my code in:


    Microsoft Visual Studio Community 2022 (64 bits) - Current
    Versión 17.6.5​
    Microsoft.Net Framework Version 4.8.04084

    My code: (the same like demo by NT support)

    using System;
    using System.Windows;
    using NinjaTrader.Client;

    // set Built -> Cinfiguration Manager -> Active solution Platform -> X64
    // Reference -> C:\Program Files\NinjaTrader 8\bin\NinjaTrader.Client.dll
    // NT8


    namespace NT8Client
    {
    public partial class MainWindow : Window
    {
    private Client myClient = new Client();
    private bool shuttingDown = false;
    private System.Timers.Timer timer;

    public MainWindow()
    {
    InitializeComponent();
    Closed += MainWindow_Closed;
    Loaded += MainWindow_Loaded;
    }
    private void MainWindow_Closed(object sender, EventArgs e)
    {
    if (shuttingDown)
    return;

    myClient.UnsubscribeMarketData("ES");

    timer.Enabled = false;
    shuttingDown = true;
    Environment.Exit(0);
    }

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
    int connect = myClient.Connected(1);

    Console.WriteLine(string.Format("{0} | Connected to NT8: {1}", DateTime.Now, connect.ToString()));

    myClient.SubscribeMarketData("ES");

    timer = new System.Timers.Timer()
    {
    Interval = 1000
    };

    timer.Elapsed += TimerElapsed;
    timer.Enabled = true;
    }

    public void TimerElapsed(object sender, System.Timers.ElapsedEventArgs args)
    {
    if (myClient == null)
    return;

    double lastPrice = myClient.MarketData("ES", 0);

    Console.WriteLine(string.Format("{0} | Last {1}", DateTime.Now, lastPrice));
    }
    }
    }​

    Errors:
    ​​
    Attached Files

    #2
    Hello jesusmbecerra,

    Thanks for your post.

    Please refer to the forum post link below for more information about the NinjaTrader API and a reference sample called Ninja8API that demonstrates connecting to NinjaTrader, then sending and receiving data for NinjaTrader 8. You could also find a demonstration video on this forum thread.
    https://ninjatrader.com/support/foru...art#post793626

    Also, see this help guide about using the NinjaTrader 8 API: https://ninjatrader.com/support/help..._interface.htm

    Note that the example scripts are 100% unsupported by NinjaTrader as mentioned in the forum thread.

    Support for the API is limited from NinjaTrader Support. We are not able to assist with any code in an application external to NinjaTrader. We are able to detail the usage of any methods available from the API.

    Below I am providing a publicly available link to the help guide that lists the functions available to the API.

    Help Guide NT8 API functions - https://ninjatrader.com/support/helpGuides/nt8/functions.htm

    On the forum, you can ask other developers in the community if anyone has tips for unsupported external application code.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Brandon,

      I try with this Ninja8API.zip in https://forum.ninjatrader.com/filedata/fetch?id=1135352 and my app runs, however, the data always is zero: Here is my output:

      'NinjaTraderClient.exe' (CLR v4.0.30319: NinjaTraderClient.exe): 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System .Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dra wing.dll' cargado. Se omitió la carga de símbolos. El módulo está optimizado y la opción del depurador 'Sólo mi código' está habilitada.

      13/07/2023 4:57:49 p. m. | connect: 0
      13/07/2023 4:57:59 p. m. | ES 09-23 | Last: 0, Ask: 0, Bid: 0
      13/07/2023 4:58:00 p. m. | ES 09-23 | Last: 0, Ask: 0, Bid: 0
      13/07/2023 4:58:01 p. m. | ES 09-23 | Last: 0, Ask: 0, Bid: 0
      El subproceso 0x1dac terminó con código 0 (0x0).

      Something that Can I check please ?

      Regards, Jesus

      Click image for larger version

Name:	image.png
Views:	511
Size:	207.5 KB
ID:	1260302
      ​​

      Comment


        #4
        Hello Jesus,

        Thanks for your notes.

        The Ninja8API that Chelsea shared in that forum thread does work.

        To test the Ninja8API, you must enable the AT Interface option in NinjaTrader 8 by opening NInjaTrader and going to the Tools > Options > Automated Trading Interface tab. Enable the 'AT Interface' checkbox option and click OK.

        After enabling the 'AT Interface' option, restart NinjaTrader.

        Then, open the Ninja8API project in Visual Studio, run the Visual Studio project, and click the 'Receive AAPL' button to receive AAPL data. Data will appear under the 'Receive AAPL' button. After a few moments pass, stop the Visual Studio project and note the Output window.

        See this demonstration video: https://brandonh-ninjatrader.tinytak...N18yMTc0NjE2MQ
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hi Brandon.

          Thank you very much. Everything goes good. Now the project is working. Thank you again for your support. I am studying software development and it is very important for me. I know you do not give support in this case but I supose I can post here my scripts about C# tools for NT8 for study porpuses.

          Regards,

          Jesús.-

          Click image for larger version

Name:	image.png
Views:	497
Size:	192.7 KB
ID:	1260427

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Segwin, 05-07-2018, 02:15 PM
          14 responses
          1,788 views
          0 likes
          Last Post aligator  
          Started by Jimmyk, 01-26-2018, 05:19 AM
          6 responses
          837 views
          0 likes
          Last Post emuns
          by emuns
           
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          6 responses
          3,293 views
          1 like
          Last Post jgualdronc  
          Started by Touch-Ups, Today, 10:36 AM
          0 responses
          12 views
          0 likes
          Last Post Touch-Ups  
          Started by geddyisodin, 04-25-2024, 05:20 AM
          11 responses
          62 views
          0 likes
          Last Post halgo_boulder  
          Working...
          X