Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Connection with C# Sample Application

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

    Connection with C# Sample Application

    Hi,

    I'm trying to run the Ninja Trader C# Sample Application with NT version 7.0.1000.2. However, I get the following error:

    "Unable to connect to NinjaTrader (127.0.0.1/36973). Please make sure NinjaTrader is running: Object reference not set to an instance of an Object."

    Any suggestions? AT interface under File menu is checked. I can connect to the same port using external data feed connection with Tradestation.

    Thanks.
    Last edited by Blue Waters; 01-11-2011, 12:30 PM.

    #2
    You can do a quick check via PowerShell to see if Ninja is listening. At the PowerShell prompt try this:

    Code:
    PS C:\> Add-Type -path "c:\Program Files\NinjaTrader 7\bin\NinjaTrader.Client.dll"
    PS C:\> $atiTest = New-Object NinjaTrader.Client.Client
    PS C:\> $atiTest.Connected(1)
    0
    PS C:\>
    The return "0" indicates you are connected, while -1 would indicate you are not. Other funtions are also available:

    Code:
    PS C:\> $atiTest.CashValue("Sim101")
    93930.6249999997
    PS C:\>
    If you are connected and the Sample C# app isn't working, it is a problem with the app.

    Comment


      #3
      MXASJ, thank you very much for your reply. Indeed, Ninja is listening. I can connect to it using the Tradestation DLL, but not with the Ninja C#.NET sample program. I should try your way of testing too.

      Thanks.

      Comment


        #4
        No prob. Did you try removing and then re-referencing NinjaTrader.Client from the source code? Sometimes that helps.

        Comment


          #5
          Thanks I tried that too, but it didn't help.

          Comment


            #6
            Try this out. The VS2010 Project is attached in a zip file. It is very poorly written and extremely basic, but the Order Builder code and Flatten Everything buttons work.

            I just ran it in debug mode, used Order Builder to buy 1 ES 03-10 Market GTC, and used Flatten Everthing to get out. You can see what it is doing in the Log tab and Order tab of NT's Control Center.

            Feel free to make it more functional and post it back for the masses!
            Attached Files

            Comment


              #7
              Thank you very much. I'll try this out tomorrow.

              Comment


                #8
                MXASJ, I looked at the files in your zip file and realized that the NinjaTrader.Client.dll I was using was from 2008! That C# application I downloaded had the old dll in it! Thank you Now my connection problem is resolved!

                Comment


                  #9
                  To All,

                  I've made a starter projected to help understand what using the API looks like with both the NTDirect.dll and NinjaTrader.Client.dll.

                  This example is 100% unsupported by NinjaTrader Support.
                  Attached Files
                  Last edited by NinjaTrader_ChelseaB; 10-19-2016, 03:21 PM.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    where i put this file

                    Comment


                      #11
                      Hello scalper1234,

                      Extract the file any where you would like.
                      This is a project for visual studio.

                      Try extracting this to your Downloads folder, then open the solution in visual studio.
                      Last edited by NinjaTrader_ChelseaB; 01-12-2017, 08:13 AM.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        NT Community,

                        I've recently needed to demonstrate that the API works as documented sending and receiving data.

                        I've added the methods to send and receive data to this starter visual studio project and tested that they work correctly.

                        These examples are 100% unsupported by NinjaTrader Support.

                        (edit June 6th, 2018)
                        These examples are now in the post with further information linked below.
                        Last edited by NinjaTrader_ChelseaB; 06-05-2018, 08:14 PM.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you Chelsea. These little examples are often all it takes for an NT User to get started on a project.

                          Comment


                            #14
                            I am getting 0.0's for Last, Ask, and Bid from this sample application and also from my own sample application. Please help.



                            Comment


                              #15
                              Hello pedromoy,

                              Do you have the ATI enabled?

                              Who are you connected to for real-time data?

                              Is this during a session?

                              Are you seeing real-time ticks appear on a chart?
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by mjairg, 07-20-2023, 11:57 PM
                              3 responses
                              213 views
                              1 like
                              Last Post PaulMohn  
                              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                              4 responses
                              544 views
                              0 likes
                              Last Post PaulMohn  
                              Started by GLFX005, Today, 03:23 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post GLFX005
                              by GLFX005
                               
                              Started by XXtrader, Yesterday, 11:30 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post XXtrader  
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Working...
                              X