Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get RSI Indicator with relative values?

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

    How to get RSI Indicator with relative values?

    Hello,
    with the following code I get a wrong rsi value:

    RSI rsi = RSI(Close, 14, 3);
    double rsiValue = rsi.Value[0];

    But the value is not relative from 0-100 and additional not top when bottom as in the diagram.

    How can I get RSI like in the diagram?
    14 and 3 are the default parameters out of the diragram.

    Thanks
    Andreas

    #2
    Hello Andreas,

    Thank you for your post.

    Rather than using rsi.Value[0] you should be able to just use rsi followed by the barsAgo index you would like the value for:

    RSI rsi = RSI(Close, 14, 3);
    double rsiValue = rsi[0];

    The help guide describes the following syntax to get the default RSI value:
    Returns default value
    RSI(int period, int smooth)[int barsAgo]
    RSI(ISeries<double> input, int period, int smooth)[int barsAgo]​


    It looks like what you are doing is storing a reference to the indicator, which can have a performance benefit. This is useful when you are reusing an indicator several times throughout your code. That way you can call rsi[0] rather than RSI(Close, 14, 3)[0] for example. For a more detailed explanation of referencing indicator methods, please see the NinjaScript Best Practices page here:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Thanks for your answer.
      I have change the code to without a reference.
      RSI(14, 3)[0];

      But I get still the same absolute values like 245000, 5149, ...
      The diagram shows 0-100 values.

      Comment


        #4
        Hello ASoellner,

        Thank you for your reply.

        Do you get the same results with the attached indicator? I have created an indicator that prints the following to the NinjaScript Output window:
        Code:
        Print(String.Format("{0} RSI(14, 3)[0]: {1}, myRsi[0]: {2} rsiValue: {3}", Time[0], RSI(14, 3)[0], myRsi[0], rsiValue));

        I tested it on the Playback Connection for ES 09-23 on 6/30/2023 and got output such as the following:
        6/30/2023 10:00:00 AM RSI(14, 3)[0]: 57.1154920671089, myRsi[0]: 57.1154920671089 rsiValue: 57.1154920671089

        I am not able to reproduce the results with the absolute values you have mentioned. Please import the attachment at Control Center > Tools > Import > NinjaScript Add On and test the indicator on a chart.

        I look forward to hearing the results.
        Attached Files

        Comment


          #5
          Hello Emily,

          thanks for your help. Your example works. I have found my error.
          RSI Indicator works as expected.

          Thanks Andreas

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          639 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
          572 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X