Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsValidDataPoint and MaximumBarsLookBack256

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

    IsValidDataPoint and MaximumBarsLookBack256

    This help documentation says:

    Warning: Calling IsValidDataPoint() will only work a MaximumBarsLookBackInfinite series. Attempting to check IsValidDataPoint() MaximumBarsLookBack256 series throw an error.
    Meanwhile this forum page provides some examples which work for me in NinjaTrader 8 even when the indicators are set to MaximumBarsLookBack256.

    Specifically SampleEveryNBarTest contains this code:

    Code:
            protected override void OnBarUpdate()
            {
                /* Checks to see if the current bar has a valid indicator plot value set on indicator plot: Value. It is important to check this to know if the values you are
                 using are relevant or not. Using irrelevant values for your script logic can cause inaccurate calculations and trade signals. */
                if(!SampleEveryNBar(N).Value.IsValidDataPoint(0))
                {
                    // SampleEveryNBar does not have a valid indicator plot value. Set hosting indicator's plot to zero and paint the bar red.
                    BarBrushes[0] = Brushes.Red;
                    PlotBrushes[0][0] = Brushes.Red;
                    Value[0]= 0;
                }
                else
                {
                    // SampleEveryNBar does have a valid indicator plot value. Set hosting indicator's plot to this value and paint the bar blue.
                    BarBrushes[0] = Brushes.Blue;
                    PlotBrushes[0][0] = Brushes.Blue;
                    double val = SampleEveryNBar(N).Value[0];
                    Value[0] = val;
                }
            }
    And when I added to my chart, I used MaximumBarsLookBack256:

    Click image for larger version  Name:	Capture.PNG Views:	1 Size:	34.8 KB ID:	1054909

    Can you help clarify whether the documentation is wrong or misleading on this? Or specifically under what circumstances the maximum lookback becomes a problem?

    Thanks,
    Steve

    Last edited by Steve L; 04-20-2019, 01:58 PM.
    Steve L
    NinjaTrader Ecosystem Vendor - Ninja Mastery

    #2
    Hello Steve L,

    The example provided does not use a secondary data series or have any custom series.

    The primary series will always be MaximumBarsLookBack.Infinite and this is not possible to change.

    If a secondary series is added, that series must be Infinite to use IsValidDataPoint().
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    576 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X