RSI Fix value

 
 RSI_Test.mq5        |
//|                        Copyright 2024, MetaQuotes Software Corp. |
//|                                       https://www.mql5.com       |
//+------------------------------------------------------------------+
#property strict

// Input parameters for the RSI
input int RSI_Period = 14;          // RSI period
input double RSI_Overbought = 70.0; // Overbought level
input double RSI_Oversold = 30.0;   // Oversold level

void OnInit()
{
    Print("RSI Test Initialized");
}

void OnTick()
{
    // Calculate RSI
    double rsi = iRSI(_Symbol, PERIOD_H1, RSI_Period, PRICE_CLOSE);
    
    // Print the current RSI value
    Print("Current RSI: ", rsi);
}

//+------------------------------------------------------------------+


log


S	0	00:01:04.352	 RSi skalp (NZDUSD,H1)	2024.01.30 22:21:59   Current RSI: 10.0
CS	0	00:01:04.352	 RSi skalp (NZDUSD,H1)	2024.01.30 22:22:00   Current RSI: 10.0
CS	0	00:01:04.353	 RSi skalp (NZDUSD,H1)	2024.01.30 22:22:20   Current RSI: 10.0
CS	0	00:01:04.354	 RSi skalp (NZDUSD,H1)	2024.01.30 22:22:40   Current RSI: 10.0
CS	0	00:01:04.354	 RSi skalp (NZDUSD,H1)	2024.01.30 22:22:59   Current RSI: 10.0
CS	0	00:01:04.359	 RSi skalp (NZDUSD,H1)	2024.01.30 22:23:00   Current RSI: 10.0
CS	0	00:01:04.359	 RSi skalp (NZDUSD,H1)	2024.01.30 22:23:20   Current RSI: 10.0
CS	0	00:01:04.360	 RSi skalp (NZDUSD,H1)	2024.01.30 22:23:40   Current RSI: 10.0
CS	0	00:01:04.360	 RSi skalp (NZDUSD,H1)	2024.01.30 22:23:59   Current RSI: 10.0
CS	0	00:01:04.361	 RSi skalp (NZDUSD,H1)	2024.01.30 22:24:00   Current RSI: 10.0
CS	0	00:01:04.361	 RSi skalp (NZDUSD,H1)	2024.01.30 22:24:20   Current RSI: 10.0

why? 

Visually i see in tester the is rsi price are normal and moving, the rsi is changing. What can be the problem?

 
Put the cursor on iRSI and press F1 and read how this function is used! It returns a handle not values!
 

Hi

Exactly – int mt5 functions for indicators returns handles you should call this function in OnInit and then use CopyBuffer to get the values from this handle like this:

double values[1];
int copied = CopyBuffer(rsi,0,0,1,values);

Print(“Current RSI: “, values[0]);

Have a nice weekend👍📊