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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        57 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        78 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        41 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        101 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        61 views
        0 likes
        Last Post PaulMohn  
        Working...
        X