Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dataseries question

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

    Dataseries question

    Hi,
    i have an issue using a dataseries in onmarketdata.

    code looks something like this:

    if (e.MarketDataType == MarketDataType.Last)
    {
    dataseries[0] += volume;
    }
    the amount with which the dataseries value on each event is increased seems alright, but the starting value is not zero but some ridiculous value. or stated otherwise when dataseries[0] should be zero, or not yet have a value, its actually 14000(maybe the first onmarketdata event) or something, after that it increases the value as its supposed to, I do not see whats wrong.

    thanks

    #2
    Hello,

    Thank you for reporting the issue to us. Do you have a complete (and simplified) script that you can share, so that I can trace how the data series is instantiated and everything that occurs with it throughout the code?
    Dave I.NinjaTrader Product Management

    Comment


      #3
      public class DataSeriesIndicator : Indicator
      {
      private Series<double> DataSeries;

      else if (State == State.Configure)
      {
      DataSeries = new Series<double>(this);
      }

      protected override void OnMarketData(MarketDataEventArgs e)
      {
      if (e.MarketDataType == MarketDataType.Last)
      {
      DataSeries[0] += e.Volume;
      }
      }
      }

      thats pretty much all, where its mentioned. if I print from onmarketdata, i get the screwed values.

      Comment


        #4
        keepsimple,

        Thank you for your response.

        We will test this on our end and follow up with any details we have.

        Comment


          #5
          thanks in advance

          Comment


            #6
            Hi Keepsimple,

            After a quick look here, you may be added a value to a non-valid data element.

            Before you add, you should do something like this:
            if (dataseries.IsValidDataPoint(0))
            dataseries[0] += volume;
            else
            dataseries[0] = volume;

            Try that, so now the first entry into dataseries[0] is the volume and only added to if it is valid.

            Comment


              #7
              Hello keepsimple,

              So I can replicate, what instrument and time frame and bar type are you testing this on. Also, can you provide the code segment that shows your print statement.

              In testing I've done, I see the 1st tick of bar, in OnMarketData showing typically a value of 1 and accumulating until a new bar (Tested on 1 minute TF 03-16).
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                was ES 5 Range Bar.

                Print Statement:
                Print(DataSeries[0] + " " + CurrentBar + " " + e.Volume);

                Comment


                  #9
                  tried NJA_MC s suggestion, looks way better now. need to test that, but the ridiculous values are gone now. need to check for correctnes, but this might have been the issue.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by maybeimnotrader, Today, 05:46 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post maybeimnotrader  
                  Started by quantismo, Today, 05:13 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post quantismo  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  8 responses
                  166 views
                  0 likes
                  Last Post jeronymite  
                  Started by cre8able, Today, 04:22 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post cre8able  
                  Started by RichStudent, Today, 04:21 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post RichStudent  
                  Working...
                  X