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

changing indicator parameter has no effect

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

    changing indicator parameter has no effect

    under what circumstances will a parameter change not have an effect?

    i have the following code:

    public int trigger = 120;

    Add(new Line(Color.Red, Trigger, "Level 1"));

    [Description("Trigger line. Minimum 1.")]
    [Category("Parameters")]
    public int Trigger
    {
    get { return trigger; }
    set { trigger = Math.Max(1, value); }
    }

    when i change the parameter in the indicator settings (i.e. when just using the indicator in a chart and not using it via a strategy) from 120 to 100, the line does not change

    however...when i change the setting via my strategy, which calls the indicator, no problem

    thanks
    Last edited by ATI user; 06-02-2008, 05:58 AM.

    #2
    That is expected. You need to removed and add the indicator to chart again.

    Comment


      #3
      Thanks Dierk. I had already tried that however and it does not make a difference.

      In the code trigger is set at 120

      When I load the inidicator to the chart, I change the 120 to 200 and the line stays at 120...even though the parameter is shown in the title as being accepted as 200.

      I think something in the Ninjascript code that is automatically added to the indicator is keeping the setting at the default value...i.e. it seems to use 'trigger' instead of 'Trigger'

      I have noticed in other instances that the auto Ninjascript does not always adapt to changes I make in my code. In some cases I had to start over...and may have to this time also.

      Comment


        #4
        Unfortunately what you are trying to achieve (setting the "line" value by a parameter configurable on the properties dialog) is not supported.

        Comment


          #5
          to test the theory in my last reply, I copied all my code from the indicator and pasted it into a new one..compiled and loaded it...same problem...so the issue is not the ninjascript code

          the problem is no doubt something that I do not understand about the code. Note in attached chart that the plot (at pointer) remains at 120 (default) although the parameter was changed to 200 and accepted by the indicator.

          This must have something to do with the way NT uses the additional parameter section 'Lines' which I do not know how to override/avoid.

          so...I have been changing the default each time instead of the parameter setting as a workaround
          Attached Files

          Comment


            #6
            Please see my post #4

            Comment


              #7
              ok...that explains it..thanks

              1. is this something you might add in the future?

              2. why is it configurable from a parameter when I call the indicator from my strategy and pass the parameter setting that way?

              Comment


                #8
                This is a NT internal limitation. I'll add it to the list of future considerations.

                Comment


                  #9
                  2. why is it configurable from a parameter when I call the indicator from my strategy and pass the parameter setting that way?

                  Comment


                    #10
                    Since a different logic is triggered NT internally.

                    Comment


                      #11
                      thanks...will stick with the workaround

                      Comment


                        #12
                        ATI user

                        I tried your approach in an indicator and got the same result that you did. Try putting the following code in your OnBarUpdate() method:

                        Lines[0].Value = Trigger;

                        The Lines[0] assumes that the line you want to change is the first line in your Add(new Line(etc.)) in your Initialize() method. Adjust the index for whichever line you want to change. That allowed me to dynamically change the position of an oscillator line in an indicator. If you then make the change to Trigger in the Indicators dialog box and hit apply then you should see the line adjust in the indicator. However, you won't see the new value in the Lines portion of the Indicators dialog box until you close the dialog box and reopen it, showing that the change has taken effect.

                        I don't know why this works in the OnBarUpdate() method but not in the Initialize() method.

                        Comment


                          #13
                          higler

                          very cool...works great...thanks

                          Comment


                            #14
                            Glad it works for you. The only thing that you might want to do is put some conditions on how often that line of code executes (maybe just on the first bar, maybe when some other condition is met, etc). Otherwise, since it is in the OnBarUpdate() method, it executes everytime the bar is updated which can be a lot of repetition of the same assignment statement (every tick) in some instances. If you can come up with some limiting logic then you can reduce the unnecessary repetition. It all depends on exactly what you want your indicator to do. Other than that, it also worked for me.

                            Comment


                              #15
                              right

                              I am using

                              if ( Bars.FirstBarOfSession )
                              Lines[0].Value = Trigger;

                              which works fine...and only sets it once

                              thanks again....great workaround/solution

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ZenCortexCLICK, Today, 04:58 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post ZenCortexCLICK  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              172 responses
                              2,280 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              18 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X