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

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.



    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 CommonWhale, Today, 09:55 AM
          1 response
          2 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by Gerik, Today, 09:40 AM
          2 responses
          7 views
          0 likes
          Last Post Gerik
          by Gerik
           
          Started by RookieTrader, Today, 09:37 AM
          2 responses
          11 views
          0 likes
          Last Post RookieTrader  
          Started by alifarahani, Today, 09:40 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by KennyK, 05-29-2017, 02:02 AM
          3 responses
          1,285 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X