Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Receiving incorrect data from secondary bars array

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

    Receiving incorrect data from secondary bars array

    Hello,

    I am getting incorrect ATR data which results in wrong strategy behavior.

    I am using following code to add daily instrument while my strategy runs on 1 min:

    Code:
    protected override void Initialize() {
    Add(PeriodType.Day, 1);
    }
    and for example on YM 09-14 I get

    Code:
    protected override void OnBarUpdate() {
    Print(Instrument.FullName + " " + Time[0].ToString() + " DAILY MAX: " + CurrentDayOHL().CurrentHigh[0] + " ATR: " + ATR(BarsArray[1],5)[0] + " ORDERSIZE: " + actualOrderAmount);
    }
    YM 09-14 9.7.2014 16:36:00 DAILY MAX: 16894 ATR: 12 ORDERSIZE: 5

    but If I look at the graph on daily I see that ATR(YM 09-14(Daily),5) is 91,51

    Any idea where the problem might be?

    Thanks.

    #2
    Hello fLife,

    Thank you for your post.

    This could be due to not having enough bars loaded before accessing the data. Meaning the calculations to build the ATR(5) over the daily bars, do not have enough data in the NinjaScript file. Yet on your daily chart, there are more than likely 365 days being loaded, so there is enough data to build the accurate value.

    Yet the ATR is only calling a 5 period, so this would only be 5 bars needed to plot the first value. Please add a check for the CurrnetBars[0] and CurrentBars[1] against 5, for example:
    Code:
    if(CurrentBars[0] <= 5 || CurrentBars[1] <= 5)
    return;
    You can find more information at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

    Comment


      #3
      Thanks. Is there any way to load additional historical data? Because I cannot wait few days with running strategy to get them.

      Comment


        #4
        Hello fLife,

        Thank you for your response.

        Please right click in the chart --> select Data Series --> set the DaysToLoad parameter to the desired number of days --> OK.

        For information on working with price data please visit the following link: http://www.ninjatrader.com/support/h...price_data.htm

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

        Comment


          #5
          Thanks for your quick reply. I have set daysToLoad for both chart and strategy to 10 days but it didnt help.

          CurrentBars[0].ToString() returns high number as expected but
          CurrentBars[1].ToString() returns 0.

          Comment


            #6
            Problem fixed by http://www.ninjatrader.com/support/f...ad.php?t=67384

            Comment

            Latest Posts

            Collapse

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