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.

Indicators problems. Multi-Instrument indicator.
 Post subject: Indicators problems. Multi-Instrument indicator. Post rating: 0   New post Posted: Mon 22 Nov, 2010, 10:40 

User rating: 0
Joined: Thu 19 Aug, 2010, 13:53
Posts: 62
Hi,

I try to group my indicators in class methods to simplify coding. Below an example. I used this model for all of them.
public double ultimateOsc(Period aTimeFrame, int aFastPeriod, int aSlowPeriod, int aSlowestPeriod, int aShift) throws JFException
{
IBar aBar = getBar(aTimeFrame,aShift);
double aArr[] = iStrategy.iIndicators.ultOsc(iInstr,aTimeFrame,OfferSide.BID,aFastPeriod,aSlowPeriod,aSlowestPeriod,Filter.ALL_FLATS,1,aBar.getTime(),0);
if(aArr == null || aArr.length <= 0)
throw new JFException("Ultimate Oscillator indicator not ready.");   
return aArr[0];      
}


I have done in this way ~ 30 indicators. I have well tested them by comparing on the chart with the values outputed from strategy. I get correct values for almost all of them, eg even from complicated ones as Hilbert transform. However, several indicators refuses to give me the same values as the ones shown on the chart. These are: Chaikin AD, Chaikin AD oscillator, On balance Volume and Triple EMA/TEMA. Tema gives however appropiate values +/- several pips than on chart.
Is anything special with them ? Or I might suspect some troubles/bugs ?

The second question: Does JForex allow to write Multi Instrument indicators ? Eg. I want show in an indicator the stochastic from 2 instruments, eg. RSI of EURUSD and RSI AUDJPY. I ask because I have not seen an exmple for this. If yes, can you provide an example ? I suspect there is need bar synchronizations on the instruments, etc.


 
 Post subject: Re: Indicators problems. Multi-Instrument indicator. Post rating: 0   New post Posted: Fri 26 Nov, 2010, 08:02 

User rating: 0
Joined: Thu 19 Aug, 2010, 13:53
Posts: 62
Hi,

Any feedback Dukascopy ?

Sorry, I forgot to mention I test indicators using Tick on open, usually using Hourly TF, and I check the shift 1.

I rechecked also many of them and I get correct values, but recheck on Chaikin AD, Chaikin AD osc and OBV still do not provide same values that with the chart ones.

Thank you.


 
 Post subject: Re: Indicators problems. Multi-Instrument indicator. Post rating: 0   New post Posted: Fri 26 Nov, 2010, 16:48 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please have a look at the following example: https://www.dukascopy.com/swiss/english ... 946#p28946

Every new AD indicator and OBV indicator value adds to the previous. It depends on the range you calculate on, that is why values don't match.


 
 Post subject: Re: Indicators problems. Multi-Instrument indicator. Post rating: 0   New post Posted: Sat 27 Nov, 2010, 06:36 

User rating: 0
Joined: Thu 19 Aug, 2010, 13:53
Posts: 62
Support wrote:
Hi,
Please have a look at the following example: https://www.dukascopy.com/swiss/english ... 946#p28946

Every new AD indicator and OBV indicator value adds to the previous. It depends on the range you calculate on, that is why values don't match.


Well, I am not sure I understand the AD line and OBV problem. The EMA also depends by the previous, eg, ema0 depends by ema1 and I get correct values in code. Also, the AD oscillator should bevave similar like any other, no ?
Can you explain a bit more this problem, especially, how do I get the correct value in code for AD, ADOsc and OBV ? Thank you.

Thank you for the link also.


 
 Post subject: Re: Indicators problems. Multi-Instrument indicator. Post rating: 0   New post Posted: Thu 02 Dec, 2010, 11:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
The values you get are correct, AD/OBV indicators have IndicatorInfo.setRecalculateAll set to true, which means that these indicators are recalculated for all chart data.
An example:
Instrument instrument = Instrument.EURUSD;
Period period = Period.ONE_HOUR;
       
long from = history.getBar(instrument, period, OfferSide.ASK, 3).getTime();                      
long to = history.getBar(instrument, period, OfferSide.ASK, 1).getTime();
double[] adValues = indicators.ad(instrument, period, OfferSide.ASK, from, to);               
for (int i = 0; i < adValues.length; i++){           
   console.getOut().println("ad value: " + adValues[i]);
}
       
for (int i = 3; i > 0; i--){
   double singleAdValue = indicators.ad(instrument, period, OfferSide.ASK, i);           
    console.getOut().println("single ad value: " + singleAdValue);           
}

Here is the result:
single ad value: 3880.9090909089127
single ad value: 2463.1
single ad value: 127.85632183879329
ad value: 6471.865412747706
ad value: 2590.956321838793
ad value: 127.85632183879329

Notice that every new ad value is added to the previous.


 

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