Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need simple code for StochRSI please

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

    Need simple code for StochRSI please

    Hello there,
    I use StochRSI indicator a lot in Ninjatrader, however It only display %K line.
    I would like it to also display the %D line; StochRSI %D is a moving average of %K over %D Length bars.
    I came up with some code by adding D as SMA of StochRSI but it doesn't show the correct results, the D line is way off. can someone help? can I just modify stochRSI.cs and get it done? if so what code should I add and where.

    Thank you for your assistance
    Tom

    #2
    Tom, can you please post the code you've come up with so far?
    AustinNinjaTrader Customer Service

    Comment


      #3
      protected override void Initialize()
      {
      Add(new Plot(Color.Green, "D"));
      Add(new Plot(Color.Orange, "K"));

      Add(new Line(Color.DarkViolet, 0.20, "Lower"));
      Add(new Line(Color.YellowGreen, 0.80, "Upper"));

      Overlay = false;
      PriceTypeSupported = true;
      }

      /// <summary>
      /// Calculates the indicator value(s) at the current index.
      /// </summary>
      protected override void OnBarUpdate()
      {
      double rsi = RSI(Input, periodK, 1)[0];
      double rsiL = MIN(RSI(Input, periodK, 1), periodK)[0];
      double rsiH = MAX(RSI(Input, periodK, 1), periodK)[0];

      if (rsi != rsiL && rsiH != rsiL)
      K.Set((rsi - rsiL) / (rsiH - rsiL));
      else
      K.Set(0);
      D.Set(SMA(K, PeriodD)[0]);
      }

      Comment


        #4
        Never mind I got it, I just had a problem adjusting the smoothing and period length and got diff results, I got it now. I think my formula is correct also.

        Regards,
        Tom

        Comment

        Latest Posts

        Collapse

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