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

    #31
    Alexstox,

    Yes, you can do that in the Initialize method, however, please note that the initialize method only gets called when you add the script to a chart. You would need to remove and add the script back from the dialog window.
    Cal H.NinjaTrader Customer Service

    Comment


      #32
      When I tried to call for MyIndicator() in strategy, this caused an error because strategy required MyIndicator(1var, 2var, 3var). That's why I asked about how to call MyIndicator as default just MyIndicator()?

      Comment


        #33
        Alexstox,

        Correct, when you add another indicator to a strategy or any other script, it will create a new instance of that indicator in which you will need to pass through values for the indicator.

        You can create variables that will be the default to pass through the MyIndicator()
        Cal H.NinjaTrader Customer Service

        Comment


          #34
          Originally posted by NinjaTrader_Cal View Post
          Alexstox,

          Correct, when you add another indicator to a strategy or any other script, it will create a new instance of that indicator in which you will need to pass through values for the indicator.

          You can create variables that will be the default to pass through the MyIndicator()
          Can be these variables from MyIndicator? Not to set them in script? And how to implement this in strategy, where I call this indicator?

          Comment


            #35
            Alexstox,

            You will need to pass values through values for the MyIndicator() in order for the instance to know what values to create it and calculate the indicator.
            Cal H.NinjaTrader Customer Service

            Comment


              #36
              Originally posted by NinjaTrader_Cal View Post
              Alexstox,

              You will need to pass values through values for the MyIndicator() in order for the instance to know what values to create it and calculate the indicator.
              So, if there are var1, var2, var3 in MyIndicator, these variables should be in strategy script in Variables region and in MyIndicator(var1, var2, var3)?!

              Comment


                #37
                Alexstox,

                No, that is not what I'm saying.

                Let's try a different look.

                When you add, say, an SMA() to the strategy you need to pass a value through the () in order for the SMA to know what to calculate with.

                I.E. SMA(12)

                However, you can create a variable that you can pass through the SMA instead so that you have more control over it rather than having to open the script back and forth to adjust the value.

                http://www.ninjatrader.com/ninjatrader/nt7/setup.exe
                Cal H.NinjaTrader Customer Service

                Comment


                  #38
                  Originally posted by NinjaTrader_Cal View Post
                  Alexstox,
                  I.E. SMA(12)
                  However, you can create a variable that you can pass through the SMA ...
                  I knew that, thanks
                  I thought default variables could be used without passing through () in indicator
                  Last edited by alexstox; 01-08-2014, 03:14 PM.

                  Comment


                    #39
                    Originally posted by NinjaTrader_Cal View Post
                    Alexstox,

                    Yes, you can do that in the Initialize method, however, please note that the initialize method only gets called when you add the script to a chart. You would need to remove and add the script back from the dialog window.
                    1) So, how to script this
                    Code:
                    if([B][U]instrument==MSFT[/U][/B]) do something
                    2) If I change the instrument (MSFT to MMM) in the chart, will this reload Initialize() method and will Initialize() see the change of instrument?

                    3) how to script
                    Code:
                    If([B][U]instrument==futures or stocks[/U][/B]) do smth

                    Comment


                      #40
                      Alexstox,

                      This does not reload the initialize() method as this is only called when the indicator is first applied to the chart.

                      You would need to do this in OnStartUp() method -
                      http://www.ninjatrader.com/support/h...onstartup2.htm
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #41
                        how to write this in script
                        if(instrument==MSFT)

                        Comment


                          #42
                          Originally posted by alexstox View Post
                          I will check this. Thanks.
                          May I use IF() in Initialize()? For example, to filter ADD() only for some instruments?
                          Code:
                          if(instrument==MSFT) do something
                          And how to check what instrument now is using in strategy or indicator?

                          2) When I tried to call for MyIndicator() in strategy, this caused an error because strategy required MyIndicator(1var, 2var, 3var). That's why I asked about how to call MyIndicator as default just MyIndicator()?
                          There is no default constructor: you must use the full calling signature. That is, all inputs that are exposed as a GridCategory or listed as a Category("Parameters"), must be included on the calling line.

                          Comment


                            #43
                            Originally posted by koganam View Post
                            There is no default constructor: you must use the full calling signature. That is, all inputs that are exposed as a GridCategory or listed as a Category("Parameters"), must be included on the calling line.
                            calling line is Indicator(1,2,3)?
                            What is GridCategory?

                            Comment


                              #44
                              Originally posted by alexstox View Post
                              calling line is Indicator(1,2,3)?
                              What is GridCategory?
                              Look inside the code for your indicator. If the indicator has parameters, you must have exposed them as properties. Show an example of how you specified the Properties.

                              Comment


                                #45
                                Yes! I got it!
                                So, if I want to add MyIndicator() without anything inside (), I should not declare indicator variables in
                                Code:
                                #region Properties
                                [Description("......")]
                                        [GridCategory(".......")]
                                I'm feeling like script guru
                                thank you guys!!!

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                624 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                359 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
                                562 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                567 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X