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

RSI Indicator is wrong, 7.0.1000

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

    RSI Indicator is wrong, 7.0.1000

    Using NT 7.0.1000

    87 double rs = avgUp[0] / (avgDown[0] == 0 ? 1 : avgDown[0]);
    88 double rsi = 100 - (100 / (1 + rs));

    Line 87 of RSI indicator is incorrectly coded.
    This line calculates rs and guards against the possibility of division by zero.
    If true then rs equates to 1 which would result in rsi = 50, which is wrong.
    The correct result is rsi = 100 if avgDown = 0.

    Line 87 should be deleted and line 88 should be revised to:
    double rsi = avgDown[0] == 0 ? 100 : 100 - (100/(1 + avgUp[0]/avgDown[0]));

    #2
    Camdo,

    Not sure I follow you. Line 87 guards against division by zero by ensuring avgDown[0] does not equal zero. If avgDown[0] is equal to zero, then the division is done by 1. I do not know how you jumped to the conclusion that when the denominator of the division is equal to 1 that it would equate to the rs = 1.

    In the situation that avgDown[0] == 0:
    rs = avgUp[0] / 1
    rsi = 100 - (100 / (1 + rs))

    The only way rsi would be equal to 50 here is if avgUp[0] was equal to 1, which it is almost certainly not. Not following why you feel if avgDown[0] is zero you just completely bypass the division for calculating rs.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh
      You are correct:
      If avgDown[0] = 0 then rs will equal avgUp[0]
      In that case rsi = 100 - (100 / (1 + avgUp[0])) and that is what is wrong.

      A division by zero is infinity.
      so rsi = 100 - (100 / infinity) which is aproximately = 100

      According to J. Welles Wilder
      If avgDown[0] = 0 then rsi should equal 100

      Comment


        #4
        Thank you for the clarification. We will take a look.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Also, the period should have a minimum of 1, and not 2 as presently configured.

          Comment


            #6
            A period of 1 is not useful. There is a lot of initializations being done based off of Period - 1. If Period was 1, that Period-1=0 which is not desired.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              A period of 1 turns RSI into a square wave oscilator which shows at a glance continous succession of ups and downs.

              It is not NT's job to determine usefulness, but to implement the indicator as the author intended.
              You are adding your own spin to this indicator.

              A period of 1 works okay in my testing with the changes outlined in post #1.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, 04-17-2024, 06:40 PM
              6 responses
              48 views
              0 likes
              Last Post algospoke  
              Started by arvidvanstaey, Today, 02:19 PM
              4 responses
              11 views
              0 likes
              Last Post arvidvanstaey  
              Started by samish18, 04-17-2024, 08:57 AM
              16 responses
              61 views
              0 likes
              Last Post samish18  
              Started by jordanq2, Today, 03:10 PM
              2 responses
              9 views
              0 likes
              Last Post jordanq2  
              Started by traderqz, Today, 12:06 AM
              10 responses
              21 views
              0 likes
              Last Post traderqz  
              Working...
              X