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:



    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 ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            44 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            180 views
            0 likes
            Last Post jeronymite  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Working...
            X