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.

a simple use of RSI.but history tester was working very very slowly,what to do?
 Post subject: a simple use of RSI.but history tester was working very very slowly,what to do? Post rating: 0   Post Posted: Fri 11 Oct, 2013, 05:07 
User avatar

User rating: 0
Joined: Wed 28 Mar, 2012, 06:41
Posts: 25
Location: China, Beijing
public void onTick(Instrument instrument, ITick tick) throws JFException {
console.getOut().println("sssssssssssssssssssssssssssssssss3333333333333");
double[] rsi = indicators.rsi(instrument, Period.FOUR_HOURS, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 14,Filter.ALL_FLATS,0, tick.getTime(),1);
console.getOut().println("rsi: "+ rsi[0]);
}


 
 Post subject: Re: a simple use of RSI.but history tester was working very very slowly,what to do? Post rating: 0   Post Posted: Fri 11 Oct, 2013, 13:12 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Are you sure that the slowdown is due to the RSI compilation? We tested the performance of the following strategy in Historical Tester and the calculation times normally were below on millisecond:
    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {
        long start = System.nanoTime();
        double[] RSIArray = indicators.rsi(instrument, period, side, appliedPrice, 14, Filter.WEEKENDS, 1, tick.getTime(), 0);
        long t1 = System.nanoTime();
        console.getOut().format("now=%s tick time=%s calculated in %.6f secs, value=%.5f",
                DateUtils.format(System.currentTimeMillis()),
                DateUtils.format(tick.getTime()),
                ((double)t1 - start) * Math.pow(10, -9),
                RSIArray[0]
        ).println();
    }
For subsequent requests please provide a full example strategy which replicates the case and a screenshot of your Historical Tester settings.


Attachments:
RSIperformTest.java [2.22 KiB]
Downloaded 147 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: a simple use of RSI.but history tester was working very very slowly,what to do? Post rating: 0   Post Posted: Sat 12 Oct, 2013, 11:25 
User avatar

User rating: 0
Joined: Wed 28 Mar, 2012, 06:41
Posts: 25
Location: China, Beijing
API Support wrote:
Are you sure that the slowdown is due to the RSI compilation? We tested the performance of the following strategy in Historical Tester and the calculation times normally were below on millisecond:
    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {
        long start = System.nanoTime();
        double[] RSIArray = indicators.rsi(instrument, period, side, appliedPrice, 14, Filter.WEEKENDS, 1, tick.getTime(), 0);
        long t1 = System.nanoTime();
        console.getOut().format("now=%s tick time=%s calculated in %.6f secs, value=%.5f",
                DateUtils.format(System.currentTimeMillis()),
                DateUtils.format(tick.getTime()),
                ((double)t1 - start) * Math.pow(10, -9),
                RSIArray[0]
        ).println();
    }
For subsequent requests please provide a full example strategy which replicates the case and a screenshot of your Historical Tester settings.



YES .It's this fragment code.history tester went very slowly。。
I download your file .and run normly.but my fragment code run very slowly..
you can copy that to your file ,and have a try.


 
 Post subject: Re: a simple use of RSI.but history tester was working very very slowly,what to do? Post rating: 0   Post Posted: Sat 12 Oct, 2013, 12:40 
User avatar

User rating: 0
Joined: Wed 28 Mar, 2012, 06:41
Posts: 25
Location: China, Beijing
zzping115 wrote:
API Support wrote:
Are you sure that the slowdown is due to the RSI compilation? We tested the performance of the following strategy in Historical Tester and the calculation times normally were below on millisecond:
    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {
        long start = System.nanoTime();
        double[] RSIArray = indicators.rsi(instrument, period, side, appliedPrice, 14, Filter.WEEKENDS, 1, tick.getTime(), 0);
        long t1 = System.nanoTime();
        console.getOut().format("now=%s tick time=%s calculated in %.6f secs, value=%.5f",
                DateUtils.format(System.currentTimeMillis()),
                DateUtils.format(tick.getTime()),
                ((double)t1 - start) * Math.pow(10, -9),
                RSIArray[0]
        ).println();
    }
For subsequent requests please provide a full example strategy which replicates the case and a screenshot of your Historical Tester settings.



YES .It's this fragment code.history tester went very slowly。。
I download your file .and run normly.but my fragment code run very slowly..
you can copy that to your file ,and have a try.


hello support,I found the diffirent.just in
double[] rsi = indicators.rsi(instrument, Period.FOUR_HOURS, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 14,Filter.ALL_FLATS,0, tick.getTime(),1); changed to

double[] rsi = indicators.rsi(instrument, Period.FOUR_HOURS, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 14,Filter.ALL_FLATS,1, tick.getTime(),0);
it became very faster.
but I did not know the real reason? and I want to use the newly tick's rsi value. what to do?


 
 Post subject: Re: a simple use of RSI.but history tester was working very very slowly,what to do? Post rating: 0   Post Posted: Sat 12 Oct, 2013, 18:10 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
The javadoc regarding the last parameter in question:
numberOfCandlesAfter - how much candles to load after (and not including) the candle with time specified in the time parameter

The time parameter is tick.getTime(), which actually the latest tick. So there are no ticks or candles after this tick. Maybe there are some issues (slowdowns) when you want to calculate something for a bar that does not exists? Support must clarify (on Monday :) )

More on indicator calculation on general here.
And the javadoc, where you can find information about functions: https://www.dukascopy.com/client/javadoc/


 
 Post subject: Re: a simple use of RSI.but history tester was working very very slowly,what to do? Post rating: 0   Post Posted: Mon 14 Oct, 2013, 08:18 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
zzping115 wrote:
but I did not know the real reason?
You are trying to calculate on the candle that does not exist yet - the one after the currently forming candle. It is rather an API discrepancy that a JFException does not get thrown (we are going to take a look at this).
zzping115 wrote:
and I want to use the newly tick's rsi value. what to do?
Our example does just that - it calculates the RSI value on the current candle. You can make sure of this by plotting an RSI indicator on the same feed chart, a convenient way how to do this can be found here:
https://www.dukascopy.com/wiki/#Add_indicators_on_chart/Include_in_OHLC


 
 Post subject: Re: a simple use of RSI.but history tester was working very very slowly,what to do? Post rating: 0   Post Posted: Fri 18 Oct, 2013, 03:26 
User avatar

User rating: 0
Joined: Wed 28 Mar, 2012, 06:41
Posts: 25
Location: China, Beijing
API Support wrote:
zzping115 wrote:
but I did not know the real reason?
You are trying to calculate on the candle that does not exist yet - the one after the currently forming candle. It is rather an API discrepancy that a JFException does not get thrown (we are going to take a look at this).
zzping115 wrote:
and I want to use the newly tick's rsi value. what to do?
Our example does just that - it calculates the RSI value on the current candle. You can make sure of this by plotting an RSI indicator on the same feed chart, a convenient way how to do this can be found here:
https://www.dukascopy.com/wiki/#Add_indicators_on_chart/Include_in_OHLC


yes。thankyou
But throw an exceoption rather than a very slowly run


 

Jump to:  

  © 1998-2026 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