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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        87 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        106 views
        0 likes
        Last Post CarlTrading  
        Working...
        X