Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How backtesting c# strategy IB API in Ninjatrader

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

    How backtesting c# strategy IB API in Ninjatrader

    Hi,


    I developed my own strategy in C# (my own application) communicating with Interactive Brokers through the IB API.
    This strategy is working well and now I need to perform tests.

    How do I run tests on Ninjatrader?


    I've already transferred my C# strategy to Ninjatrader, but when I run the backtest, no orders are fired.
    I believe IB API events are not being called by Ninjatrader and so nothing happens in backtesting.


    I don't want to use Ninjatrader events, but I want to use IB API.
    I tried to use the Initializer method, but to no avail.

    My C# console application works fine, but the problem is how to backtesting.

    Can anyone help?

    Tks.

    #2
    Hello brunoviveiros,

    Welcome to the NinjaTrader support forums.

    The platform relies on you placing trades through the platform to be able to use the tools in the platform. To utilize the tools such as backtesting you would need to configure a connection in NinjaTrader for historical data or import data and then build a strategy in the correct way.

    The backtesting tools would need a full strategy which executes orders using NinjaScript methods, this includes the Managed or Unmanaged order methods:
    https://ninjatrader.com/support/help...er_methods.htm
    You can see the SampleMACrossOver that is included with the platform as an example of the structure/syntax.

    The platform is not expecting you to interface directly with the API so how you have it now would not be able to be used in the platform. You can use interactive brokers with NinjaTrader for data or trading but you would need to configure that as a connection to use it. After a connection is made you can use the NinjaScript methods to submit orders to the account. A connection is not required for backtesting, only imported historical data would be along with a strategy that is programmed correctly.
    https://ninjatrader.com/ConnectionGu...nnection-Guide

    I look forward to being of further assistance.

    Comment


      #3
      Thanks for the answer NinjaTrader_Jesse.


      I had already made the connection with Intercative Brokers as mentioned above.

      So in my case that I have my own C# application using the IB API to placing orders, (placeOrder () method), should I rewrite to a method recognized by Ninjatrader (EnterLong()) so that testing can be done? It is impossible to use Ninjatrader to place orders using IB API methods ?

      Thank you for your support.

      Comment


        #4
        Hello brunoviveiros,

        Correct you would need to make the code use the NinjaScript order methods, you cannot submit directly to the API from within the platform.

        For the testing tools like backtesting the orders are not being submitted to a broker, they are held locally so using the API is not relevant here.

        For realtime orders the platform is designed to use the existing connections and uses the Sim101 account for local testing. There is no expectation for users to interface with a data providers API directly. If you want to interface with the API directly you would need to use an external software however you would be unable to use NinjaTrader to do anything in that use case.


        Please let me know if I may be of further assistance.

        Comment


          #5
          Thank you for your support NinjaTrader_Jesse.

          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