Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

C#.NET <-> NinjaTrader

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

    C#.NET <-> NinjaTrader

    Hi,

    I made this code, but doesn't work. My return always is 0.

    Client c = new Client();
    if (c.Connected(1).Equals(0))
    {
    c.SubscribeMarketData("BVMF3.SA");
    double value = c.RealizedPnL("BVMF3.SA");
    textBox1.Text = value.ToString();
    }
    else
    {
    textBox1.Text = "Error!";
    }

    #2
    Welcome to our forums, I suggest you check into the sample code provided in the C:\Program Files\NinjaTrader 6.5\bin\AutoTrade folder > NinjaTraderCSharpSampleApplication.zip

    For the RealizedPnL call, it works for the account where you pass a symbol in - http://www.ninjatrader-support.com/H...ientClass.html

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Welcome to our forums, I suggest you check into the sample code provided in the C:\Program Files\NinjaTrader 6.5\bin\AutoTrade folder > NinjaTraderCSharpSampleApplication.zip

      For the RealizedPnL call, it works for the account where you pass a symbol in - http://www.ninjatrader-support.com/H...ientClass.html

      Hi,

      The correct code is this:

      Client c = new Client();
      if (c.Connected(1).Equals(0))
      {
      c.SubscribeMarketData("BVMF3.SA");
      double value = c.MarketData("BVMF3.SA", 2);
      textBox1.Text = value.ToString();
      }
      else
      {
      textBox1.Text = "Error!";
      }

      Comment


        #4
        Ok, so does this code work for you now as expected or not? Do you get 0 returned for the SubscribeMarketData call?

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Ok, so does this code work for you now as expected or not? Do you get 0 returned for the SubscribeMarketData call?
          I get 0, but I expected 12,50 as is showed in NinjaTrader for this instrument.

          Comment


            #6
            Likely you should not be opening new data streams every single time your code processes.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I don't understand.

              May you give me an example?

              Comment


                #8
                if (c.Connected(1).Equals(0))
                {
                c.SubscribeMarketData("BVMF3.SA");
                double value = c.MarketData("BVMF3.SA", 2);
                textBox1.Text = value.ToString();

                You are subscribing every single time possible. You don't need to keep subscribing. Once you have subscribed that is it. Also, BVMF3.SA actually needs to be an instrument in NinjaTrader.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Hi NinjaTrader_Josh,

                  Thank you for your attention, but I made the "BVMF3.SA" as an instrument in my NinjaTrader but doesn't work.

                  Comment


                    #10
                    Please just try with a standard instrument first. Something like AAPL is easy to test if you have equities data from your data provider.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    67 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    41 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    24 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    27 views
                    0 likes
                    Last Post TheRealMorford  
                    Started by Mindset, 02-28-2026, 06:16 AM
                    0 responses
                    53 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Working...
                    X