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 - 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 The_Sec, Yesterday, 03:53 PM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by mmenigma, Yesterday, 03:25 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by kujista, Today, 05:44 AM
        0 responses
        7 views
        0 likes
        Last Post kujista
        by kujista
         
        Started by ZenCortexCLICK, Today, 04:58 AM
        0 responses
        9 views
        0 likes
        Last Post ZenCortexCLICK  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        172 responses
        2,283 views
        0 likes
        Last Post sidlercom80  
        Working...
        X