Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting highest value of past x candles for RSI

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

    Getting highest value of past x candles for RSI

    Hey I'm fairly new developer in ninjascript. actually i started today.

    I'm trying to convert an indicator I developed in pinescript.

    xbars = input(90, title="Div lookback period (bars)?",group = "Dont Change")
    hb = math.abs(ta.highestbars(rsi, xbars)) // Finds bar with highest value in last X bars
    lb = math.abs(ta.lowestbars(rsi, xbars)) // Finds bar with lowest value in last X bars

    this is the code in pinescript.
    I have tried to do something similar but it throws an error...

    double rsivalue = RSI(14, 3)[0];
    Math.Abs(MAX(rsivalue, 90));​

    Anyone can provide me an insight on how to go around it?

    #2
    you are not assigning the output of the 2nd line to a variable.
    try
    Code:
    double rsivalue_highest_90 = MAX(rsivalue, 90) ;
    there is no need to do Absolute since RSI has a floor of 0

    Comment


      #3
      Originally posted by balltrader View Post
      you are not assigning the output of the 2nd line to a variable.
      try
      Code:
      double rsivalue_highest_90 = MAX(rsivalue, 90) ;
      there is no need to do Absolute since RSI has a floor of 0


      it is still coming up with an error "argument 1: cannot convert from double to ninjatrader.ninjascript.iseries<double>"

      Comment


        #4
        Hello oshriur,

        The variable rsivalue is a single number which is type double in C#, that is a single decimal number.

        The MAX indicator is expecting a series of many numbers which is known as a Series<double>. You cannot pass a single number to MAX.

        To get the MAX of the RSI from a period you need to pass the RSI to the MAX indicator:

        Code:
        double maxRsi = MAX(RSI(14, 3), 90)[0];

        Comment

        Latest Posts

        Collapse

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