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

Indicator that calculate in different chartime

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

    #16
    Hello ninjo,

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> myPlotLine
    {
    get { return Values[4]; }
    }

    There is no Values[4] in your script.

    You have not called AddPlot() 5 times and added 5 plots for there to be a [4] index with Values.

    There is only one call to AddPlot() and this would be Values[0].



    Also, the script has a data series added.

    You will need to make sure that CurrentBars[1] is greater than 1 and ensure the secondary series has a bar

    if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
    return;
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Yes, I forget change it. I had 5 plots in my original indicator.

      I added:

      Code:
      if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
      return;
      Its strange... works with

      Code:
      AddDataSeries(Data.BarsPeriodType.Minute, 60);
      but not with others times...


      I attached the new .cs

      Thank you !


      Attached Files

      Comment


        #18
        Hello ninjo,

        Are you still experiencing an error with this new file that we can assist with?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Yes, the error returned is:

          "A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state"

          but, this problem dont happend with SMA, or EMA indicator.

          Have you any indicator .cs with and example related to my purpose? I suppose it would be quicker to get, and less boring for you : )

          Thank you
          Last edited by ninjo; 02-19-2019, 12:21 PM.

          Comment


            #20
            Hello ninjo,

            This error means you are calling a hosted indicator that is using AddDataSeries() but you have not added the same series to the host indicator.

            From the help guide:

            "To maximize data loading performance, any NinjaScript object (indicator or strategy as host) which references a multi-series indicator which calls AddDataSeries must include it's own calls to AddDataSeries(). For example, if the code above was included in an indicator, and that indicator was referenced in a NinjaScript strategy, then the hosting strategy will need to include the same calls to AddDataSeries(). When the strategy adds the additional Bars objects, the calls to AddDataSeries() within the indicator will be ignored. If the Bars objects are not added by the strategy in such cases, and error will be thrown in the Log tab of the Control Center that would read - "A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.""



            You will need to also call the same AddDataSeries() call in the host script.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Ok Chelsea B, i am going to try it as you suggest.

              Thank you for the support!

              Comment


                #22
                I can't find why there is "Error on calling OnBarUpdate method on bar 200: Object reference not set to an instance of an object"
                Attached Files

                Comment


                  #23
                  Hello Parmenides48,

                  Thanks for your note.

                  "Object reference not set to an instance of an object"

                  The error message means that something in the script is returning null at the time you are accessing it. I see in the script you shared that you have not added debugging prints in your script to determine what the exact line of causing the error is.

                  Debugging steps would need to be taken to determine what exactly is returning null in your script.

                  Below is a link to a forum post that demonstrates using debugging prints to understand the behavior of a script.
                  https://ninjatrader.com/support/foru...121#post791121

                  Let us know if we may assist further.
                  Brandon H.NinjaTrader Customer Service

                  Comment


                    #24
                    This is a duplicate of https://forum.ninjatrader.com/forum/...ng-onbarupdate and it was already resolved there.
                    Bruce DeVault
                    QuantKey Trading Vendor Services
                    NinjaTrader Ecosystem Vendor - QuantKey

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Kaledus, Today, 01:29 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post Kaledus
                    by Kaledus
                     
                    Started by PaulMohn, Today, 12:36 PM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by yertle, Yesterday, 08:38 AM
                    8 responses
                    36 views
                    0 likes
                    Last Post ryjoga
                    by ryjoga
                     
                    Started by rdtdale, Today, 01:02 PM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by alifarahani, Today, 09:40 AM
                    3 responses
                    18 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X