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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        36 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        14 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        19 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X