Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar formation different when using IB vs. using SIM

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

    Bar formation different when using IB vs. using SIM

    Hi
    I have a strategy I tested using the simulator that trades based on the first 5 minute bar of the day. It uses the open price and the high and low of the first 5 minute bar of the day. It works fine when using the simulated feed and account.

    However when I connect to my IB account, the same code sends out trades as soon as it gets an open price. Why is there this difference in sim vs IB?
    Here is the code that detects bars
    Code:
                    if (BarsInProgress == 1)
                    {
                        if (!Period1Elapsed)
                        {
                            if (CurrentBar > 0)
                            {
                                                        Print(String.Format("Opening " + period1 
                                      + "Bar  Hi:{0} Lo:{1}", Highs[1][Bars.BarsSinceSession],
                                                        Lows[1][Bars.BarsSinceSession]) + "Bars since session " + Bars.BarsSinceSession);
                                Period1HighPrice = Highs[1][Bars.BarsSinceSession];
                                Period1LowPrice = Lows[1][Bars.BarsSinceSession];
                                if (Period1HighPrice != 0 && Period1LowPrice != double.MaxValue)
                                {
                                    Period1Elapsed = true;
     
                                    if(true)
                                    {
                                        HI = Period1HighPrice;
                                        LO = Period1LowPrice;
                                        STOP_PRICE = Period1LowPrice;
                                        Print(String.Format("{0} will use period 1 prices HI:{1} LO:{2}",
                                            Instrument.FullName.PadRight(5, ' '), Period1HighPrice, Period1LowPrice));
                                        //send trades if this is real time
                                        if (!Historical)
                                        {
                                              //SEND OUT BUY TRADE
                                        }
                                    }
                                }
                            }
                        }
                    }

    #2
    Additionaly I am using minute bars - days to load =1 and the BarsInProgresss=1 should mean 5 minute bars because this is what I do on initialize

    protected override void Initialize()
    {
    currentDate = DateTime.Now.Date;
    EntriesPerDirection = 2;
    Add(PeriodType.Minute, 5);
    Add(PeriodType.Minute, 15);
    CalculateOnBarClose = false;

    }

    Comment


      #3
      Hi psycho760,

      We're not aware of a an issue where NinjaTrader processes signals differently on a simulated feed compared to Interactive Brokers feed. If the conditions are true, then it processes the code block that follows, and it does this regardless of the feed.

      You're printing all values. Are they not calculating as you expect?

      Can you please send your log / trace files and indicate the date / time where you feel orders were placed incorrectly. Use help > mail to support feature. In the subject write Attn: RyanM 460635. Thank you.
      Ryan M.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      650 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      370 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      577 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X