Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add horizontal lines to indicator in strategy script

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

    #46
    Originally posted by NinjaTrader_Cal View Post
    Alexstox,

    You can set up conditional statements to check values, if those values are not plots then you would want to take a look at the link below on exposing your values -
    http://www.ninjatrader.com/support/f...ead.php?t=4991

    If they are plots then you would want to look at the Valid Input link from the help guide -
    http://www.ninjatrader.com/support/h..._indicator.htm
    This was interesting. Please explain some things.
    Why this is used in indicator?
    Code:
    [Browsable(false)]
            [XmlIgnore()]
            public double ExposedVariable
            {
    			// We need to call the Update() method to ensure our exposed variable is in up-to-date.
                get { Update(); return exposedVariable; }
            }
    Please explain in other words, what this mean?
    Code:
    /* If you happen to have an object that does not have an IDataSeries class that can be used, you
    		will need to manually ensure its values are kept up-to-date. This process will be done in the
    		"Property" region of the code. */
    		private double exposedVariable;
            #endregion

    Comment


      #47
      Hello alexstox,

      Basically what this means is that if you want another Indicator or Strategy to be able to have access to a calculated value other than something like a Plot you would have to use the "Update();" method before returning the variable is all.

      IDataSeries (Plots basically) will do this automatically but other variable like "int", "double" etc... need to have the "Update()" place before this.
      JCNinjaTrader Customer Service

      Comment


        #48
        I got it! So, all ...Series are automatically updated.

        What is it? This update true/false for every variable on every bar?
        Code:
        /* "this" syncs the BoolSeries to the historical bar object of the indicator. It will generate
        			one bool value for every price bar. */
        			bearIndication			= new BoolSeries(this);
        			bullIndication			= new BoolSeries(this);
        Whether it should be present in the strategy?

        Comment


          #49
          Hello alexstox,

          Correct yes, it is basically like the Plot (DataSeries) series but for a bool (true/false) so that way every bar you can check to see if was a Bear Indication bar or if it was a Bull Indication.

          You may use it inside of a strategy or a Indicator.
          JCNinjaTrader Customer Service

          Comment


            #50
            Originally posted by NinjaTrader_JC View Post
            Hello alexstox,

            Correct yes, it is basically like the Plot (DataSeries) series but for a bool (true/false) so that way every bar you can check to see if was a Bear Indication bar or if it was a Bull Indication.

            You may use it inside of a strategy or a Indicator.
            Do you mean that this could be used after some condition come true in OnBarUpdate()?! and true/false for BoolSeries variable will be checked only those cases?

            Comment


              #51
              Hello alexstox,

              Correct.
              JCNinjaTrader Customer Service

              Comment


                #52
                FIRST.
                ok. if I use it after some condition in OnBarUpdate(), how to null variable value if condition not come true? As I understood, that's why in NT samples you put those expressions in Initialize()?
                Code:
                protected override void Initialize()
                        {
                			/* "this" syncs the BoolSeries to the historical bar object of the indicator. It will generate
                			one bool value for every price bar. */
                			bearIndication			= new BoolSeries(this);
                			bullIndication			= new BoolSeries(this);
                Or if I add after my condition in OnBarUpdate() I should script in manner like this
                Code:
                if() {} 
                else if() {}
                else //here will be everything except my conditions come true
                Last edited by alexstox; 01-11-2014, 01:04 PM.

                Comment


                  #53
                  SECOND
                  Originally posted by NinjaTrader_JC View Post
                  Hello alexstox,

                  Correct yes, it is basically like the Plot (DataSeries) series but for a bool (true/false) so that way every bar you can check to see if was a Bear Indication bar or if it was a Bull Indication.

                  You may use it inside of a strategy or a Indicator.
                  Still can't understand. We set true or false for variables in OnBarUpdate(). Why we should else
                  Code:
                  BuyIndication = BoolSeries (this)
                  Last edited by alexstox; 01-11-2014, 01:05 PM.

                  Comment


                    #54
                    Third question.

                    Can I Autoscale=false only for 1 component of my indicator?
                    And how to ScaleJustification = ScaleJustification.Left; only for some component in my indicator?
                    How to add value of those component, that will not be shown on y-scale, on right top corner of indicator window(panel)?
                    Last edited by alexstox; 01-11-2014, 01:06 PM.

                    Comment


                      #55
                      Hello alexstox,

                      1. It is a bool variable so if it is not "true" you would want to set it to "false" which would mean that the condition was not hit.

                      2. There is an "else" statement there because we want to only set the "bool" variable to either "true" or "false" (not null) so if it does not meet any of the conditions above it we will want to set them both to false.

                      3. AutoScale will affect all of your Plot components but your drawing objects you can control by using the overload methods that allows you to set the "AutoScale" feature for those objects.

                      ScaleJustification will affect your entire Indicator.

                      I am not sure what you are referring to on your last question could you please clarify this a bit more or give me an example?
                      JCNinjaTrader Customer Service

                      Comment


                        #56
                        Still can't understand.
                        We set true or false for variables in OnBarUpdate().
                        Code:
                         protected override void OnBarUpdate()
                                {
                        	// MACD Crossover: Fast Line cross above Slow Line
                        	if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1))
                        	{.......... bullIndication.Set(true);
                        		bearIndication.Set(false);
                        Why we should assign bullIndication and bearIndication else in Initialize()?!
                        Code:
                        bearIndication = new BoolSeries(this);
                        	bullIndication = new BoolSeries(this);

                        Comment


                          #57
                          Originally posted by alexstox View Post
                          Still can't understand.
                          We set true or false for variables in OnBarUpdate().
                          Code:
                           protected override void OnBarUpdate()
                                  {
                              // MACD Crossover: Fast Line cross above Slow Line
                              if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1))
                              {.......... bullIndication.Set(true);
                                  bearIndication.Set(false);
                          Why we should assign bullIndication and bearIndication else in Initialize()?!
                          Code:
                          bearIndication = new BoolSeries(this);
                              bullIndication = new BoolSeries(this);
                          That is the standard code REQUIRED to initialize a boolSeries, before you can assign any values to it. That is not an assignation: it is a declaration. Yes, even despite the new keyword (that simply assigns it at declaration time; the key issue is still the declaration). Why do you think that it should not be there?

                          Comment


                            #58
                            Originally posted by koganam View Post
                            That is the standard code REQUIRED to initialize a boolSeries, before you can assign any values to it. That is not an assignation: it is a declaration. Yes, even despite the new keyword (that simply assigns it at declaration time; the key issue is still the declaration). Why do you think that it should not be there?
                            Because I'm not a coder I'm newbie with 2000 rows code first in my life
                            I never knew about C#, C++ etc. But only NT help guide and their great support gave me this opportunity to plunge into the programming world thank you all guys!

                            About
                            Why do you think that it should not be there?
                            Because I thought it's enough only to assign value to variables.

                            Comment


                              #59
                              Originally posted by NinjaTrader_JC View Post
                              Hello alexstox,
                              AutoScale will affect all of your Plot components but your drawing objects you can control by using the overload methods that allows you to set the "AutoScale" feature for those objects.
                              ScaleJustification will affect your entire Indicator.
                              I am not sure what you are referring to on your last question could you please clarify this a bit more or give me an example?
                              Ok. For example, there are 3 SMAs and MAX and MIN in MyIndicator. So, 3 SMAs plots great, BUT MAX and MIN are differs much from SMA's values. And as result all this components are y-scaled, so it's hard to see them. It would be great to "not scale" MAX and MIN and only see their values in right top corner of indicator panel. What you can advise?
                              Well it would be better to say "see MAX/MIN if they are "in similar" y-scale as SMA, and don't see them (only right top values) if they are not "in similar" y-scale.
                              Last edited by alexstox; 01-13-2014, 04:53 PM.

                              Comment


                                #60
                                Hello alexstox,

                                If you are visually displaying MAX/MIN on the chart using a Plot then AutoScale will be applied to all Plots. If you want to not have them be on the AutoScale list you may want to use a Drawing object so that way you can toggle if it is going to be AutoScale or not in part of the overloads. It will be a "bool autoScale" that you may set to false to do this.

                                JCNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                608 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                355 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                105 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                560 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                561 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X