Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Please help me create a Series<T> of a custom data type

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

    Please help me create a Series<T> of a custom data type

    Hi there,
    I want to create a Series<T> of custom data type for use in multiple time intervals. It's tracking some data points on a Daily, a 240-minute, and a 15-minute chart. Please see the bold red text below. Specifically the first line or bold red text. I'm not doing it correctly (duh), and for the life of me I cannot find the correct syntax. Can I declare a Series where I'm trying to so when I run the indicator it doesn't throw an "Indicator 'MarketStructure': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object." error?
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class MarketStructure : Indicator
    {
    Series<TimeFramePoints> HTF = new Series<TimeFramePoints>; // <-- THIS LINE IS BORKED
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    ...
    }
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Minute, HighTimeframe); // BarsInProgress index = 1
    }
    else if (State == State.DataLoaded)
    {
    HTF = new Series<TimeFramePoints>(BarsArray[2]);
    }​

    #2
    Hello Nate G,

    Creating an instance of a Series<T> cannot be done in the scope of the class.

    Just declare the variable and create the instance in State.DataLoaded as your are.

    private Series<TimeFramePoints> HTF;

    in State.DataLoaded:
    HTF = new Series<TimeFramePoints>(BarsArray[1]);

    I put BarsArray[1] to synchronize to that data series as there is no BarsArray[2] in your suggested code.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    230 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    149 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    161 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    243 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    198 views
    0 likes
    Last Post CarlTrading  
    Working...
    X