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

Excel VBA and ATI

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

    Excel VBA and ATI

    Brand new to Excel VBA. I am trying to automate trading strategies via Excel. I created VBA code as below.

    Private Declare PtrSafe Function CashValue Lib "D:\NinjaTrader 8\bin\NinjaTrader.Client.DLL" (ByVal lpAccountName As String) As Double

    Private Sub CommandButton1_Click()
    Dim dbCashValue As Double
    dbCashValue = CashValue("")
    Range("A1").Value = dbCashValue
    End Sub​

    When I click on CommandButton1, it stops on the line "dbCashValue = CashValue(""), and I get an error msg (see attached).

    Any ideas what I'm doing wrong?​
    Attached Files

    #2
    Is the AT Interface enabled?

    Comment


      #3
      It was not -- thank you for the tip bitdavid! However, after turning this on, I am still getting the same result. It appears the problem is with my VBA code, but I've got to believe I'm not the first person to do this. Someone else must have done it before, and so hoping to find someone with the requisite VBA and NT experience. Hoping to get some feedback from NT early next week when everyone is back in the office. May hit Stackoverflow for some feedback too.

      Interestingly, when I was reading the documentation on utilizing the DLL interface, I saw nothing about enabling ATI. It's probably somewhere in the docs, just didn't see it in the sections I was reading.

      Thanks again -- back to sleuthing!

      Comment


        #4
        Just to make life easier, perhaps you should approach
        this a but differently.

        Instead of trying to get Excel/VBA working, make your first
        attempt be directly with VB.Net.

        From VB.Net, the solution for VBA might come more easily.

        [Of course, ya gotta realize, I am not expert on this -- I mean,
        I'm just making (I hope) helpful suggestions -- I've never tried
        to actually do anything with NinjaScript outside of C#.]

        Comment


          #5
          Maybe you need to add 'NinjaTrader.Client.dll' as a reference inside VBA?

          Comment


            #6
            bltdavid I had the same idea re: adding the DLL as a reference inside VBA. When I tried, it said "Can't add a reference to the specified file." The help behind that msg said that the DLL is not usable by VBA. I'm hoping that on Monday, someone at NT will be able to provide guidance on using this DLL outside of NT, which is the entire premise of NT's Automated Trading Interface (ATI). VBA supports external DLL calls, so one would expect that this interface should be accessible from VBA.

            Comment


              #7
              Bummer ... which version of NinjaTrader are you using?

              Comment


                #8
                On my system, I'm using 8.0.26.1, installed into the default location.

                There are two different Client assemblies,

                C:\Program Files(x86)\bin\NinjaTrader.Client.dll
                C:\Program Files(x86)\bin64\NinjaTrader.Client.dll

                Have you tried using the bin64 version?

                Comment


                  #9
                  Oh, uh ... sorry

                  the bin vs bin64 distinction goes away starting in 8.0.27.0

                  my bad

                  Comment


                    #10
                    I'm using 8.1.1.3, and I only have the bin directory.

                    Comment


                      #11
                      Hello Elevator2TheTop,

                      Thanks for your post.

                      The NinjaTrader.Client.dll for NinjaTrader 8 can be found in:
                      • C:\Program Files\NinjaTrader 8\bin\NinjaTrader.Client.dll
                      Please see this forum thread for information about the API: https://forum.ninjatrader.com/forum/...626#post793626

                      ​Support for the API is very 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 - http://ninjatrader.com/support/helpG..._interface.htm

                      Let me know if I may assist further.
                      Brandon H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Haiasi, 04-25-2024, 06:53 PM
                      2 responses
                      16 views
                      0 likes
                      Last Post Massinisa  
                      Started by Creamers, Today, 05:32 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post Creamers  
                      Started by Segwin, 05-07-2018, 02:15 PM
                      12 responses
                      1,785 views
                      0 likes
                      Last Post Leafcutter  
                      Started by poplagelu, Today, 05:00 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post poplagelu  
                      Started by fx.practic, 10-15-2013, 12:53 AM
                      5 responses
                      5,407 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Working...
                      X