Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsToLoad not preserved in chained indicator additional BarsArray

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

    BarsToLoad not preserved in chained indicator additional BarsArray

    Hi,

    I want to pass along a situation and workaround that can happen when loading additional MultiBarArray's.

    When a chart is configured to contain an Indicator A whose source is another Indicator B whose source is Instrument I. And if Indicator B calls AddDataSeries(), then "BarsToLoad" for that series appears to be forever locked to the initial value of Instrument I's BarsToLoad.

    The problem comes along if the BarsToLoad is increased using the Chart Control. When that happens the BarsArray[1] within Indicator B does not load enough bars. The workaround below appears to be working but I'm not sure that "PriceSeries.Count" is the best way to determine the value of BarsToLoad that was set within the interface.

    A better fix may be for NT8 to preserve the "BarsToLoad" within Indicators that are sources of other Indicators, especially when additional DataSeries() are added.

    Hope this can help someone else or encourage a fix,

    Thanks,
    Chris


    case State.Configure:
    BarsRequiredToPlot = 1;

    // If an indicator is used as source for another indicator, and then later on
    // the BarsToLoad is increased for the original instrument, The AddDataSeries() below and
    // BarsToLoad in this indicator fail to track the BarsToLoad change.
    //
    int? forceBarsToLoad = null;
    string tradingHours = null;

    PriceSeries priceSeriesInput = Input as PriceSeries;
    if (priceSeriesInput.Count > BarsToLoad)
    {
    forceBarsToLoad = BarsToLoad = priceSeriesInput.Count;
    tradingHours = priceSeriesInput.Bars.TradingHours.Name;
    }

    string partnerInstrument = "^DECL"; // assumes main instrument is "^ADV"

    BarsPeriod barsPeriod = new BarsPeriod() { BarsPeriodType = BarsPeriod.BarsPeriodType, Value = BarsPeriod.Value };

    if (forceBarsToLoad.HasValue)
    {
    if (tradingHours == null)
    tradingHours = "US Equities RTH";

    AddDataSeries(partnerInstrument, barsPeriod, forceBarsToLoad.Value, tradingHours, false); // BA[1]
    }
    else
    {
    AddDataSeries(partnerInstrument, BarsPeriod.BarsPeriodType, BarsPeriod.Value); // BA[1]
    }

    break;
    Last edited by crokusek; 01-05-2018, 11:27 AM. Reason: remove code that wan't related

    #2
    Hello crokusek,

    Thank you for your post.

    I will review this further on my end and follow up with you when I have any details.

    Comment


      #3
      Hello crokusek,

      Thank you for your patience.

      Your workaround may suffice but would not be recommended as the Bar Series parameters should not be dynamically set including the BarsToLoad.

      There a open feature request to have this behavior changed to allow the secondary series to use it's own BarsToLoad rather than the primary series. I have forwarded your thread to our development team to add a vote to this item under the internal tracking id of SFT-2823.

      Please let me know if you have any questions.

      Comment


        #4
        Hi Patrick,

        Another issue is showing up on the second day. The BarsArray[1] start and end dates show a lag with respect to BarsArray[0]. For example right now at 9:40 I'm seeing about 35 bars skew on a 5 minute chart which corresponds closely to the time since the open. More simply BarsArray[1] is just not loading fresh data

        Recall this is a case of an inner indicator feeding an indicator. The inner indicator is loading the extra series.

        Here are the debug's of the FromDate's and Count.

        DataLoaded. From Date / Count
        BarsArray[0] = 11/28/2017 12:00:00 AM / 2201,
        BarsArray[1] = 11/27/2017 12:00:00 AM / 2201
        priceSeries = 11/28/2017 12:00:00 AM / 2201

        Is there some way for me to programatically adjust that FromDate to match?

        Thanks,
        Chris

        Comment


          #5
          Hello crokusek,

          Thank you for your response.

          There is no means to force the date on the bar series.

          You could call Update() on the hosted indicator in the hosting indicators OnBarUpdate() method to keep the data up to date. - Update(): https://ninjatrader.com/support/help...-us/update.htm

          Please let me know if this corrects the bar series.

          Comment


            #6
            Hi Patrick,

            It looks like the underlying cause is actually the "To" date of the inner indicator which a day behind and stuck to the date when the indicator was created:

            this.To = 1/8/2018 12:00:00 AM, priceSeries.Bars.ToDate = 1/9/2018 12:00:00 AM

            If I run the following within State.Configure it fixes it for all F5 refreshes but then over time it starts losing bars (will look into tomorrow).

            this.To = priceSeriesInput.Bars.ToDate;

            I'm guessing even calling update() won't pull more bars since the "To" is stuck but I will try it tomorrow along with any other ideas.

            Thanks,
            Chris
            Last edited by crokusek; 01-10-2018, 03:51 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by thread, Yesterday, 11:58 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by stafe, Yesterday, 08:34 PM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by jclose, Yesterday, 09:37 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by firefoxforum12, Yesterday, 08:53 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by kmunroe478, Yesterday, 05:39 PM
            2 responses
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X