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

Problem with adding plots

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

    Problem with adding plots

    Greetings,

    Can I get an explanation as to why I cannot add variables/plots to my indicators? Although it compiles there is no plot being made...

    #region Variables
    double VSLOPE; double VSLOPE2; double VSLOPE_DIFF; double VSLOPE_ROC;
    #endregion
    protectedoverridevoid Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "ROC"));
    }
    protectedoverridevoid OnBarUpdate()
    {
    VSLOPE = TRENDSLOPE[0]; VSLOPE2 = TRENDSLOPE[1]; VSLOPE_DIFF = Math.Abs(VSLOPE - VSLOPE2); VSLOPE_ROC = Math.Abs(VSLOPE_DIFF / VSLOPE2);
    ROC.Set(VSLOPE_ROC);
    }

    Any explanation would be GREATLY appreciated, it is very frustrating to not have these plots and not know why...

    #2
    Not sure what TRENDSLOPE[] is, but check your logs for errors. Use print functions to debug at each step.

    You will also most likely need to watch out for division by 0.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Does your ROC have a DataSeries?

      Do you have something like this in your code?

      #region Properties

      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries ROC
      {
      get { return Values[0]; }
      }

      #endregion

      Comment


        #4
        Thanks for the replies. Yes I do have the commands in the Properties similar to as shown. What is a "Plot method: Overflow Error"??

        Is there a way to have Plot info display in the "Data Box" however NOT PLOT on the indicator display itself? I simply want a quick and easy way to view the data values, not necessarily anything displayed visually...I'm trying to plot the data for 1 plot but only display the values in the Data Box for another...

        Comment


          #5
          >> "Plot method: Overflow Error"
          Where have you seen this.
          a) on a NT standard indicator? which one or
          b) on a custom indicator? or
          c) on a custom indicator where you have overwitten the Plot() method?

          Comment


            #6
            Hi,

            On a custom indicator where I have added a Plot() method, not overwritten...the original Plot() is still there. The error is in the log.

            Comment


              #7
              - can you reproduce this issue in the logs?
              - are you on latest 6.5.1000.1?

              Comment


                #8
                Yes on both questions.

                Comment


                  #9
                  Originally posted by Burga1 View Post

                  protected override void OnBarUpdate()
                  {
                  VSLOPE = TRENDSLOPE[0]; VSLOPE2 = TRENDSLOPE[1]; VSLOPE_DIFF =
                  I suspect that the solution is that you need to add the following before you attempt to access "[1]"...

                  Code:
                  if (CurrentBar < 1) return;

                  Comment


                    #10
                    Yes, I have such a condition already. Here is the complete code within OnBarUpdate:

                    if(CurrentBar < 50){return;}
                    Print(Time[
                    0].ToString()); Print("Current CurrentBar = " + CurrentBar);

                    TRENDSLOPE.Set(Slope(FIBTREND(
                    1).Middle, 2, 0));
                    //VSLOPE = TRENDSLOPE[0]; VSLOPE2 = TRENDSLOPE[1]; VSLOPE_DIFF = Math.Abs(VSLOPE - VSLOPE2);
                    //VSLOPE_ROC = Math.Abs(VSLOPE_DIFF / VSLOPE2); ROC.Set(VSLOPE_ROC);

                    The above works fine with everything commented out as displayed. When I "uncomment" those lines that causes the "re-producable" error in the log about the Overflow...

                    Comment


                      #11
                      When VSLOPE2 == 0 it would cause an overflow. divided by 0.

                      Comment


                        #12
                        Well, when all else fails, you can always open the Output window and just pepper your code with Print statements.

                        But it sounds like you need to do this in your Plot() method.

                        If you add the Print statements and open your Output window, it will become obvious what's going on (or at least what statement is objectionable). This is generally just a 5 to 10 minute exercise, start to finish.

                        Comment


                          #13
                          divide by 0 errors normally appear in the log...do they not? I know I've seen them before there so I assume they always do so.

                          Comment


                            #14
                            Divide by zero would display an error in the log... if it gets that far.

                            What I would do is this: put in some Print statements and see.

                            It's less typing to put in a Print statement than to answer this post!

                            Comment


                              #15
                              Originally posted by Burga1 View Post
                              Yes on both questions.
                              Great. Please send this info to "christian AT ninjatrader DOT com" and refer to this post:
                              - your custom indicator in question
                              - your zipped DB (e.g. by Help->Mail to support)
                              - which instrument is this?
                              - which indicator settings have you applied?

                              Thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              167 responses
                              2,260 views
                              0 likes
                              Last Post jeronymite  
                              Started by warreng86, 11-10-2020, 02:04 PM
                              7 responses
                              1,361 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Perr0Grande, Today, 08:16 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Perr0Grande  
                              Started by elderan, Today, 08:03 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post elderan
                              by elderan
                               
                              Started by algospoke, Today, 06:40 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post algospoke  
                              Working...
                              X