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.

How to call ULTOSC indicator
 Post subject: How to call ULTOSC indicator Post rating: 0   New post Posted: Tue 02 Mar, 2010, 13:11 

User rating: 0
Joined: Tue 02 Mar, 2010, 12:18
Posts: 8
Hi Support,

I have been trying to use the Ultimate Oscillator within a custom indicator but I get the runtime error message.

Quote:
12:08:05 Error in indicator: java.lang.ClassCastException: [D cannot be cast to [[D @ jforex.OsMAIndicator.calculate(OsMAIndicator.java:46)


The problematic line is:

Quote:
ind01.setInputParameter(0, inputs[0]);


Note: To make sure it wasn't some unrelated coding error I adapted the OsMAIndicator.java example so that it called ULTOSC instead of MACD. It too gave the same error. That file is attached below.

What am I doing wrong?
In what way is ULTOSC different to other indicators?
Where can I find such information about the various indicators?

Thanks in advance.
John


Attachments:
File comment: Adapted example code that exhibits the runtime error described above.
OsMAIndicator.java [3.97 KiB]
Downloaded 460 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: How to call ULTOSC indicator Post rating: 0   New post Posted: Wed 10 Mar, 2010, 15:46 

User rating: 0
Joined: Tue 02 Mar, 2010, 12:18
Posts: 8
Hello Support,

Could you please post the code of the ULTOSC indicator so that I can try to diagnose this problem myself.

Thanks!
John


 
 Post subject: Re: How to call ULTOSC indicator Post rating: 0   New post Posted: Thu 11 Mar, 2010, 18:26 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello,
sorry for not answering.
The ULTOSC indicator is a third party indicator(https://ta-lib.org/index.html).
All our indicators are available here https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewforum.php?f=6
You are receiving this exception because, you are trying to pass to a function setInputParameter as second parameter just an object. Instead you need to pass the array of objects.


 
 Post subject: Re: How to call ULTOSC indicator Post rating: 0   New post Posted: Mon 15 Mar, 2010, 08:31 

User rating: 0
Joined: Tue 02 Mar, 2010, 12:18
Posts: 8
Hi there,

I'm new to JForex so sorry if this is a stupid question... :?

Quote:
You are receiving this exception because, you are trying to pass to a function setInputParameter as second parameter just an object. Instead you need to pass the array of objects.

The code is:
private double[][] inputs = new double[1][];
...
ind01.setInputParameter(0, inputs[0]);

I am passing an array of doubles, the same as in the tutorial "Implementing indicator that uses another indicator". I tried passing inputs which is double[ ][ ] but that resulted in other errors.

This code works with all the indicators that I have used - except for ULTOSC.

Has anyone managed to call ULTOSC from within a custom indicator?
If so I would greatly appreciate an example!


 
 Post subject: Re: How to call ULTOSC indicator Post rating: 0   New post Posted: Mon 15 Mar, 2010, 11:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
ULTOSC has input type PRICE. It needs all bar prices in array of doubles. You can define input of your custom indicator as PRICE input and pass it to the ULTOSC
You need to make this changes to your code:
1. private double[][] inputs = new double[1][];
change to
private double[][][] inputs = new double[1][][];
2. inputParameterInfos = new InputParameterInfo[] {new InputParameterInfo("Input data", InputParameterInfo.Type.DOUBLE)};
change to
inputParameterInfos = new InputParameterInfo[] {new InputParameterInfo("Input data", InputParameterInfo.Type.PRICE)};
3. public void setInputParameter(int index, Object array) {
inputs[index] = (double[]) array;
}
change to
public void setInputParameter(int index, Object array) {
inputs[index] = (double[][]) array;
}

maybe more changes will be needed, but you will see it in compilation messages


 

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