Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Arrays of DataSeries

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

    Arrays of DataSeries

    Is the above legal? I am having problems with the "Object reference not set to an instance of an object" even though I set variable and initialize it
    public class MM : Indicator
    {
    #region Variables
    #endregion

    public DataSeries[] BB;
    int[,] McM;// = new int[4,3];
    private double[] dMACDS;

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {


    int[,] McM= {{12,26,10},{31,68,26},{51,110,42},{6,13,5}};


    BB[4] = new DataSeries(this);
    etc

    #2
    DLatNT, unfortunately arrays / arraylists (later are easier to maintain) are more general C# topics and thus outside of the scope that we can offer support here for. BB is either a NinjaScript DataSeries object or an array but not both. Also DataSeries should be exposed using those techniques here :

    Comment


      #3
      Thanks Josh.
      So if I use any arrays in a variable declaration and then initialize it in Initialize() I still get that Object error. The only way I can avoid it is by putting this code to initiliaze in OnBarUpdate(). Is this correct? This is very unusual setup? My programming skills are rusty but this very basic staff.
      Can you point me to a solution? You should have a debugger.

      Comment


        #4
        You would need to ensure you include checks for access while the array / object is null / emtpy, this should not happen. If it works for you in OnBarUpdate(), then try moving this code section to OnStartUp() in NT7 : http://www.ninjatrader.com/support/h.../onstartup.htm

        For professional debugging, please check into using Visual Studio in connection with NT :

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        612 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        355 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        561 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        564 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X