Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Discrepancy between RSI -Chart and IIndicators.rsi() ?
 Post subject: Discrepancy between RSI -Chart and IIndicators.rsi() ? Post rating: 0   New post Posted: Sun 25 Apr, 2010, 20:15 

User rating: 0
Joined: Wed 14 Apr, 2010, 22:36
Posts: 11
I try to use the rsi indicator within a strategy by the call

double rsiOut = indicators.rsi(instrument, Period.DAILY, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, TIME_PERIOD_RSI, 0);

with TIME_PERIOD_RSI = 8.
The output of these rsi values on the console by

console.getOut().println(date.toString() + ": rsi = " + rsiOut);

shows a massive (!) difference to the values I measure from the RSI chart (close price, daily and TimePeriod = 8) within the instrument chart.
Why? What's the mistake?

Modifying the shift or TIME_PERIOD_RSI in the indicators.rsi call does not show any improvement.
On the screenshot "tester_output.png" it's obvious that there's a large descrepancy on 20th April from the rsi output and the rsi chart.
I suppose it's a trivial mistake I am making but cannot find a solution.

Many thanks in advance!
Best regards.


Attachments:
tester_output_sceen.png [63.45 KiB]
Downloaded 617 times
tester_screen.png [54.52 KiB]
Downloaded 607 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Discrepancy between RSI -Chart and IIndicators.rsi() ? Post rating: 0   New post Posted: Tue 27 Apr, 2010, 11:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
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);
        }
    }


 
 Post subject: Re: Discrepancy between RSI -Chart and IIndicators.rsi() ? Post rating: 0   New post Posted: Wed 22 Dec, 2010, 18:28 

User rating: 0
Joined: Sun 22 May, 2011, 23:43
Posts: 12
Location: Italy, Roma
What is the other way around?
I mean, how to mantain the Filters active on charts and still have the same output in the code?
I have a custom indicator and I'm pretty satisfied of how it displays on chart. Now I'd like to use the same values within a IStrategy.
Kind regards,
Paolo


 
 Post subject: Re: Discrepancy between RSI -Chart and IIndicators.rsi() ? Post rating: 0   New post Posted: Mon 27 Dec, 2010, 17:38 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
ppduka wrote:
What is the other way around?
I mean, how to mantain the Filters active on charts and still have the same output in the code?


If you use filter ALL_FLATS in the chart, you can call rsi indicator with filter from the API in you code:
double[] rsi = indicators.rsi(instrument, period, OfferSide.BID, appliedPrice, timePeriod, Filter.ALL_FLATS, numberOfCandlesBefore, prevBar.getTime(), numberOfCandlesAfter);


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com