Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automated Trading Interface - Control From Within A Strategy

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

    Automated Trading Interface - Control From Within A Strategy

    I'm trying to access the Automated Trading Interface ( NinjaTrader 8 ) from within a strategy. Preferably the DLL method. Some sample code would be much appreciated.

    My use case: Sometimes my connection to IB will disconnect and on occasion my strategy will disconnect and when it comes back up not be in sync. I realize there is auto sync options but none of those have worked for me (I've tried it all). So instead, I can have my strategy do a lookup on the ATI to see if I'm still in a hand and proceed from there.

    Thanks,

    #2
    Hello bc24l,

    Thanks for your post.

    The DLL interface is used to have external apps interface with NinjaTrader. Order submissions can be made from here and ATM strategies can be started as well. The DLL interface does not allow starting NinjaScript strategies or interacting with them.

    The DLL interface is also provided as-is and support is limited to the resources available below. Please note that my colleague Chelsea's example is not officially supported by NinjaTrader.

    DLL interface - https://ninjatrader.com/support/help.../functions.htm

    Example application (Unsupported example) - https://ninjatrader.com/support/foru...442#post514442

    If your strategy disables from a disconnection, you would not be able to start it from the DLL interface, and we would not suggest trying to hook into the DLL interface through NinjaScript.

    If the issue is involving a strategy sync issue in the event of a disconnect, I suggest working through that instead.

    If you set Connection Loss Handling to Keep Running and set Disconnect Delay seconds to a high value, the strategy will stay running and would only fall out of sync if orders were filled during the disconnection. (This can be set in the Control Center under Tools > Options > Strategies)

    If the strategy gets disabled, you can re-enable it with ImmediatelySubmit and it will process historical data and attempt to match the orders calculated from historical data with live working orders. If the orders match, they will resume, otherwise, the live orders will be cancelled and replaced with those calculated from historical data.

    Another option to consider would be to program the strategy to use AdoptAccountPosition so when you enable the strategy, it inherits the active account position. I have attached some examples.

    For the thread's reference I have linked our Syncing Account Positions page of the Help guide.

    https://ninjatrader.com/support/help..._positions.htm

    Please let me know if you are experiencing any issues involving syncing strategies, we will be happy to assist further.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for the info Jim. Can you provide an example of how I can access NTDirect.dll from within NinjaScript? Is that possible?

      Comment


        #4
        Hello bc24fl,

        We do not have a such an example and we would not suggest trying to hook into the DLL interface through NinjaScript.

        The DLL interface is designed for external applications to interface with NinjaTrader. NinjaScript AddOn Framework would be better suited for the same sort of automated trading functionality but run directly from the platform.

        AddOn Framework Account class - https://ninjatrader.com/support/help...ount_class.htm

        Note: Neither the DLL interface or AddOn Framework allow starting NinjaScript strategies.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks Jim. Instead of access NTDirect.dll (I realize it was a hack.. but it was temporary), I was able to get the account position info from the Account class. Didn't realize the strategy is capable of knowing the account info even though it had been disconnected & reconnected. Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by t.kelly4149, Today, 05:36 PM
          1 response
          5 views
          0 likes
          Last Post bltdavid  
          Started by SilverSurfer1, Today, 06:29 PM
          0 responses
          13 views
          0 likes
          Last Post SilverSurfer1  
          Started by trader3000a, Today, 01:06 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by marcus2300, Today, 11:45 AM
          3 responses
          30 views
          0 likes
          Last Post marcus2300  
          Started by pel11, Today, 11:06 AM
          0 responses
          12 views
          0 likes
          Last Post pel11
          by pel11
           
          Working...
          X