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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X