Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NTDirect.dll Orders() function

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

    NTDirect.dll Orders() function

    Hello

    I'm trying to build a simple test app in VB6 using NTDirect.dll, and I'm having trouble with the Orders, and OrderStatus functions. The other functions work ok.

    Here are the snippets:

    Private Declare Function Orders Lib "NTDirect.dll" (ByVal acct As String) As String

    then I run the following from button_click()

    Text1.Text = Orders("sim101")

    The text1.text becomes empty. The app is connected, and, I can read the MarketPosition, MarketData just fine. I suspect it's something about the differences in how VB and C treat strings. Can anyone help please? Thanks in advance.
    J

    #2
    Hi Jaba1n, we could unfortunately not really support coding at that level, but from a quick glance - can you please try with Text1.Text = Orders("Sim101")
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand

      Thank you for your reply. Yes, I tried Sim101, no luck. It simply doesn't return anything. The open orders are in the account, I made some transactions previously too. Thanks again.

      J

      Comment


        #4
        From where did you submit the orders to the Sim101 account? From your external application or within NT only?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I tried both.

          Are you saying that Orders() will return only the orders sumbitted by the external app? If so, how do I get all open orders, including those submitted by NT, or the broker app?

          Thanks
          J
          Last edited by Jaba1n; 01-27-2012, 08:25 AM.

          Comment


            #6
            Conceptually it should be working bidirectional - having tried as well passing in an empty account, so it would use the default ATI account set under Tools > Options > ATI?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I tested the empty string, as you suggested, Orders(""). unfortunately I got the same results. Sim101 is set as the default account.

              Maybe I should pass a pointer to a string buffer to the Orders() call if the NtDirect.DLL was written in C? http://support.microsoft.com/kb/187912

              Thanks
              J
              Last edited by Jaba1n; 01-27-2012, 10:05 AM.

              Comment


                #8
                Jaba1n, certainly worth a try from the doc you linked us to. Would you mind contacting me directly at support at ninjatrader dot com with the project you have thus far so I could give a run here?

                Thanks,
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Email with attachment sent. Thanks a lot.

                  J

                  Comment


                    #10
                    Hello,
                    Bertrand, can you or Jaba1n share the resolution of this issue?

                    What are the specifications for the string parameters that the NTdirect.dll functions are expecting:
                    1) Address of Null-terminated ASCII string (as per C)?
                    2) Address of handle of dynamic string?
                    3) Unicode variation of either of the above?
                    4) other?

                    For me, the Connect function works fine (toggles correctly with AT enable), but I cannot get the other functions to work and I think it's the strings.

                    Thanks,
                    N4

                    Comment


                      #11
                      Hello,

                      I will ask Bertrand to see if he can recall the resolution. He will get into the office tomorrow morning.

                      As far as an outright answer we are not c or C++ programmers and work primary in c#. Therefor you may be on to something here, unfortunately I would just need to try a few configurations until I got it working. We use the c# string class for all of our strings in NinjaScript.

                      -Brett

                      Comment


                        #12
                        Hi Brett,
                        Thanks for your fast reply.

                        It seems to work for me now when I pass the strings (dynamic ASCII) as BYVAL.
                        As I understand it this makes a copy of the string, and passes the new string handle to the DLL.

                        However, for those DLL functions that return as a string, they appear to pass back a pointer to a null-terminated ascii string.

                        After decoding this, all seems to work well now and I REALLY like the clean and simple DLL interface.

                        Best regards,
                        N4

                        Comment


                          #13
                          N4Apound, could you post the code that worked for you, please? I kind of gave up on VB for this reason, and started coding in C#. Your code would be beneficial for the NT community, I believe. Thanks in advance.

                          J

                          Comment


                            #14
                            Hi Jaba1n,
                            I am using PowerBasic not VB. There should be VB equivalents to the following PB implementation but I haven't tried that.

                            For the NtDirect.dll function declarations, I did the following:
                            1) All string parameters passed in the DLL functions must have "BYVAL" added in the declares.
                            2) All DLL functions returned as strings should be changed to DWORDs, for pointers to null-terminated (fixed length) ascii strings.

                            Examples of DLL function declares:
                            Code:
                            DECLARE FUNCTION NTNewOrderId IMPORT "NtDirect.DLL" ALIAS "NewOrderId" () AS DWORD '(was STRING)
                             
                            DECLARE FUNCTION NTOrders IMPORT "NtDirect.DLL" ALIAS "Orders" (BYVAL account AS STRING) AS DWORD '(was STRING)
                             
                            DECLARE FUNCTION NTRealizedPnL IMPORT "NtDirect.DLL" ALIAS "RealizedPnL" (BYVAL account AS STRING) AS DOUBLE

                            Example of usage:
                            Code:
                                LOCAL sNTorderId AS STRINGZ * 256
                                LOCAL ptrNTorderId AS STRINGZ POINTER
                                ptrNTorderId = NTNewOrderId()
                                sNTorderId = @ptrNTorderId
                                IF sNTorderId = "" THEN sErrText = FUNCNAME$ & " Error: NTNewOrderId() failed." : AbortFlag = %TRUE : GOTO ErrorTrap
                             
                                LOCAL sNTaccountName AS STRING
                                sNTaccountName = "Sim101"
                                LOCAL dblNTPnL AS DOUBLE
                                dblNTPnL = NTRealizedPnL(sNTaccountName)
                                MSGBOX "NT PnL =" & STR$(dblNTPnL)

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by zstheorist, Today, 07:52 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post zstheorist  
                            Started by pmachiraju, 11-01-2023, 04:46 AM
                            8 responses
                            149 views
                            0 likes
                            Last Post rehmans
                            by rehmans
                             
                            Started by mattbsea, Today, 05:44 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post mattbsea  
                            Started by RideMe, 04-07-2024, 04:54 PM
                            6 responses
                            33 views
                            0 likes
                            Last Post RideMe
                            by RideMe
                             
                            Started by tkaboris, Today, 05:13 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post tkaboris  
                            Working...
                            X