Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SMA of custom DataSeries

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

    SMA of custom DataSeries

    I have created a DataSeries from Daily Pivots and want to plot an average of the dataseries but am getting the below errors below,

    Indicator\MyCustomIndicator.cs The best overloaded method match for 'NinjaTrader.Data.DataSeries.Set(double)' has some invalid arguments

    Indicator\MyCustomIndicator.cs Argument '1': cannot convert from 'NinjaTrader.Indicator.SMA' to 'double'

    I have attached the code.
    Attached Files

    #2
    GKonheiser, any value you wish to plot would be a double.

    PPAvg.Set(SMA(ppDS, 7));

    In this call here try to set a series to be a plot, as the SMA per default would return the series and not a double value where you point to an index of the series to access.

    Comment


      #3
      Ah, but when I try,

      PPAvg.Set(SMA(ppDS[0], 7));

      I also get errors, or am I misunderstanding you?

      Comment


        #4
        Yes, you are. You would need to get a double value of your SMA, not the ppDS series. As the SMA internally expects to get a series passed, so your ppDS.

        PPAvg.Set(SMA(ppDS, 7)[0]);

        Comment


          #5
          OK got that, that great thanks.

          When I use,

          if(ppDS == null) // Only to sync the ppDS DataSeries to Day Bars
          {
          ppDS = new DataSeries(SMA(BarsArray[2], 2));
          }

          to link the ppDS DataSeries with day bars, does it specifically link to the Symbol and expiry of the chart, ie FGBL 06-13?

          As when I load my indicator I have no values untill the 06-13 expiry become front month?

          Comment


            #6
            It would not link to a specific expiry, however the bars required would apply to all your series. So with a default of 20, would mean 20 days will pass before OnBarUpdates are processed.

            Comment


              #7
              I have bars required set to 2 and am getting a strange result on the indicator, see attached chart
              Attached Files

              Comment


                #8
                What merge policy used when you access this current non front month of the Bunds?

                Comment


                  #9
                  Merge non-back adjusted

                  Comment


                    #10
                    If you merge it with the NT default rolldates, please use the FGBL 12-13 currently as frontmonth. Would that improve the outcome seen? If not I would suggest debugging all values that contribute to arriving at your final values for display.

                    Comment


                      #11
                      I fixed the that problem. Removed min bars and seems to be OK now apart form at the beginning of the chart where the indicator is starting at 0, see attached. I tried to remedy this by setting barsRequired to the indicator period but didn't help??
                      Attached Files

                      Comment


                        #12
                        GKonheiser, I would just call .Reset method on your plot series to not set a value then for those bars until you have enough to properly calculate.

                        Comment


                          #13
                          Found the problem, I forgot to account for bars required for the underlying Data Series. Added additional check. : )

                          Thanks very much for your help today.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          574 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          332 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          101 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          553 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          551 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X