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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X