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

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.
    BertrandNinjaTrader Customer Service

    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]);
        BertrandNinjaTrader Customer Service

        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.
            BertrandNinjaTrader Customer Service

            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?
                BertrandNinjaTrader Customer Service

                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.
                    BertrandNinjaTrader Customer Service

                    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.
                        BertrandNinjaTrader Customer Service

                        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 gbourque, Today, 06:39 AM
                          0 responses
                          0 views
                          0 likes
                          Last Post gbourque  
                          Started by cmtjoancolmenero, Yesterday, 03:58 PM
                          1 response
                          17 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by benmarkal, Yesterday, 12:52 PM
                          3 responses
                          23 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by helpwanted, Today, 03:06 AM
                          1 response
                          20 views
                          0 likes
                          Last Post sarafuenonly123  
                          Started by Brevo, Today, 01:45 AM
                          0 responses
                          12 views
                          0 likes
                          Last Post Brevo
                          by Brevo
                           
                          Working...
                          X