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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thank you for your support NinjaTrader_Jesse.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Irukandji, Today, 09:34 AM
          0 responses
          3 views
          0 likes
          Last Post Irukandji  
          Started by TraderBCL, Today, 04:38 AM
          3 responses
          24 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          11 responses
          1,423 views
          0 likes
          Last Post jculp
          by jculp
           
          Started by RubenCazorla, Today, 09:07 AM
          0 responses
          4 views
          0 likes
          Last Post RubenCazorla  
          Started by BarzTrading, Today, 07:25 AM
          2 responses
          29 views
          1 like
          Last Post BarzTrading  
          Working...
          X