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