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

moving a Line

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

    moving a Line

    I know that Add() can only go in Initialize().

    Add(new Line(Color.DarkGray, threshold, "Upper"));
    Add(new Line(Color.DarkGray, -threshold, "Lower"));

    Since threshold is a user input, if the threshold is changed, the Line should move. It doesn't - I believe user input changes are supposed to be known going into Initialize(), so this might be a bug. (64-bit v7..4)

    I tried placing the Add() in the OnStartUp() method, but that does not work.

    The Lines have names... How do I update them ?

    I do NOT want to make a plot of a constant line and update it on every tick. That would be a silly waste of overhead. It also would not extend the line all the way to the right edge but would stop on the last bar.

    There must be a reasonable way to do this? Thanks

    #2
    Lost Trader, to clarify, you have an indicator that draws some constant lines defined by user input and the lines don't change if you go into the indicator property window and change the values and hit apply? Or are you trying to update the lines from within your indicator?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Constant Lines at value set by User input. When input value changed in the indicator property window and applied, lines are not moved.
      I do NOT want to change during OnBarUpdate().

      Code:
                  Add(new Line(Color.DarkGray, threshold, "Level 1"));
                  Add(new Line(Color.DarkGray, 0, "Zero line"));
                  Add(new Line(Color.DarkGray, -threshold, "Level -1"));
      threshold is a user input variable:
      Code:
              [Description("threshold for trigger filtering. Must be greater than zero.")]
              [GridCategory("Parameters")]
              public double Threshold
              {
                  get { return threshold; }
                  set { threshold = Math.Max(0.001, value); }
              }
      BTW, default value is 50.

      Comment


        #4
        Lost Trader, can you please attach the full script so I can test this out on my end?
        AustinNinjaTrader Customer Service

        Comment


          #5
          It is a variant on CCI
          Attached Files

          Comment


            #6
            LostTrader, you would use the .Value property of your Lines collection here --

            i.e. Lines[1].Value = Threshold;
            BertrandNinjaTrader Customer Service

            Comment


              #7
              And apparently it must be done in OnStartUp() because it didn't work in Initialize().

              Thank you, Bertrand.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              11 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              5 views
              0 likes
              Last Post terofs
              by terofs
               
              Started by nandhumca, Today, 03:41 PM
              0 responses
              5 views
              0 likes
              Last Post nandhumca  
              Started by The_Sec, Today, 03:37 PM
              0 responses
              3 views
              0 likes
              Last Post The_Sec
              by The_Sec
               
              Started by GwFutures1988, Today, 02:48 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Working...
              X