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

How can I customise overbought and oversold lines from Indicator window?

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

    How can I customise overbought and oversold lines from Indicator window?

    Hi All,
    I'm trying to have the ability to customize the overbought and oversold lines from the indicator window but am experiencing some difficulty. The code I've tried is as follows:-

    Code:
    #region Variables
              int overbought = 45;
              int oversold = -45;
    Code:
    protected override void Initialize()
            {
                Add(new Line(System.Drawing.Color.DarkViolet, overbought, "Upper"));
               Add(new Line(System.Drawing.Color.LightBlue, oversold, "Lower"));}
    Code:
    #region Properties
     [Description("Overbought Level")]
      [Category("Parameters")]
      public int Overbought
      {
       get { return overbought; }
       set { overbought = Math.Max(1, value);}
      }
      [Description("Oversold Level")]
      [Category("Parameters")]
      public int Oversold
      {
       get { return oversold; }
       set { oversold = Math.Max(1, value);}
      }
    What am I doing wrong? I also notice that the oversold value reverts to 1 in the indicator window. Please help.

    Regards

    Kay Wai

    #2
    Hello Kay,

    Thank you for your post.

    There are two things here. The first is that you don't need to create Int variables when you are creating Lines(). These values become available from the Indicator settings when you add it the chart. You would be able to adjust the value of the lines without having to pass Int values through it.

    The second item is with the public variable declaration. We need to replace the Math.Max(1, value) with something along the lines Math.Max(-99999, value)
    This will allow you to have a value at -45 (Which is less than 1 and why it was always defaulting to 1).

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      If however I wanted to customize these values from a strategy, how would I go about doing that?

      Regards

      Kay Wai

      Comment


        #4
        Kay,

        If you are going to be doing this from the strategy, then use the second item that I outlined in my first post.

        When you go to reference this indicator in the strategy, you will then need to pass through values for your public variables.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Hi Cal,

          While i haven't tried in it a strategy yet, and only tried to change the variables - overbought and oversold - that i've indicated above as well as the public variable declaration that you suggested, the line values do not change. Am i missing something?

          Regards

          Kay Wai

          Comment


            #6
            Kay,

            Can you please provide the .CS file so I can review the code?

            You can find the file in (My) Documents -> NinjaTrader 7 -> bin -> Custom -> Indicator
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Hi Cal,

              I've sent the code to the support email to your attention.

              Regards

              Kay Wai

              Comment


                #8
                Kay,

                You will need to use the OnStartUp() method and use Lines to set the value to the variable -
                Code:
                protected override void OnStartUp()
                		{
                			Lines[0].Value = Overbought;
                			Lines[1].Value = Oversold;
                		}
                Let me know if I can be of further assistance.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Thx Cal. Will try that out later today. Cheers, Kay Wai

                  Comment


                    #10
                    Thx Cal. It works!

                    Regards

                    Kay Wai

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by maybeimnotrader, Yesterday, 05:46 PM
                    1 response
                    18 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by Perr0Grande, Yesterday, 08:16 PM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by f.saeidi, Yesterday, 08:12 AM
                    3 responses
                    25 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by algospoke, Yesterday, 06:40 PM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by quantismo, Yesterday, 05:13 PM
                    1 response
                    14 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X