Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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];

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        12 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        15 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Working...
        X