XAUUSD RSI 1Min values don't match RSI indicator
XAUUSD RSI 1Min values don't match RSI indicator
21 Nov 2024, 02:03
Hi,
I printed all the RSI values in OnBar in a bot and they do not match the indicator at all.
Am I missing something?
Symbol: XAUUSD
Timeframe: 1Min
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, AddIndicators = true)]
public class SampleRSIcBot : Robot
{
[Parameter("Source", Group = "RSI")] public DataSeries Source { get; set; }
[Parameter("Periods", Group = "RSI", DefaultValue = 14)]
public int Periods { get; set; }
private RelativeStrengthIndex rsi;
protected override void OnStart()
{
rsi = Indicators.RelativeStrengthIndex(Source, Periods);
}
protected override void OnBar()
{
var openTime = Bars.OpenTimes.LastValue;
var _rsi = rsi.Result.LastValue;
Print($"openTime: {openTime} - rsi: {_rsi}");
}
}
}
21/11/2024 01:37:00.000 | Info | openTime: 21/11/2024 1:37:00 am - rsi: 57.675267061026105
21/11/2024 01:38:00.000 | Info | openTime: 21/11/2024 1:38:00 am - rsi: 59.087603675370005
21/11/2024 01:39:00.000 | Info | openTime: 21/11/2024 1:39:00 am - rsi: 68.22306801229806
21/11/2024 01:40:00.000 | Info | openTime: 21/11/2024 1:40:00 am - rsi: 71.63368757214312
21/11/2024 01:41:00.000 | Info | openTime: 21/11/2024 1:41:00 am - rsi: 72.43035521176071
21/11/2024 01:42:00.000 | Info | openTime: 21/11/2024 1:42:00 am - rsi: 70.30398480513982
21/11/2024 01:43:00.000 | Info | openTime: 21/11/2024 1:43:00 am - rsi: 53.41610277465669
21/11/2024 01:44:00.000 | Info | openTime: 21/11/2024 1:44:00 am - rsi: 54.590794295295346
21/11/2024 01:45:00.000 | Info | openTime: 21/11/2024 1:45:00 am - rsi: 62.695295474250194
21/11/2024 01:46:00.000 | Info | openTime: 21/11/2024 1:46:00 am - rsi: 53.66919431487438
21/11/2024 01:47:00.000 | Info | openTime: 21/11/2024 1:47:00 am - rsi: 52.50623960343824
PanagiotisCharalampous
21 Nov 2024, 06:47
Hi there,
This happens because you are printing the values at the opening of the bar. The indicator value might change by the time the bar closes. Try printing values for closed bars i.e.
Best regards,
Panagiotis
@PanagiotisCharalampous