Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cummulative rsi calculation

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

    Cummulative rsi calculation

    I'm trying to do something rather simple and it's just not working - My indicator comes up blank on the chart. What am I doing wrong? the code I came up with is a simple summation of a two period RSI for the last three bars. I don't see how it could be simpler! The plot just comes up with nothing calculated. I've saved and compiled. Any help on this would be greatly appreciated.


    protected override void OnBarUpdate()
    {
    //CALCULATE THE 2 PERIOD SUMMED RSI

    double CUMRSI = RSI(2,3)[0] + RSI(2,3)[1] + RSI(2,3)[2];

    Plot0.Set(CUMRSI);
    }

    Note: Today is my first day using NT - so be easy on me

    #2
    Hi ShruggedAtlas,

    It is always a good idea (in my opinion) to name your plots.

    In the Initialize() you need to have something like:
    Add(new Plot(Color.Cyan, PlotStyle.Line, "CumRSI"));

    In OnBarUpdate() you set the value:
    CumRSI.Set(...);

    In the properties you need to get the values you calculate.The following should work for you.

    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries CumRSI
    {
    get { return Value[0]; }
    }

    If you have more than one plot chnage return Value[0]; to return Values[0];

    I hope this gets you going. :-)

    Last edited by Zeos6; 06-13-2011, 11:57 AM.

    Comment


      #3
      Hi ShruggedAtlas,

      If you apply indexing to values but do not see a plot, check the log tab of control center for any error messages. It's likely you're running into this issue:


      You can resolve by preventing bar processing for the first 3 bars.
      if (CurrentBar < 2) return;

      You can also consider using built in method SUM(), which accepts series as input.

      Plot0.Set(SUM(RSI(2,3), 3)[0]);
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        problem solved!

        Thanks RyanM! It turned out that it was in fact the problem you suggested. I checked the log and did indeed find error alerts notifying me of the problem. The code checking for current bar position was added and it fixed the problem. Also, the SUM function definitely shortens my code up a bit. Thx!

        Also thanks to Zeos6 for giving me some practical tips to make my code a bit more readable. I did name my plot as you suggested and it makes the code more understandable.

        Thx guys!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        637 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        571 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X