Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RSI Pod & Smooth Crossover

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

    RSI Pod & Smooth Crossover

    Hi,

    I am trying use the values from the standard NT8 RSI indicator in another custom indicator. I would like to know how I can extract the values of the "RSI Period" and the "RSI Smooth" for the current bar. These are the Blue and Gold lines as shown when using the default NT8 RSI indicator.

    I plan to use these values to determine if the smooth line has crossed above, or below the period line. I also intent to use the values to verify a "dead zone" as being a certain value above or below the crossover. The dead zone will hopefully knock out some of the "noise".

    Any help would be grateful.

    #2
    Hello Kaiviti57,
    Refer below:
    Code:
    [INDENT]private RSI rsi; // before OnStateChange
    rsi = RSI(Period, Average); // in DataLoaded
    in OnBarUpdate:[/INDENT][INDENT=3]plot_rsi[0] = rsi.Default[0];
    plot_rsi_avg = rsi.Avg[0];[/INDENT]

    for dead zone, you can have a channel (example: avg plot + noise & avg plot - noise) & now instead of checking rsi crossing avg consider rsi crossing upr channel / lwr channel.

    Hope it helps!

    Comment


      #3
      s,kinra, thanks for your response. I now know where to put "private RSI rsi;"(or maybe this is still in the wrong place?). However, I have no idea where to put "rsi = RSI(Period, Average); ". There is no DataLoaded section in my code.

      You may also have misunderstood what I am trying to get. I want the actual values for the period and the smooth. I do not want to plot these. I used these values in a simple calculation to determine in the period is above or below the smooth. That then determines the colour of my plot.

      I have attached my code so that you may get a better idea of what I am trying to achieve.
      Attached Files

      Comment


        #4
        All good. I figured it out and now my indicator is working exactly as intended. See the revised attachment if you are interested in what I did.
        Attached Files

        Comment


          #5
          Hello Kaiviti57,
          Glad to know you got it working. I've made a few changes to it, just in case you would like to have a look.
          Changes:
          1. Initialized RSI & SMA
          2. Changed Folder Name to "Kairi"
          3. Removed unnecessary plots, now only 1 plot is needed & added a Zero line
          4. In your if condition, now changes only colors & not plots
          Hope it helps!
          Attached Files

          Comment


            #6
            Hello Kaiviti57,

            Where you have mentioned:
            " I now know where to put "private RSI rsi;"(or maybe this is still in the wrong place?)"

            Private and public variables will be declared in the scope of the class. This means between the curly braces for the class definition.

            See the NinjaScript Editor 401 training video where this is discussed.
            https://ninjatrader.com/support/foru...040#post786040

            Where you have mentioned:
            "I have no idea where to put "rsi = RSI(Period, Average); ". There is no DataLoaded section in my code."

            The 'else if (State == State.DataLoaded)' can be added to the script and this is where an indicator can be called in OnStateChange(), or you can call the indicator in OnBarUpdate(). Below is a link to the help guide.
            https://ninjatrader.com/support/help...tatechange.htm

            Calling the RSI indicator requires that you provide a value for Period and Smooth in the method overload parameters. For whatever value you are supplying, these could be saved to a variable and the variable supplied to the RSI.

            private double myPeriod = 14;
            private double mySmooth = 3;

            Print(RSI(myPeriod, mySmooth));

            if (myPeriod > 14)
            {
            // myPeriod is greater than 14, trigger some action
            }

            Or you could get the property from the indicator class instance.

            if (RSI(14, 3).Period > 14)
            Last edited by NinjaTrader_ChelseaB; 06-02-2021, 07:16 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea & s.kinra,

              I apologise for my lack of experience at NinjaScript. I only use it once or twice in a blue moon and I tend to forget everything in between. Your continued help and guidance is most appreciated.

              I have made some more changes and included a few more plots to show conditions where the close has not crossed above/below the SMA. The revised code is attached.

              There is more feature that I would like to do with this indicator. Can you advise if the following point is possible:

              1) Plat the MA onto the price chart and using the user defined "KriPeriod" value;
              2) Plot the RSI as a separate plot using the used defined values for "RsiPeriod" and "RsiSmooth";
              3) Give the user to show or hide the plots for 1) & 2) above.
              Attached Files

              Comment


                #8
                Hello Kaiviti57,
                Yes, you can plot in general but in 1 panel only, so all plots should be in same panel. MA is required on price chart & RSI on lower sub panel which is not possible from same indicator. You're currently using a sub panel so you can have RSI plot in the same panel but scaling would be a concern.
                You can show / hide plots using a public bool variable, use this as condition for defining plots or change color to transparent.
                Refer attachment. Hope it helps!
                Attached Files

                Comment


                  #9
                  Hello Kaiviti57,
                  Perhaps an idea to combine Draws and Plots?
                  DrawOnPricePanel = true; for all indicator values close to the price data (e.g. SMA).
                  IsOverlay = false; for plotting of other indicators of interest (e.g. RSI).
                  NT-Roland

                  Comment


                    #10
                    Yes, I thought there would be a few issues with what I was asking. I was looking for a simple way to keep all the indicators in sync. It is so easy to change the values of one and then forget too do the others. Thanks for your help anyway. I have already so much with this indicator that I shouldn't push the boundaries of friendship any further.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    641 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    366 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    107 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    569 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    573 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X