Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 DJ888, 04-16-2024, 06:09 PM
    6 responses
    18 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    1 view
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    6 views
    0 likes
    Last Post Javierw.ok  
    Started by timmbbo, Today, 08:59 AM
    2 responses
    10 views
    0 likes
    Last Post bltdavid  
    Started by alifarahani, Today, 09:40 AM
    6 responses
    41 views
    0 likes
    Last Post alifarahani  
    Working...
    X