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 Kaledus, Today, 01:29 PM
        4 responses
        11 views
        0 likes
        Last Post Kaledus
        by Kaledus
         
        Started by alifarahani, Today, 09:40 AM
        5 responses
        22 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PhillT, Today, 02:16 PM
        2 responses
        7 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Started by frankthearm, Yesterday, 09:08 AM
        14 responses
        47 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X