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

Accessing NtDirect.dll from VS2008

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

    Accessing NtDirect.dll from VS2008

    Hello,

    I like Ninja Trader and will subscribe to it if I can get the following to work.
    I am trying to access NtDirect.dll from a program that I wrote in C++ (using Visual Studio 2008).
    I cannot access the functions in NtDirect.dll properly.

    I wrote similar programs (and dll's) for the MetaTrader platform and they work flawlessly. I can't understand why my program does not work with NinjaTrader. I researched this issue and found that the answer involves complex, tedious programming using .NET interop. If this is the case, then I will not bother because of the instability of the variable passing and the long hours of programming involved.

    Please prove me wrong by providing an easy way to load the NtDirect.dll functions into my C++ program-then you will get my subscription.

    Below is all I have to do to get it to work with Metatrader(I tried to change it to work with NinjaTrader, but it wont work). Visual Studio says that the SubscribeMarketData function takes two integers as inputs, while the NinjaTrader documentation says that it takes a string.

    HINSTANCE Ninjainstance;
    MYPROC Ninja1;
    LONG Ninjatest1;

    Ninjainstance=LoadLibrary((LPCTSTR)L"C:\\Program Files\\NinjaTrader 6.5\\bin\\NtDirect.dll");
    Ninja1=(MYPROC)GetProcAddress(Ninjainstance,"Subsc ribeMarketData");
    Ninjatest1=(Ninja1)(L"EURUSD");

    Any suggestions will be helpful.

    Thanks,
    Nate9999

    #2
    Unfortunately this is beyond the level of support we could provide, nor are we C++ experts.

    However, the DLL methods of the ATI (Automated Trading Interface) are documented here: http://www.ninjatrader-support.com/H...unctions2.html

    int SubscribeMarketData(string instrument)
    Starts a market data stream for the specific instrument. Call the MarketData() function to retrieve prices. Make sure you call the UnSubscribeMarketData() function to close the data stream. A return value of 0 indicates success and -1 indicates an error.

    Note: at the DLL level there is no .NET or interop involved.

    Comment


      #3
      Thank you for the quick response!!!

      If anyone has any suggestions, please feel free to post them!


      Nate9999

      Comment


        #4
        Look for this sample application.

        C:\...\NinjaTrader 6.5\sample\NinjaTraderCSharpSampleApplication

        Comment


          #5
          Hello,

          Thank you for pointing me in the right direction. I found the file NinjaTraderCSharpSampleApplication.zip, and it is a zipped archive.
          I unzipped it and found the application.

          Unfortunately, this program does not import the NtDirect dll file. Instead it uses Classes embedded into forms that override classes in NinjaTrader in order to get Quote/Order objects. There is nothing wrong with this type of programming but it slows down your access time immensely and makes for sloppy programming. It even overrides a thread!!! And the program is way to large and awkward for what it does.

          This is the reason why I don't like MetaTrader...the programming slows down your access to the quote stream and you always get "Off quotes" and are unable to fill orders quickly. Besides that, Metatrader was written by thieves (for desk dealers). This is why I have decided to write my own application. All I am looking for is a way to import NtDirect.dll into C++,C# or VB. Perhaps the team at NinjaTrader does not want individuals to access these functions, and have made it very difficult to do so.(Understandably so).

          I really like NinjaTrader, and the way you can trade from the chart. But I want to be able to trade from the chart and see my balance and positions at the same time. Hence my own programming routine.

          Thanks for the file info!

          Nate9999

          Comment


            #6
            NtDirect.dll importing

            Hello,

            I have been trying to import NtDirect.dll into a program that I have been writing in Visual Studio 2008. The documentation at NinjaTrader states that NtDirect.dll can be imported, and all of its function utilized. However, they probably meant that NtDirect.dll can be imported within its own scripts, and not from external applications. The program NinjaTraderCSharpSampleApplication overrides a thread to get a quote/order object which is a VERY UNSTABLE way of doing things. I would not trust this method with my trade money. It is slow and unreliable.

            After about 8 hours of trying to import NtDirect.dll with no results, I have determined that it is not possible to do so from an outside program. It only took me 1 hour to do the same thing on the Metatrader platform with perfect results (But I hate Metatrader and like NinjaTrader)...shame...

            Thanks,
            Nate9999

            Comment


              #7
              Hello,

              I will have someone reply to your post on Monday. Thank you for your patience.
              DenNinjaTrader Customer Service

              Comment


                #8
                Hi Nate9999, I'm not sure I follow what you exactly mean by 'Import NTDirect.dll'. Could you please clarify?

                Here's the overview over our ATI (Automated Trading Interface) concept - http://www.ninjatrader-support.com/H...heConcept.html
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Nate,

                  You first have to "add reference" to the NTDirect.dll" file. To do this, in your current VS project workspace, right click the top level assembly, then select "add reference." In here, go to the Browse tab and browse to the NTDirect.dll file and add it.

                  You can then add
                  Code:
                  using NinjaTrader.Cbi;
                  using NinjaTrader.Client;
                  using NinjaTrader.Data;
                  to the top.

                  Then you can create an NT object
                  Code:
                  NinjaTrader.Client.Client NTClient;
                  Then, instantiate the object in the default constructor.
                  Code:
                  NTClient = new NinjaTrader.Client.Client();
                  try it out and let us know.
                  mrlogik
                  NinjaTrader Ecosystem Vendor - Purelogik Trading

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by traderqz, Today, 12:06 AM
                  10 responses
                  18 views
                  0 likes
                  Last Post traderqz  
                  Started by algospoke, 04-17-2024, 06:40 PM
                  5 responses
                  46 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by arvidvanstaey, Today, 02:19 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Started by mmckinnm, Today, 01:34 PM
                  3 responses
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by f.saeidi, Today, 01:32 PM
                  2 responses
                  9 views
                  0 likes
                  Last Post f.saeidi  
                  Working...
                  X