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.

Problem with use Stochastic in custom indicator
 Post subject: Problem with use Stochastic in custom indicator Post rating: 0   New post Posted: Fri 07 Mar, 2014, 12:21 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
Hello,

I have problem with using Stochastic indicator in custom indicator.

I try to write indicator similar to RSISinglaArrows which is decribed in wiki: https://www.dukascopy.com/wiki/#Indicato ... _indicator
But instead of RSI I want to use Stochastic.

If I replace RSI by Stochatic I receive strange bug:

07.03.2014 12:16:46.508 SEVERE dataprovider.AbstractDataProvider ] null
java.lang.NullPointerException
at com.dukascopy.indicators.MAIndicator.getLookback(MAIndicator.java:108)
at com.dukascopy.indicators.StochasticIndicator.getLookback(StochasticIndicator.java:123)
at jforex.indicators.StochMA01.getLookback(StochMA01.java:107)

It looks that MA indicator which is used by STOCH indicator is NULL. And I do not know why... (it means that we can not use indicators which call another indicators?)

In attachment code of my indicator. Please help me.


Attachments:
StochMA01.java [7.4 KiB]
Downloaded 65 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: Problem with use Stochastic in custom indicator Post rating: 0   New post Posted: Mon 10 Mar, 2014, 18:16 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
you should fetch the lookback in some local variable instead of getting it from the STOCH, which may not be fully initialized on the first request.


 
 Post subject: Re: Problem with use Stochastic in custom indicator Post rating: 0   New post Posted: Mon 10 Mar, 2014, 19:18 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
Thanks,

I do this but I receive very similar error but in different place. Here it also looks that MA indicator which is used by STOCH indicator is NULL.:

10.03.2014 19:18:09.873 SEVERE a.a ] null
java.lang.NullPointerException
at com.dukascopy.indicators.MAIndicator.getLookback(MAIndicator.java:108)
at com.dukascopy.indicators.StochasticIndicator.getLookback(StochasticIndicator.java:123)
at com.dukascopy.indicators.StochasticIndicator.calculate(StochasticIndicator.java:61)
at jforex.indicators.StochMA01.calculate(StochMA01.java:83)

In attachment new version. Please help.


Attachments:
StochMA01.java [7.65 KiB]
Downloaded 73 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: Problem with use Stochastic in custom indicator Post rating: 0   New post Posted: Tue 11 Mar, 2014, 12:22 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
I found the bug. In setOptInputParameter method I have all in statement if (index == 0)... stupid bug.

Thanks


 
 Post subject: Re: Problem with use Stochastic in custom indicator Post rating: 0   New post Posted: Tue 11 Mar, 2014, 12:40 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See line 138.


 
 Post subject: Re: Problem with use Stochastic in custom indicator Post rating: 0   New post Posted: Tue 11 Mar, 2014, 12:41 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
Thanks, very stupid bug :)


 

Jump to:  

  © 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