Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RSI - lookback bar # deviations

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

    RSI - lookback bar # deviations

    I'm looking at the built-in RSI code and trying to figure out why and how the max number of lookback bars (and hence the historical number of bars on the chart) affects the RSI.

    The closest answer I could find was this thread: http://ninjatrader.com/support/forum...ad.php?t=35004

    It specifically said that RSI Average values (variable rsiAvg) uses a smoothing such that lookback bars become relevant. However, I'm getting different values for the RSI Value (variable rsi) depending on whether my chart loads up 50 bars, 51 bars, or max bars. When my chart is at max bars, the RSI using 256 max lookback is the same as the RSI using infinite max lookback.

    #2
    Hello pretender,

    There is smoothing and and rsiAvg that use the data from the previous bar. So on every bar, this is including some information from the previous bar.

    This means that this is a somewhat cumulative effect in that changing the information of the first bar process affects the avg and smoothing for every bar moving forward.

    Changing the number of bars is going to affect this avg and smooth as all bars are contributing to this value.

    The maximum look back will make it so only 250 bars are included maximum. So a period of less that 250 is going to be affected by the number of bars included. Any period of greater than 250 should have to affect as only 250 bars will be used.

    avgDown.Set((avgDown[1] * (Period - 1) + down[0]) / Period);
    avgUp.Set((avgUp[1] * (Period - 1) + up[0]) / Period);
    double rsiAvg = (2.0 / (1 + Smooth)) * rsi + (1 - (2.0 / (1 + Smooth))) * Avg[1];
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      how to reference previous RSI Move Down-Up

      I need help coding the following:
      - in UpTrend
      -- want to write script indicator to plot when
      --- current move down and up of RSI is greater than previous down and up move of RSI ( \/)
      no matter the number bars that occur between down and up moves

      RSI Line
      ........./
      ....../\/
      ../\./ >
      ./ \/
      /

      and vice versa in DownTrend
      Last edited by RicRules; 10-05-2015, 08:02 PM. Reason: more accurate picture

      Comment


        #4
        Hi RicRules,

        You would need to create logic that compares the values of the RSI.

        You can check that the current close is greater than the open on the current bar and the close is less than the open on the previous bar. That would let you know the RSI has changed directions.

        When the change happens, you can use a loop to loop backwards looking for the last place there was a change of direction. This would use similar logic that looks for the open being less than the close on the bar index of the loop and greater than on the previous bar index of the loop.

        if (Close[0] > Open[0] && Open[1] < Close[1])

        This would tell you that the RSI has changed direction from falling to rising.

        for (int i = 1; i > CurrentBar-1, i++)
        {
        if (Close[i] > Open[i])
        {
        Continue;
        }
        else
        {
        Print("previous direction change was: "+ i +" bars ago");
        }
        }
        }

        This would find the previous bar where the open was greater than the close.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        627 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        359 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        562 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X