• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get Feed of Price Change to Method/Event & Confirm Order

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

    Get Feed of Price Change to Method/Event & Confirm Order

    Hi All,

    1. Subscribe
    I know from other API that it is possible to subscribe to the Market Data of an instrument/contract, and then I get into a Method/Function any tick / price change.

    Is is possible with NT API?

    2. Order Confirmation.
    How I can confirm (from C# code) that order got filled, and get the details on that order, p.s. Fill price..


    In other worlds, dose NT push information to the application?
    I know by relating the Method (with right signature) to the socket, then I can get information from NT and not only send.

    Thank you,
    Isaac


    Thank you.

    #2
    Hello ieitani,

    Thank you for your post.

    1. In the supported functions for the NTDirect.dll there would be no options to subscribe to events. The NTDirect.dll is not intended as an API for market data but rather to allow for Automated Trading through external sources and allow them to tell NinjaTrader to submit orders.
    If you are working on an API we would not have supported items for this in NinjaScript or the ATI available functions.

    2. If using the NTDirect.dll then please review the functions for orders available at the following link: http://ninjatrader.com/support/helpG.../functions.htm

    Please let me know if you have any questions.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Yes I have a question.
      If I need to make orders and run a strategy, how I can know what is going on in the position?
      Should I pull information 5 times a second?
      I trigger it based on the change of the price, or position. By Any Tick move, or price change.

      So, I need to delegate a function/method to receive each of price change, or tick, or change in position.
      It is the minimum I can ask.

      BTW: I am not using NTDirect.dll, I could not reference it to the VS environment.
      I used NinjaTrader.Client.dll instead...
      Maybe you can explain me why?
      It has all the function, you send me for reference.
      So, it is exactly the same.

      And within the same dll, I have a namespace: NinjaTrader.Data...
      I saw within it, some property of the event "OnMarketData(MarketDataEventArgs e)"...
      And why I cannot subscribe to this event? Is it only from inside Ninja?
      I don't like to put my code inside Ninja, and thank you for the Dll reference so I can run it from outside, like TWS API.

      Please help, or even put my request in your next version, I think you good enough to not be the best.
      With OEC, I get it, but the broker is more "...".. Understand?
      I am your client now, so I ask for respect.

      Thank you,
      Isaac

      Comment


        #4
        Hello ieitani,

        Thank you for your response.

        There would not be any function that would update to the external object without being called. So the functions for the DLL interface need to be called. It is up to you how you wish to pull those values whether using a timer or another means.

        The NTDirect.dll should be an item you can call in your project. You stated C:\Windows\SysWOW64 is where you found it on your PC. What message do you receive when attempting to call the NTDirect.dll in Visual Studio? Please provide a screenshot if possible.

        As far as the NinjaTrader.Client.dll, the functions or methods that can be called there are not intended to be from an external application. So items like OnOrderUpdate would not have any expected behavior as calling them in an external object would be unsupported.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          I ask for the best practice.
          I understood that your work with the socket is highly smooth, what if in a timer I will run few times a second, calling for the status, and maybe I will mimic or generate an event that will update me on any change in price or position.
          Still I see this solution as patch, and not like original. It could be a solution, but not healthy one. In my opinion.

          I think it is better that your Api dll will able to push information into our code. Like I get with OEC (you should know, if you are from NT customer support).
          So we need to set something like this.
          NTInstance.OnPriceChange += OurOnPriceChangeMethod (that has the same signature) as delegate and you will trigger onto this method as an Event.
          I am sure that with programming inside NT, I could get a trigger per price/position change.
          Otherwise, how can I decide what to do if I don't track price change, or to get a trigger when an order got filled, or I got the desired profit, and should make my decision of what to do.

          I did API with FIX as well. and when we subscribe to data, we get data feed 4,5,6 times a second, even when the format of FIX is a string, it is triggered into a method, and I can parse it and trigger my operation.
          I think it is basic, same like be able to set/change/cancel order, and I got this part already.
          If not, I am a bit stuck and will need to find some solution.
          I am a very robust programmer, so I wish to do thing right.

          Sorry for writing long rationality letter about what I need, therefore WANT. and it is right to all of us (API Developers).


          NtDirect.dll:
          In regards for the NtDirect.dll, and you asked me to show you a snapshot. You don't have ability to upload an image to you.
          So, I put it on my server, but can't promise that I will keep it there for long. So, mabe there is a time where a reader will read this article, and won't have the snapshot shown.

          When I attempt to reference the file from C:\Windows\SysWOW64.
          I copied it to a folder in my app folder, and opened VS as admin.
          The message I get state:
          A reference to 'D:\AppFolderLocation\NtDirect.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
          I have uploaded the image (snapshot) to this message. In addition.


          Thank you for your support.

          BTW: If you will tell me that I could get this solution with Ninja Trader 8, then I will move to the 8th version. It is all new here and won't make a different to me in this stage.
          Please escalate it to the development team, and give us better API, I would say like it should be. Where I can develop from our code (dll, or app[exe]) all possible logic, and communicate with your application. or even with FIX protocol, which is common in this market. At least what I ask for, does exist with FIX (and other API [OEC] I know).


          Thanks,
          Isaac
          Attached Files
          Last edited by ieitani; 07-03-2016, 04:27 AM.

          Comment


            #6
            Hello ieitani,

            Thank you for your feedback, I have submitted a feature request on your behalf to add events for the price changes and for market data (and I am assuming for the account position changes as well) to the NTDirect.dll that allow you to subscribe to these events by assigning handlers.

            Once I have a tracking ID for this request I will post this in this thread.

            Regarding the NTDirect.dll (which is a 32-bit dll, meaning your application must be a 32-bit application), this is a managed dll and must be P/invoke imported into your project. Also, you cannot move the file or copy the file and reference a new location or the NinjaTrader 7 platform will not be able to locate the file.
            On a 32-bit machine this is located in C:\Windows\System32
            On a 64-bit machine this is located in C:\Windows\SysWow64

            Below is a link to an example of Platform Invoke on a dll.
            https://msdn.microsoft.com/en-us/library/55d3thsc.aspx

            That said, the NinjaTrader.Client.dll does not need to be P/invoked and can be referenced directly from your application, but the correct cpu architecture type must be used for that application (and will work with that type of NinjaTrader).
            If your application is 32-bit, reference the C:\ProgramFiles (x86)\NinjaTrader 7\bin\NinjaTrader.Client.dll and use this with NinjaTrader 7 32-bit.
            If your application is 64-bit, reference the C:\ProgramFIles (x86)\NinjaTrader 7\bin64\NinjaTrader.Client.dll and use this with NinjaTrader 7 64-bit.

            Then make a new Client object. The client object will hold the commands available in the NTDirect.dll.
            Last edited by NinjaTrader_ChelseaB; 07-05-2016, 09:43 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              My Installation is on Program Files (x86), but the DtDirect.dll, is only on SysWOW64, and I have none in System32.

              I got confused from your last message Chelsea.

              Comment


                #8
                Hello ieitani,

                If NinjaTrader has installed to Program Files (x86) then this means you are running Windows 64-bit and the file will be located in C:\Windows\SysWow64.

                (If NinjaTrader is installed to Program Files, this would mean Windows is 32-bit and the file will be located in C:\Windows\System32.)
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Dear Chelsea,
                  Could you understand why I cannot reference DtDirect.dll?
                  I get that message (look above, this thread)...
                  It don't matter where I take it from.

                  And you right, I have 64 bit OS, so the DLLs located on SysWOW64 folder.
                  Still I am stuck with the fact that I cannot get delegated method triggered OnPriceChange, or OnMarketData, or OnPositionChange, or OnOrderFilled, etc.
                  If I get them, I am all set.

                  How can I make it?

                  Comment


                    #10
                    Hello ieitani,

                    Post #6, the NtDirect.dll is a managed dll and must be P/invoke imported into your project. You will not be able to add this to the references.

                    Below is a link to an example of Platform Invoke on a dll.
                    https://msdn.microsoft.com/en-us/library/55d3thsc.aspx

                    For example:
                    Code:
                    [System.Runtime.InteropServices.DllImport("C:\\Windows\\SysWOW64\\NtDirect.dll")]
                    public static extern int Connected(int showMessage);

                    Alternatively, the NinjaTrader.Client.dll is not managed and can be directly added to the references in your project.
                    Last edited by NinjaTrader_ChelseaB; 10-25-2016, 07:36 AM.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by saeed, Today, 12:32 PM
                    3 responses
                    32 views
                    0 likes
                    Last Post NinjaTrader_PatrickG  
                    Started by motog4, Today, 11:42 AM
                    3 responses
                    18 views
                    0 likes
                    Last Post NinjaTrader_PatrickG  
                    Started by derivtrader, Today, 11:20 AM
                    5 responses
                    27 views
                    0 likes
                    Last Post derivtrader  
                    Started by TAJTrades, Today, 10:34 AM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_ChrisL  
                    Started by timcjpfx, Today, 10:20 AM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X