No announcement yet.

Partner 728x90


Bars Request bug freezes chart updates

  • Filter
  • Time
  • Show
Clear All
new posts

    Bars Request bug freezes chart updates

    Weird BarsRequest bug, which causes a chart to stop receiving live data. I've attached a strategy.

    Steps to reproduce:

    - Open FXCM connection settings
    - Disable Ninjatrader historical servers
    - connect to FXCM
    - open a 1 minute Forex Chart
    - open output window
    - Add strategy to chart and click enable

    Observe output window, which prints "tick tick tick" for every new tick.
    Then prints "14 Daily bars been received for the ATR Calculation" - from the barsrequest handler. Then no more ticks. Observe that chart is no longer receiving live data. That chart will no longer receive data unless you quit and restart Ninjatrader.

    Repeat above steps for timeframe other than daily.... no issue. Repeat with Ninjatrader servers enabled... no issue.

    I'm literally having one of those weeks when I think a malicious individual has gained access to my computer and is f$cking with things to mess with me! I've done practically no work all week.

    Ninjatraders servers took 90 seconds to deliver bars requests all weekend and most of the start of the week. Switching to FXCM I get "cannot find instrument" errors.

    Ninja sorts out the performance issues but their historical data is clearly corrupted - gaps in the data everywhere and the whole of May is missing from the Forex dailys!!

    Switch back to FXCM and dodge the Instrument not found problem by deleting my whole cache folder every 5 minutes, and now this issue which freezes realtime data when a BarsRequest is made for daily data.

    What a nightmare!
    Attached Files
    Last edited by reach4thelasers; 10-01-2015, 02:20 AM.

    Was anybody able to reproduce this bug? Please apply the strategy to a chart with FXCM (not ninja) historical servers enabled. Does it freeze the chart?



      Thank you for providing the steps on this.

      I did run the strategy per your guide but was unable to re produce the same result. I see that OnMarketData was called and OnBarUpdate did get called as well.

      I would like to ask, are you only trying to get daily data into a strategy or what is the greater purpose of doing the bar request from the strategy? This specific segment of code was intended for getting data into an addon so I would like to better understand the purpose of this being in the strategy.

      In general for adding data to a strategy you would use AddDataSeries() to add additional data or increase the charts days to load for further historical data.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service


        I know that the code segment is related to an Addon but it can be used for Strategies and Indicators as well. AddDataSeries is restrictive in the amount of data that it pulls back. I really only need a few hundred bars of each timeframe. but If I add a few hundred dailly bars to a strategy that has a one minute series, then I need to load hundreds of thousands of one-minute bars to get all the day bars I need.

        Using a BarsRequest I can get a few hundred day bars and a few hundred one-minute bars individually - they are not tied together in any way that forces me to grab a whole load of data I don't require. It seems that where the primary chart series is minute and you make a BarsRequest for Days - the chart is then subsequently unsubscribed from the minute feed and no longer gets updates.

        Its a pretty consistent and reproducible bug for me. I don't understand why you can't reproduce this.


          We're still looking into and will get back to you.

          re: The comment about BarsRequest: we're just trying to understand how users are using this class/feature. The method name suggested to me you may be wanting to use this for an indicator calculation. If you want to use ATR() or any other methods, the bars request itself is not sufficient - but you can certainly run your own calcs from that bars data. For using the system indicator methods, AddDataSeries() would be the recommended approach. At any rate, just trying to better understand the real-world usage here, so thanks for any feedback.

          Also if you were not aware, the AddDataSeries() method now has an overload with a barsToLoad parameter:

          AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)
          MatthewNinjaTrader Product Management


            In order to calculate the wiggle room on my stop-loss orders, I need to know the 14-day Average True Range. I add 2% of the 14D ATR to my stop-loss estimate to account for general variations in volatility.

            I literally just need a single number computed from 14 daily bars. Doesn't matter if my main series is 30seconds 1 minute 5 minute. I only need one number.

            If I add 1-day series for 14 days, then my 30 second EURUSD chart I needs to load 2 x 60 x 24 x 14 = 40,320 bars. I simply don't need the loading time, processing time, or general sluggishness that happens with having 20 Ninjatrader charts open each with 40 thousand unnecessary bars.

            Based on feedback from NT7, I understand the BarsRequest class was exposed for use to help with scenarios like this, guidance given on several threads in this regard including this one:

            Its a great feature, and I'm using the BarsRequest method not just for this, but also for processing 2 other timeframes in addition to my need for those 14 daily bars.

            For some reason ( and this happens very consistently ). If I make a bars request for a Time Interval that is not the same as the main chart, the main chart stops getting updates.

            For example, if my main chart is minute-based and I BarsRequest for "days", my charts cease to receive updates for minutes data. If I then add a strategy that makes a BarsRequest for minutes to the frozen chart, the updates resume once more. If my chart is days and I add a strategy that makes a bars request for months then the days stop loading.

            Unfortunately Jason in the Dutch support team wasn't able to reproduce. And there are some other pretty consistent problems I've had which it seems that you guys can't reproduce.

            They only occur with an FXCM account receiving data from FXCM's servers (not the ninjatrader servers). I am at a loss to explain it.


              Thanks for the details, I appreciate it.

              Just an update, we were able to reproduce today with the details provided in the first post. Our QA team is running analysis and we'll report back either with a bug tracking number, or more information on what may be going wrong.
              MatthewNinjaTrader Product Management


                I am relieved that you were able to reproduce it, I was starting to think there was a problem with my workstation and was in the process of setting up an Azure Virtual Machine to try it out in a clean environment.

                Could you try running the attached strategy please. This one makes lots of BarsRequests for various timeframes. When using FXCM's historical servers and not Ninjatraders I get "Instrument Not Found" errors. Running the strategy repeatedly compounds the problem. Its like there is a concurrency problem which make the instrument inaccessible in some way.

                Deleting all the data from the cache folder usually fixes it until the next run.
                Attached Files


                Latest Posts


                Topics Statistics Last Post
                Started by Renorail, Today, 01:38 PM
                1 response
                Last Post Renorail  
                Started by BrianARice, Today, 01:16 PM
                0 responses
                Last Post BrianARice  
                Started by Ousher, Today, 09:08 AM
                0 responses
                Last Post Ousher
                by Ousher
                Started by Unsuitable, Today, 08:41 AM
                0 responses
                Last Post Unsuitable  
                Started by newdill, Today, 07:54 AM
                0 responses
                Last Post newdill
                by newdill