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

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 :

    BertrandNinjaTrader Customer Service

    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 :

        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Stanfillirenfro, Yesterday, 09:19 AM
        7 responses
        51 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by TraderCro, 04-12-2024, 11:36 AM
        4 responses
        69 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Mindset, Yesterday, 02:04 AM
        1 response
        15 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by agclub, 04-21-2024, 08:57 PM
        4 responses
        18 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Irukandji, Today, 04:58 AM
        0 responses
        6 views
        0 likes
        Last Post Irukandji  
        Working...
        X