Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninjatrader, IB, Python integration, backtest and live trading environment

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

    Ninjatrader, IB, Python integration, backtest and live trading environment

    I used MT4/5 as a trading and backtest platform. Besides Fx trading, I would like to connect to Interactive Broker for a wider range of instruments coverage. By searching around the web, I found that Ninjatrader is able to connect to IB. I would like to confirm more details so that I can have a deeper understanding of NT.

    Q: Can NT integrate with python?
    - DLL integration, https://ninjatrader.com/support/help...?functions.htm
    - From the above api list, I cannot find callback functions such as OnBarUpdate()... Is that means I cannot backtest those strategies created by python?

    Q: Can I use different python environment in different strategies?
    - I may need to use virtualenv to create and maintain different python run time environment. In the python integration working scenario, can I select different virtualenv for different strategies?

    Q: Can I backtest and live trading my strategies which is getting price data from multiple instruments and placing orders to multiple instruments?
    - From https://ninjatrader.com/support/help...nstruments.htm
    - I can see that I may be able to get price from different instruments but can I make orders to different instrument during backtest and live trading?

    Q: I would like to trade stocks from different markets through IB. Is it possible for me to do backtest on NT as long as I get those data from other data source?
    - I used to use tick data suite in MT4/5 which provides tick data to the backtest system. Is there any thing similar in NT? Is it possible to do any specific backtest once I get the historical data in csv file?

    Thank you very much.

    #2
    Hi Sulfred, thanks for your post and welcome to the NinjaTrader forum.

    Q: Can NT integrate with python?
    A: The DLL interface allows any external application that can import DLLs to communicate with NinjaTrader through the documented methods. As long as you can find a python library that can import the DLL then it can be used in your program. The methods that belong to the Strategy class are separate from all of this. If you wanted an automated trading system implemented through the DLL interface your python code must manage every aspect of the strategy. We have an example program here that might be helpful:


    Q: Can I use a different python environment in different strategies?
    A: I'm really only an expert with NinjaScript/C#. In my past python experience, the virtualenv was to have a python environment with its own encapsulated dependencies/librarys. It would be up to you to decide this based on how you implement a strategy in python.

    Q: Can I backtest and live trading my strategies which is getting price data from multiple instruments and placing orders to multiple instruments?
    A: If this strategy is written in NinjaScript with a managed/unmanaged strategy then you can use the Strategy Analyzer to backtest your strategy over a large amount of historical data. As far as using the DLL interface, the backtesting code would also need to be implemented.

    Q: I would like to trade stocks from different markets through IB. Is it possible for me to do backtest on NT as long as I get those data from other data source?
    A: Yes, you can backtest multi time frame strategies. If you are enabled for a given instrument with Interactive Brokers, you will be able to pull historical and real time data for that instrument regardless of the exchange its traded on. NinjaTrader figures that out through the Interactive Brokers connection.

    Kind regards,

    -ChrisL




    Comment


      #3
      Hey Guys, Glad to connect
      I have built a new connector for NT8 python bridge, check it out on my github its called PyNinjatrader .
      The dll connector also have many features that help your strategy interact with nt8 and get an method in very simple ways.
      Last edited by offpista; 06-06-2024, 02:45 AM.

      Comment


        #4
        Hello offpista,

        Unfortunately, I've had to remove the link from your post.
        To ensure a fair forum environment that isn't filled with advertisement, our policy is to remove links to third party sites that are not educational.
        It can helpful to discuss a vendor product, however if you have links to non-educational material such as product sites please consider sending these as a private message to the recipient.​
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello, This is a tool that can help the community,
          how can I show this tool if I am not linking to it? I linked to my github, that tool is partly open source....

          Last edited by offpista; 06-06-2024, 02:47 AM.

          Comment


            #6
            Hello offpista,

            Please send the link as a private message to the recipient or submit the script to the User App Share.
            Upload tools and add-ons that you build to share through the NinjaTrader Ecosystem User App Share.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            110 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            59 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            37 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            41 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            78 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X