Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RSI averages not same as chart's avgs

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

    RSI averages not same as chart's avgs

    Hello,

    This chart shows RSI average values that are not the same as the Data Box's RSI average values. I thought the index [1], etc would pull the correct values but it is not. Is the syntax incorrect somewhere in the code? See chart in attached.

    Thanks in advance!

    Code:
    namespace NinjaTrader.Strategy
    {
        public class ShowRSIvalue : Strategy
        {
            #region Variables
    		private DataSeries rsi;
    		private DataSeries avg;
            #endregion
    
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
    			Add(RSI(9,3));
    			rsi = new DataSeries(this);
    			avg = new DataSeries(this);
            }
            protected override void OnBarUpdate()
            {
    			rsi.Set(Math.Round((RSI(9,3)[0]),2));
    			avg.Set(Math.Round((RSI(9,3)[1]),2));
    			DrawTextFixed("RSI", "RSI 0: " + rsi[0] + "  " + avg[0]
    			+ "\nRSI 1: " + rsi[1] + "  " + avg[1]
    			+ "\nRSI 2: " + rsi[2] + "  " + avg[2]
    			+ "\nRSI 3: " + rsi[3] + "  " + avg[3]
    			+ "\nRSI 4: " + rsi[4] + "  " + avg[4]
    			+ "\nRSI 5: " + rsi[5] + "  " + avg[5]
    			,TextPosition.Center,Color.Yellow,new Font("Arial",18),Color.Black,Color.Black,10);
            }
    Attached Files

    #2
    Hello,

    Thank you for the question.

    I am looking at the Image you have provided and would like to clarify your question.

    I see that in the image you have the mouse hovering 1 bar in the past, the code which is getting the RSI for 1 bar in the past is the same value.

    Can you please clarify the question as to what you are trying to correct?

    I look forward to being of further assistance.

    Comment


      #3
      Data Box's RSI avg has 52.48 while chart's text has 50.31. All the remaining averages on the chart are not same to Data Box's values (Avg) when pointing specific bar. See next chart attached.

      Thanks.
      Attached Files

      Comment


        #4
        The code of your strategy is flawed.

        Math.Round((RSI(9,3)[1]),2) calls the RSI 1 bar ago.

        If you wish to call the RSI average for the current bar, then the correct formula would be

        Code:
        avg.Set(Math.Round(RSI(9,3).Avg[0],2);

        Comment

        Latest Posts

        Collapse

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