Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Create a public series that doesn’t contain every bar

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

    Create a public series that doesn’t contain every bar

    Goal: Create a series that contains bar numbers but only if certain conditions exist (e.g. buyers bars or pivot points) that is accessible from other indicators.
    Example: Return the last bar number of a buyer’s bar (or pivot point)
    What I’ve tried:
    1. Creating a public series that’s only added to under certain conditions. But the compiler complains that it’s not set under all conditions (i.e. it needs a value for every bar).
    2. Creating a routine that searches for the last occurrence of a condition. For this one, I can’t figure out how to set it up.
    Does anyone have any ideas on how to solve this?
    Thank you for your time and help.
    Michael

    #2
    Hello Michael, thanks for your question.

    You can use a List<T> straight from C# for a custom list. If you want the list to be available to all other scripts, you would need to set the list up in a shared class like I demonstrate here:
    https://ninjatrader.com/support/foru...dsaddonexample

    A lot of the time, users will use a Series object, and just fill it with a sentinel value (like -1 or False) when their condition is not true.

    Note that we also have the Most Recent Occurrence method to use.

    Please let me know if you have any further questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    597 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    555 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X