• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing OB OS line values using user defined parameters

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

    Changing OB OS line values using user defined parameters

    Hi,

    Say I am using RSI on a chart. To move the OB and OS line values I need to change the values under the Lines section in the Indicators GUI. Within a strategy I know I can change these lines by adding lines like:

    Code:
    RSI(14,1).Lines[0].Values = 85;
    Ref:
    http://www.ninjatrader.com/support/f...ead.php?t=3228
    http://www.ninjatrader.com/support/f...ad.php?t=47135

    However, is it possible to do the same within an indicator. That is, can I add user defined parameters that will make the same change when I plot the indicator on a chart? I have tried but it doesn't seem to work. If I define an OB variable as 75 under Variables and then use

    Code:
    Add(new Line(Pen, OB, "OB LINE"));
    within Initialize(), even if I change the value of OB in the GUI to 80 before plotting the indicator, the Lines are defined by Initialize beforehand so OB will plot 75 regardless. I then need to change the "OB LINE" Lines value to 80 separately in the GUI to get the OB line to plot where I originally wanted it.

    I'm guessing there is no way around this because it all happens in Initialize()?

    Cheers,
    darmbk.

    #2
    darmbk, if you check into the RSI indicator itself standalone, isn't that already doing what you seek? It exposes the Lines in separate category in the UI and would accept user defined values for OB and OS this way.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks for getting back to me. I appreciate that you are correct. The real reason I ask is because I am designing a bespoke indicator with many lines based off calculations using a number of parameter values. The required calculations can be done within a strategy as shown but I would need to manually enter values for these lines when adding the indicator to a chart using the GUI.

      This isn't a massive deal as the main thing is that I can do it in a strategy.

      Cheers,
      darmbk.

      Comment


        #4
        Correct, if you want have those lines adjusted automatically, then either you would need to Add() the indicator via the strategy script, or have the complete logic for adjusting in a RSI indicator copy. You could not expose those for access in the strategy.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          So, assuming I'm using parameters for "upper" and lower", what's the method of making these plot with a different value set from the UI since the initialize section keeps them at the original setting?

          Code:
          //in variables:
          private int upper = 75;
          private int lower = 25;
          Code:
          //in initialize:
          Add(new Line(System.Drawing.Color.Red, upper, "Upper"));
          Add(new Line(System.Drawing.Color.Green, lower, "Lower"));
          Code:
          //in onbarupdate:
          
          if (K[0] > Lines[1].Value){
          //do something
          }
          Code:
          //in Properties
          [Description("Line value")]
          		[GridCategory("Parameters")]
          		public int Upper
          		{
          			get { return upper; }
          			set { upper = Math.Max(1, value); }
          		}
          		[Description("Line value")]
          		[GridCategory("Parameters")]
          		public int Lower
          		{
          			get { return lower; }
          			set { lower = Math.Max(1, value); }
          		}
          Problem is, when I change the parameter for Upper or Lower in the UI, it doesn't change the plotted line value since they were set in Initialize. What's the correct manner to have OnBarUpdate "look up" the current value from the UI of the parameter?
          Last edited by zeller4; 11-05-2014, 05:52 PM.

          Comment


            #6
            zeller4, if you want to set through custom property inputs, just assign them to their values in OnStartUp(). The Line value access looks correct, what issue do you see here? Have you printed this value for each bar?
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by aviat72, Today, 12:41 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChrisSch  
            Started by _Zero_, 01-06-2020, 01:16 PM
            2 responses
            76 views
            2 likes
            Last Post CiprianV  
            Started by RuthB, 05-29-2020, 09:41 PM
            3 responses
            33 views
            0 likes
            Last Post aviat72
            by aviat72
             
            Started by Jorge.andres.o, Yesterday, 08:22 PM
            0 responses
            7 views
            0 likes
            Last Post Jorge.andres.o  
            Started by mtamaku, Yesterday, 06:54 PM
            0 responses
            11 views
            0 likes
            Last Post mtamaku
            by mtamaku
             
            Working...
            X