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.

Stoch indicator values do not match tester screen
 Post subject: Stoch indicator values do not match tester screen Post rating: 0   New post Posted: Wed 09 Jun, 2010, 15:53 

User rating: 0
Joined: Sat 05 Jun, 2010, 09:47
Posts: 9
Hi,

Below the code i'm trying to use in my strategy.
I'm looking to retrieve the K and D values of the stoch after bar0 has been detected as being a full bar.
The period and offerside settings have been checked and correct.

The values i print (whilst running in Eclipse) are not lined up with those on screen when running the tester.
The bar however does show the exact values. So at least something is going right .. ;-)

1. Could someone please let me know whether the code used below is correct and should supply the same results as on screen
2. What effect do the candlesBefore and after have on the selection. if after>1 then no data comes through at all!?

Tia,

Fermin DCG

private double calculateStoch(Instrument instrument, Period period, IBar bar0) throws JFException {
    int fastK = 26;//13
    int slowK = 9;//5
    int slowD =  9;//5
    MaType slowKMA =  MaType.TEMA;//MaType.SMA;//
    MaType slowDMA =  MaType.WMA;//MaType.SMA;//
    int candlesBefore = 3;
    int candlesAfter=0;
    int upperStochLimit=80;
    int lowerStochLimit=20;

    messageStoch=null;
    double stochX=0;
    int boundaryX = 0;
   
    if (period==Period.ONE_HOUR) {
      double[][] stoch = indicators.stoch(instrument, defaultPeriod, OfferSide.ASK, fastK, slowK, slowKMA, slowD, slowDMA, Filter.WEEKENDS, candlesBefore, bar0.getTime(), candlesAfter);

...


 
 Post subject: Re: Stoch indicator values do not match tester screen Post rating: 0   New post Posted: Thu 10 Jun, 2010, 12:41 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
When you are calculating an indicator, you need to check also for the correct instrument. Because methods onBar and onTick are called for each subscribed instrument.
Please, consider this https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=5&t=2345


 
 Post subject: Re: Stoch indicator values do not match tester screen Post rating: 0   New post Posted: Thu 10 Jun, 2010, 13:21 

User rating: 0
Joined: Sat 05 Jun, 2010, 09:47
Posts: 9
Support wrote:
Hi,
When you are calculating an indicator, you need to check also for the correct instrument. Because methods onBar and onTick are called for each subscribed instrument.
Please, consider this https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=5&t=2345


Hi support,
Thanks for reply but i'm currently only running against one pair (EURUSD) so this suggestion i'm assuming does not apply. Though i understand your point and the code does take that into consideration.

Since you did not supplu a comment on the code itself i surmise that this is correct?

Tia,

Fermin DCG


 
 Post subject: Re: Stoch indicator values do not match tester screen (SOLVE Post rating: 0   New post Posted: Thu 10 Jun, 2010, 14:16 

User rating: 0
Joined: Sat 05 Jun, 2010, 09:47
Posts: 9
dacosta wrote:
Support wrote:
Hi,
When you are calculating an indicator, you need to check also for the correct instrument. Because methods onBar and onTick are called for each subscribed instrument.
Please, consider this https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=5&t=2345



The error was not in the instrument but indeed the use of the candlesBefore and after.
As it tuns out they mean i had to do the following to get figures that look acceptable:
1. candlesBefore means candles before the bar being scrutinized, used fastK+1 for that
2. For the time i used the time of the latest completed bar as determined in the onBar() method
3. candlesAfter i set to 0 (anything over 1 throws an exception, which makes sense looking at bar0)

These settings get me pretty close to the screen numbers (within tolerance levels, i hope).

Cheers,

Fermin DCG


 

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