Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

object not initialized using Drawing tool

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

    object not initialized using Drawing tool

    I have seen the following error in the log:

    Error on calling 'OnBarUpdate' method on bar 64: Object reference not set to an instance of an object.


    debugging shows that it failed at this line in the strategy code:

    Draw.Line(this, "bphigh"+CurrentBar, true, bpphigh, prevlocalhigh, bphigh, prevlocalhigh, Brushes.DarkRed, DashStyleHelper.Solid, 2);

    This was working before with the previous beta release, now it did not work with NT v8 beta 10.

    What could be the cause of this problem?

    #2
    Hello rcfcu2000,

    The error indicates that something is null.

    What is the object that does not exist?

    Can you print the values of bpphigh, prevlocalhigh, bphigh,and prevlocalhigh?

    Do any of these have a null value?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I did more debugging in Visual Studio, it appears a null value in the following code:

      StackTrace " at NinjaTrader.NinjaScript.DrawingTools.Draw.DrawLine TypeCore[T](NinjaScriptBase owner, Boolean isAutoScale, String tag, Int32 startBarsAgo, DateTime startTime, Double startY, Int32 endBarsAgo, DateTime endTime, Double endY, Brush brush, DashStyleHelper dashStyle, Int32 width, Boolean isGlobal, String templateName) in
      c:\\Users\\xxxxxxxxxxx\\Documents\\NinjaTrader 8\\bin\\Custom\\DrawingTools\\@Lines.cs:line 777\r\n
      at NinjaTrader.NinjaScript.DrawingTools.Draw.Line(Nin jaScriptBase owner, Boolean isAutoScale, String tag, Int32 startBarsAgo, DateTime startTime, Double startY, Int32 endBarsAgo, DateTime endTime, Double endY, Brush brush, DashStyleHelper dashStyle, Int32 width) in
      c:\\Users\\xxxxxxxxxxx\\Documents\\NinjaTrader 8\\bin\\Custom\\DrawingTools\\@Lines.cs:line 983\r\n


      line 777 of @Line.cs is:
      startAnchor.SlotIndex = Math.Round(chartControl.GetSlotIndexByX(chartContr ol.GetXByBarIndex(chartBars, currentBar - startBarsAgo)));


      The chartControl object appears to be null. I am using the strategy analyzer to back test my strategy, there is no chart in this case. Maybe no chartControl object in this case?

      Comment


        #4
        Originally posted by rcfcu2000 View Post
        I have seen the following error in the log:

        Error on calling 'OnBarUpdate' method on bar 64: Object reference not set to an instance of an object.


        debugging shows that it failed at this line in the strategy code:

        Draw.Line(this, "bphigh"+CurrentBar, true, bpphigh, prevlocalhigh, bphigh, prevlocalhigh, Brushes.DarkRed, DashStyleHelper.Solid, 2);

        This was working before with the previous beta release, now it did not work with NT v8 beta 10.

        What could be the cause of this problem?
        I am having the exact same problem.

        My strategy is getting the error message at any Draw.Line code. When I "//" them, then the strategy works just fine.

        I have checked the variables and nothing is null.

        Here is an example:
        Code:
        Print("here 15" +" "+ BuyProfitTarget+" "+A_useFixedStopLoss +" "+ C_useFixedSLFromSwing  +" "+UseATRSLFromSwing  +" "+BuyStopLoss);
        			//	Draw.Line(this, "BuyTP"+k, false, 5, BuyProfitTarget, 0, BuyProfitTarget, Brushes.Green, DashStyleHelper.Dash,2);
        This error happens whether I am using the Draw.Line function in the strategy or even in an indicator that is called by the strategy. Put that same indicator on a chart, and there is no problem. Only when it is called by the strategy.

        Thanks,
        -Stearno

        Comment


          #5
          Originally posted by rcfcu2000 View Post
          I did more debugging in Visual Studio, it appears a null value in the following code:

          StackTrace " at NinjaTrader.NinjaScript.DrawingTools.Draw.DrawLine TypeCore[T](NinjaScriptBase owner, Boolean isAutoScale, String tag, Int32 startBarsAgo, DateTime startTime, Double startY, Int32 endBarsAgo, DateTime endTime, Double endY, Brush brush, DashStyleHelper dashStyle, Int32 width, Boolean isGlobal, String templateName) in
          c:\\Users\\xxxxxxxxxxx\\Documents\\NinjaTrader 8\\bin\\Custom\\DrawingTools\\@Lines.cs:line 777\r\n
          at NinjaTrader.NinjaScript.DrawingTools.Draw.Line(Nin jaScriptBase owner, Boolean isAutoScale, String tag, Int32 startBarsAgo, DateTime startTime, Double startY, Int32 endBarsAgo, DateTime endTime, Double endY, Brush brush, DashStyleHelper dashStyle, Int32 width) in
          c:\\Users\\xxxxxxxxxxx\\Documents\\NinjaTrader 8\\bin\\Custom\\DrawingTools\\@Lines.cs:line 983\r\n


          line 777 of @Line.cs is:
          startAnchor.SlotIndex = Math.Round(chartControl.GetSlotIndexByX(chartContr ol.GetXByBarIndex(chartBars, currentBar - startBarsAgo)));


          The chartControl object appears to be null. I am using the strategy analyzer to back test my strategy, there is no chart in this case. Maybe no chartControl object in this case?
          Yes, if a Strategy calls an Indicator, there will be no ChartControl. As a workaround, check for its non-nullity before you call the method. You can also always hide the method, or create another method, by using a private method that checks for nullity before calling the original method.

          I believe they may have omitted the check. Somewhere in this forum, NT says that they are aware of the issue and have fixed it in the next release.

          Comment


            #6
            Hello rcfcu2000,

            Thank you for letting us know this only happens when using the Strategy Analyzer.

            koganam is correct, this item is known and being tracked with ID# NTEIGHT-9605.

            I can also confirm that this has been corrected in the next Beta (NinjaTrader 8 Beta 11).
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Any idea when version 11 is being released? I use Draw in every strategy I build.

              I've been wanting tick-by-tick simulation since I started with NT7.
              Wonder how you got to ten versions before anybody backtested anything?

              Comment


                #8
                Originally posted by RichManInTraining View Post
                Any idea when version 11 is being released? I use Draw in every strategy I build.
                They have never said when a release will be and that surely won't change. (Ok - they did once say "later in the day" if I remember correctly).

                They are about 1 release every 5 weeks on average...



                So it should be pretty soon? (this week or next?)



                Originally posted by RichManInTraining View Post

                Wonder how you got to ten versions before anybody backtested anything?
                It's been a very difficult BETA. Hopefully you can find some bugs too.

                Comment


                  #9
                  Hello RichManInTraining,

                  There is not an estimated date or time that the Beta 11 update will be released at this time.
                  Last edited by NinjaTrader_ChelseaB; 05-23-2016, 07:46 AM.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hey, got B11 now that it is released, and no more object errors!

                    Draw.Text is working fine, but I cannot see and lines when I use Draw.Line:

                    Draw.Line(this,"High"+CurrentBar,30,ThirtyMinuteHi gh,0,ThirtyMinuteHigh,Brushes.Green);

                    Am I doing it wrong? I have tried squishing the chart down to nothing, and I do not see the lines anywhere.

                    Comment


                      #11
                      Hello RichManInTraining,

                      Try the following call on the first line of OnBarUpdate.
                      Code:
                      if (CurrentBar > 30)
                      	Draw.Line(this, "myLine", true, 30, High[0] + 3 * TickSize, 0, High[0] + 3 * TickSize, Brushes.Green, DashStyleHelper.Solid, 2);
                      This will draw the line with the auto scale on and will draw 3 ticks above the current bar.

                      Are you able to see this line on your chart?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        That works, thanks!

                        I kept all the other parameters the same, and my lines were right at local high/lows, so the Draw.Line signature I was using apparently does not work, but I like yours better anyhow with AutoScale, but did not know how to set the line style.

                        Comment


                          #13
                          Hi RichManInTraining,

                          Below is a link to the help guide on Draw.Line() that shows the different overloads that can be used with this method.
                          http://ninjatrader.com/support/helpG.../draw_line.htm
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by alifarahani, Today, 09:40 AM
                          3 responses
                          15 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by RookieTrader, Today, 09:37 AM
                          4 responses
                          18 views
                          0 likes
                          Last Post RookieTrader  
                          Started by PaulMohn, Today, 12:36 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post PaulMohn  
                          Started by love2code2trade, 04-17-2024, 01:45 PM
                          4 responses
                          40 views
                          0 likes
                          Last Post love2code2trade  
                          Started by junkone, Today, 11:37 AM
                          3 responses
                          26 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X