Hi,
if you are executing an indicator like you show, then it means that:
- The indicator is calculated from all type of candles (including all flats)
- The indicator is calculated starting from current incomplete candle (shift = 0)
These two are the main points why are you not getting same values as charts has.
First of all you need to configure your chart preferences. Open Tools->Preferences->Chart. Find section "Flats Filtration". Select option "Flats filter is disabled". And the second thing is as a first candle use the first completed bar (Shift = 1).
Please consider this code:
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (Instrument.EURUSD == instrument && Period.DAILY == period ){
double rsi = context.getIndicators().rsi(instrument, period, OfferSide.BID, AppliedPrice.CLOSE, 8, 1);
context.getConsole().getOut().println(new Date(context.getHistory().getBar(instrument, period, OfferSide.BID, 1).getTime())
+" rsi= "+rsi);
}
}