• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Dataseries variable

  • Filter
  • Time
  • Show
Clear All
new posts

    Dataseries variable


    I have a dataseries variable that I am getting very odd behavior with. I looked at it using the Visual Studio debugger and doing a quick watch looked at the series.

    Not only am I getting odd results, it appears that somehow this variable is associated with an ADX indicator. This is stand alone code, has no indicators and I have never used ADX in my life.

    The declaration

    private DataSeries xOpen;
    xOpen =
    new DataSeries(this);

    I have obviously done something wrong but any ideas as to where I can even start?

    Unfortunately this is proprietary code and the above is all I am can share. This code was copied from an indicator I developed and with the exception of the adjustment to the index to work in FirstTickOfBar nothing is changed (famous last words).

    An additional question - I put a test in OnMarketData to return if the tick was associated from BarsInProgress = 1 (a different timeframe of the same symbol), is that necessary to avoid processing the same tick twice (once for each series)?


    Hello Scott,

    The syntax looks right for declaring and instantiating a DataSeries. One thing to check is to make sure it's instantiated within Initialize() method for the indicator you're working with.

    What weird results are you having with it?

    OnMarketData() will be unique per instrument. There's no need to have a BIP check unless your second series is another instrument.

    Ryan M.NinjaTrader Customer Service



      Good deal relative to OnMarketData; I had hoped NinjaTrader was designed that way. The weird results are that although I set xOpen[1] to some variable e.g. Open[1] on each bar, I do not then see that value as xOpen[2] on the next bar.

      My understanding is that what is xOpen[1] this bar would be xOpen[2] next bar. If that isn't correct, oops on my part.

      When I use the quick watch in Visual Studio to look at xOpen it has the usual stuff but then it has information relative to what appears to be an ADX indicator. I am probably not looking in the right place but somewhere I would expect to see a series of values.

      Is a data series variable attached to something else like a bars array or something? I know I am not being overly clear but this is the best I can do. Can you tell me where I should be looking if I do a quick watch for a data series variable?



        Yes, values should be relative to bars. DataSeries are synced to every bar. They work similar to plots except there's no visual.

        I'm not familiar with quick watch. I suggest printing the values or setting a plot based off the DataSeries to see what it is returning.
        Ryan M.NinjaTrader Customer Service


          Ryan, thanks for those ideas, especially using a plot (I never thought of doing that). I can handle things from here (famous last words, see post below).

          Last edited by ScottB; 09-29-2010, 07:29 AM.


            I have been working with this issue for a while now and I must say, I am really perplexed.

            I have a multi time frame strategy calling a UserDefinedMethod passing in a dataseries by reference. I am doing this because it appears the UserDefinedMethod cannot instantiate a dataseries.

            I am trying to get this to work with something very simple. Put the Open of the second time frame (index 1) into a data series variable on the first tick of the second data series at 1 position back because I want the open of the bar just completed. The primary data series is a 1 minute chart.

            test.Set(1, Opens[1][1]);

            Print("Test " + test[1].ToString() + " " + test[2].ToString() + " " + Time[1].ToString());

            I get the following

            test 1.3459 1.3474 9/28/2010 7:55:00 AM
            test 1.3467 1.3473 9/28/2010 8:00:00 AM
            test 1.3465 1.3468 9/28/2010 8:05:00 AM
            test 1.3479 1.3468 9/28/2010 8:10:00 AM

            The proper Open is printed for test[1] (the first price) but while I would have expected test[2] to print the open 1 bar further back i.e. the second number on the 8:10 line to be 1.3465 as opposed to 1.3468. The value 1.3468 matches nothing I can align with anything but it is certainly not the Open of two bars back. I even checked all the intervening 1 minute opens and those values are nowhere to be found.

            I obviously have some fundamental understanding of some part of this process. Can you point me to where I might be going wrong? I ended up using print statements rather than a plot (Ryan's suggestion from above) because it seemed easier.

            Thanks in advance
            Last edited by ScottB; 09-28-2010, 09:21 PM.


              Scott, can you please confirm which timeframes you're working with here? The dataSeries object for the added timeframe would need synching to properly react to your [index] - ing - http://www.ninjatrader.com/support/f...ead.php?t=3572
              BertrandNinjaTrader Customer Service


                Bertrand, the primary timeframe is 1 minute (although I have tried several) and the secondary is always 5 minutes. I will also review the link you sent me.

                Thanks for your help.


                Latest Posts


                Topics Statistics Last Post
                Started by Rastus, Today, 10:27 PM
                0 responses
                Last Post Rastus
                by Rastus
                Started by kloiuyvcp, Today, 09:54 PM
                0 responses
                Last Post kloiuyvcp  
                Started by WNorton, Today, 06:53 PM
                0 responses
                Last Post WNorton
                by WNorton
                Started by Jorge.andres.o, Today, 03:44 PM
                1 response
                Last Post bltdavid  
                Started by r3n3v, Today, 06:30 PM
                1 response
                Last Post r3n3v
                by r3n3v