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

exposing the wavetrend indicator for strategy builder

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

    #31
    Hello ezrollin,

    I'm not sure I understand, the CrossDetectionForMarketAnalyzerExample_NT8 example provided has everything necessary to return a Values[plot series] added with AddPlot(). Nothing else is necessary.

    Can you clarify what is missing from this example?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #32
      Ok, I found that CrossDetection script you just mentioned. I was talking about https://ninjatrader.com/support/foru...tch?id=1183110 the PublicSeriesDoubleTest.

      In my script. I added the plot. When I change it to a color (from transparent) it doesnt mess up my upper chart like it should (cause it would conflict with the price candles in the upper).
      Price = ~ 16500
      My reversal plot would be ...,1,0,-1,....
      It doesnt plot anything like it should (even though I want to keep it transparent) this just proves its not working right.

      These are my only changes to the script:
      Code:
           private Series<double> reversal;           //   at the beginning of the class
      
      AddPlot(Brushes.Transparent, "Reversal Plot");      //   to expose the indicator to strat builder, its the 3rd plot
      
      else if (State == State.DataLoaded)
      {
      reversal = new Series<double>(this);        // in SetDefaults
      }
      
      reversal[2] = 0;                             //  reset to 0 on start at beginning of OnBarUpdate,  2 because its the 3rd plot
      
      reversal[2] = reversal[2]++;                       //    on my true condition
      
      reversal[2] = reversal[2]--;                       //   on my false condition
      
      
      [Browsable(false)]              //  in my properties
      [XmlIgnore()]
      public Series<double> Reversal
      {
      get { return reversal; }
      }
      So what is wrong with my additions????? thanks


      Comment


        #33
        Hello ezrollin,

        The example was linked back in post# 4 and is a working example with the answer to your question as my first post.

        A transparent plot would not be visible on a chart. Are you printing the values?

        I'm not seeing anywhere in your code where Values[0] is being returned or being set. Are you setting the plot series as demonstrated in the example?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #34
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello ezrollin,

          The example was linked back in post# 4 and is a working example with the answer to your question as my first post.

          A transparent plot would not be visible on a chart. Are you printing the values?

          I'm not seeing anywhere in your code where Values[0] is being returned or being set. Are you setting the plot series as demonstrated in the example?
          Maybe I wasnt clear. I said I was only changing the color of the plot to see if anything was being spit out by the indicator. I wanted it transparent once I can see it works.
          I am scared to use value or values because I dont know if it'll conflict with something else labeled value, values or something else.

          So I changed all my reversal stuff to be exactly like the CrossDetection script but even as just an indicator it doesnt plot anything, in fact it messed up the original indicator (so something is conflicting):

          Heres the only stuff I transfered:

          Code:
          AddPlot(Brushes.Transparent, "SignalPlot");    // in SetDefaults  (3rd plot)
          
          Value[2]    = 0;    //  At the first of OnBarUpdate so we start in a reset condition
          
          Value[2]    = 1;  // on true conditon
          
          Value[2]    = -1;  // on false condition
          
          [Browsable(false)]
          [XmlIgnore]
          public Series<double> SignalPlot
          {
          get { return Values[0]; }
          }
          This is all the stuff I see to transfer over.
          Do I need to add in the Triggered boolean stuff? thanks

          Comment


            #35
            Hello ezrollin,

            The example sets a value on every bar. Are you setting a value on every bar or only when the conditions are true?

            If the plot is transparent, nothing will show on a chart. For a plot to show on a chart, two bars must have a value in a row.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #36
              hmm... I'm thinking that Values[0] in the properties should not be 0, maybe 2?
              I just now caught that error

              I'm not exactly sure what you mean so I'm just gonna guess you mean:

              in OnBarUpdate()
              Code:
              if (CurrentBar < 1)   //OnStartup
              (assign 0 to reset it)

              Code:
              if (CurrentBar > 1)
              (assign a value to the bar)

              I'm not sure how I could not be assigning a value to every bar since OnBarUpdate will do it for me every cycle?
              I'll have to look more. thanks
              Last edited by ezrollin; 12-31-2021, 12:24 AM.

              Comment


                #37
                Hello ezrollin,

                What Chelsea had meant was that for the plot to be continuous you need to set a value each time OnBarUpdate is called. OnBarUpdate is called for each bar so as long as you set any value to the Value[0] each time OnBarUpdate is called that would be a continuous plot. Your condition in the latest post would allow for a continuous plot.

                If you don't want to change the existing logic but just want to expose a signal you need to add a new plot of your own and then set that plot to the values you wanted during a condition. For example you set it to 0 always at the beginning of OnBarUpdate and then in some conditions you can change the value to 1, 0, -1 etc. As long as the plot is continuous another script can read those values to make conditions based on the indicator plot value.

                JesseNinjaTrader Customer Service

                Comment


                  #38
                  I know this is a bit off subject but could anyone help me with coding the WaveTrendV2 indicator so that Crossover Paintbar going up, also has the bodies painted? Currently on line 262 it shows "// Written for Candle charts - Up Candles paint the bar outline and Down Candle bodies are painted".

                  Thanks for any help you can provide.

                  Comment


                    #39
                    Code:
                    private Series<double> reversal;  
                    AddPlot(new Stroke() { Brush = Brushes.Transparent, Width = 1, DashStyleHelper = DashStyleHelper.Solid }, PlotStyle.Dot, "Reversal");   
                    REMOVED THE STATE.DATALOADED stuff
                    reversal[0] = 0  // on first bar
                    reversal[0] = 1   // on true condition
                    reversal[0] = -1  // on false condition
                    
                    [Browsable(false)] //
                    [XmlIgnore()]
                    public Series<double> Reversal
                    {
                    get { return [B]Values[2][/B]; }
                    }
                    I realized that this would be the correct way to do it.
                    However I'm having errors in setting any of the bars.
                    Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.
                    Error on calling 'OnBarUpdate' method on bar 2: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
                    Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.
                    Can I get some help in this area?

                    Comment


                      #40
                      Originally posted by ezrollin View Post
                      Code:
                      [B][COLOR=#e74c3c]private Series<double> reversal;[/COLOR][/B]
                      AddPlot(new Stroke() { Brush = Brushes.Transparent, Width = 1, DashStyleHelper = DashStyleHelper.Solid }, PlotStyle.Dot, "Reversal");
                      REMOVED THE STATE.DATALOADED stuff
                      [B][COLOR=#e74c3c]r[/COLOR][/B]eversal[0] = 0 // on first bar
                      [COLOR=#e74c3c][B]r[/B][/COLOR]eversal[0] = 1 // on true condition  [COLOR=#e74c3c][B]// <-- overwrites the '0' from line above[/B][/COLOR]
                      [B][COLOR=#e74c3c]r[/COLOR][/B]eversal[0] = -1 // on false condition [B][COLOR=#e74c3c]// <-- overwrites the '1' from line above[/COLOR][/B]
                      
                      [Browsable(false)] //
                      [XmlIgnore()]
                      public Series<double> Reversal
                      {
                      get { return [B]Values[2][/B]; }
                      }
                      I realized that this would be the correct way to do it.
                      However I'm having errors in setting any of the bars.

                      Can I get some help in this area?
                      It looks like you're mixing your apples and oranges again.

                      Try this ...
                      Remove the top line in red.
                      Change the lowercase r's to uppercase.

                      And, drum roll, you may still have problems.
                      This is still too little code to go on, not enough context, because
                      where all this code is located is very important,

                      Do you have two calls to AddPlot before the one that is shown?

                      Why do I ask? Because the '2' in Values[2] means that (at least)
                      three AddPlots should have been called, because accessing
                      Values[2] is really accessing the plot values in the 3rd plot created
                      by the 3rd call to AddPlot -- this is what the code is expecting, I'm
                      just asking to make sure you know what you're doing.

                      Comment


                        #41
                        Ya you're right. Looking at the script I'm getting advice from, those should be capitalized and the
                        private Series<double> reversal;
                        shouldnt even be there but IDK how they're able to get away with that.
                        Yes [2] was intentional.
                        However I dont know if ADDLINE counts as a plot? NO?
                        (AddLine is in the WaveTrend script)
                        My problem now is avoiding those errors.
                        Yes, I'm trying to overwrite (update) the reversal value when conditions exist but it doesnt like it.
                        thanks

                        Comment


                          #42
                          Originally posted by ezrollin View Post
                          However I dont know if ADDLINE counts as a plot? NO?
                          (AddLine is in the WaveTrend script)
                          The objects created by AddLine are not Plot objects.

                          AddPlot creates Plot objects and adds them to the Plots collection. (*)
                          AddLine creates Line objects and adds them to the Lines collection.

                          (*) For each Plot object added to the Plots collections, AddPlot also
                          adds a Series<double> object to the Values collection.

                          Comment


                            #43
                            Can someone please provide sufficient reference on how to use the DivergenceInputsSeries indicator in strategy builder? I want access to the signal when the up and down divergence has occurred and perhaps compare it to some value. I have followed the entire discussion above but no definite solution. I would to make the changes inside of the DivergenceInputsSeries indicator.

                            Comment


                              #44
                              bltdavid
                              NinjaTrader_ChelseaB

                              Code:
                              AddPlot(Brushes.Transparent, "BullorBear");
                              [B]this is in the State.SetDefaults but should it be in OnStateChange?[/B]
                              
                              BullorBear[0] = 0; // on first bar. [B]I guess to reset it?   I put this at the beginning of OnBarUpdate. Is this correct?[/B]
                              
                              BullorBear[0] = 1; // for a BULL condition // <-- overwrites the '0' from line above      I'm putting this in the section where a bull event occured
                              BullorBear[0] = -1; // for a BEAR condition // <-- overwrites the '1' from line above    I'm putting this in the section where a bear event occured
                              
                              [Browsable(false)] //
                              [XmlIgnore()]
                              public Series<double> BullorBear
                              {
                              get { return Values[2]; } //2 means that there are 3 plots so [2] is my 3rd plot
                              }

                              I'm still having trouble so I'm at it again to try to figure it out and get it working right.
                              Can you help? thanks
                              Last edited by ezrollin; 08-30-2022, 08:29 PM.

                              Comment


                                #45
                                My strategy wont even start.

                                Indicator 'myExposedIndicator': Error on calling 'OnBarUpdate' method on bar 5712: Object reference not set to an instance of an object.
                                Strategy 'myExposedStrategy': Error on calling 'OnBarUpdate' method on bar 5712: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
                                The only thing I have ADDED in OnBarUpdate is:
                                BullorBear[0] = 0;
                                So I dont see why its having a problem.

                                The FIRST thing in my OnBarUpdate is:

                                //Add your custom indicator logic here.
                                if(CurrentBar == 0)
                                {
                                return;
                                }
                                so I would think it would return if there werent enough bars...?
                                Last edited by ezrollin; 08-30-2022, 08:30 PM.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by naanku, Today, 07:25 PM
                                0 responses
                                6 views
                                0 likes
                                Last Post naanku
                                by naanku
                                 
                                Started by milfocs, Today, 07:23 PM
                                0 responses
                                5 views
                                0 likes
                                Last Post milfocs
                                by milfocs
                                 
                                Started by PaulMohn, Today, 06:59 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post PaulMohn  
                                Started by bortz, 11-06-2023, 08:04 AM
                                48 responses
                                1,753 views
                                0 likes
                                Last Post carnitron  
                                Started by Jonker, 04-27-2024, 01:19 PM
                                3 responses
                                24 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Working...
                                X