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

Indicator that's % of price?

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

    Indicator that's % of price?

    Hi, is there an indicator in NT, or a way to put a line on the chart that is a % of price?

    How do I determine % of price?

    Thanks!

    #2
    Hello _Cujo, and thank you for your question. It sounds like you may be talking about the Rate-Of-Change (ROC) indicator. This lets you know the percentage price change over a period you specify. You can learn more about this indicator here,



    If the thing you wanted to compare to price to get a percentage was not how much your prices changed, but instead how much gain or loss there was, you will want to look at the relative strength index (RSI) and relative volatility index (RVI) documented here,




    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hi Jessica,

      Thanks for the feedback.

      I was more looking for something that would, for example - if price is 2000, and I entered 10% in the indicator parameters, it's would draw a line at 1800.

      My understanding of ROC and RSI is they are not what I'm looking for to do this. I'm less familiar of the RVI, but I don't believe it will do what I'm after as well.

      I'm after more a basic math function.

      Thanks!

      Comment


        #4
        Thank you for this additional information _Cujo. I have prepared a video where I show you how to create this indicator. Please let us know if there are any other ways we can help.

        Attached Files
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Jessica, really appreciate it!

          I'm still on NT 7. Is there much difference between NT7 and NT8 for doing this?

          I'll try this asap.

          Comment


            #6
            The only significant difference is that in NinjaTrader 7, you will want to use Variable0 instead of ActualPercentage. After unlocking your code you will want to turn Variable0 into a double (it will start off an int). In the wizard, compare this to 0 and 100, and then change this in code to 0.0 and 1.0, respectively.
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              unless you're looking for something more specific, for an easy fix, would the moving average envelopes indicator work for you?

              just set the moving average to SMA and period to whatever the minimum allowed is

              Comment


                #8
                Hi,

                The attached file doesn't import to NT7. I zipped it, but it's not recognised. I guess because it's probably NT8?

                I tried following the video, but the 2nd screen of the video is really different from the NT7 screen. And from there I couldn't really follow so well. I'm not so technical, and have 4 thumbs, so...

                I'm not so sure how the miscommunication happened regarding NT7 vs NT8, since I'm in the NT7 forum (I double checked), but is there anyway you can do exactly what you've done, except for NT7 instead of NT8??

                Thee video and file look super useful...

                Thanks, sorry to be a pain, but hoping you don't mind.

                Comment


                  #9
                  Thanks, but I am looking for something specific. I'm looking for a % of price, not a MA based on a trailing period.

                  Comment


                    #10
                    We are always happy to help. I went ahead and prepared a video for NT7



                    This video goes a step further than the previous video, actually discussing importing your code into an Indicator, rather than leaving you with a Strategy. My 5 minute recording limit was hit, but the final step is to change "Variable0" to "ActualPercentage * Close[0]" inside the DrawHorizontalLine call.

                    For your convenience, here are the final Variables, OnBarUpdate, and Properties sections in-line in this post.

                    Code:
                    [FONT=Courier New]
                            #region Variables
                            // Wizard generated variables
                            private double percentage = 1; // Default setting for Percentage
                            // User defined variables (add any user defined variables below)
                            private double ActualPercentage = 0.0;
                            #endregion[/FONT]
                    Code:
                    [FONT=Courier New]
                            /// <summary>
                            /// Called on each bar update event (incoming tick)
                            /// </summary>
                            protected override void OnBarUpdate()
                            {
                                // Condition set 1
                                if (Percentage > 1)
                                {
                                    ActualPercentage = 1.0;
                                }
                    
                                // Condition set 2
                                if (Percentage <= 1)
                                {
                                    ActualPercentage = Percentage;
                                }
                    
                                DrawHorizontalLine("My horizontal line" + CurrentBar, ActualPercentage * Close[0], Color.Blue);
                            }[/FONT]
                    Code:
                    [FONT=Courier New]
                            #region Properties
                            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                            public DataSeries Plot0
                            {
                                get { return Values[0]; }
                            }
                    
                            [Description("")]
                            [GridCategory("Parameters")]
                            public double Percentage
                            {
                                get { return percentage; }
                                set { percentage = Math.Max(0.000, value); }
                            }
                            #endregion[/FONT]
                    The C# file attached to this post can be copied into your (My) Documents\NinjaTrader 7\bin\Custom\Indicator folder . Once you have done so, open it in the NinjaScript editor with Tools -> Edit NinjaScript -> Indicator -> Example1691995 . After this, just press F5 to install your indicator.
                    Attached Files
                    Jessica P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by cre8able, Today, 03:20 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post cre8able  
                    Started by Fran888, 02-16-2024, 10:48 AM
                    3 responses
                    47 views
                    0 likes
                    Last Post Sam2515
                    by Sam2515
                     
                    Started by martin70, 03-24-2023, 04:58 AM
                    15 responses
                    114 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by The_Sec, Today, 02:29 PM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    2 responses
                    31 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X