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

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 AaronKoRn, Today, 09:49 PM
    0 responses
    7 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Today, 08:42 PM
    0 responses
    9 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Today, 07:51 PM
    0 responses
    10 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,980 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Today, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X