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.

indicator calculation
 Post subject: indicator calculation Post rating: 0   New post Posted: Mon 10 Dec, 2012, 10:57 

User rating: 1
Joined: Sun 22 Jul, 2012, 13:35
Posts: 40
Hi support.

I have an indicator with 2 outputs:
double [][] outputs = new double [2][];

By the loop in method calculate(int startIndex, intendIndex) fill myOutput array. This output is calculated with lookBack()=0
outputs[1] is moving average of myOutputs with specific period.
so:
ma.setInputParameter(0, myOutput);
ma.setOptInputParameter(0, timePeriod);
ma.setOutputParameter(0, outputs[1]);
IndicatorResult maResult = ma.calculate(0, myOutput.length-1);

if (maResult.getNumberOfElements() == 0) {
     //ma returned 0 values
     return new IndicatorResult(0, 0);
}
System.arraycopy(myOutput, maResult.getFirstValueIndex(), outputs[0], 0, maResult.getNumberOfElements());
return new IndicatorResult(smaResult.getFirstValueIndex(), maResult.getNumberOfElements());


Indicator returns less values then expected. Can you help me with this?
It is necessary that the method getLookBack() returns timePeriod?
Thank you


 
 Post subject: Re: indicator calculation Post rating: 0   New post Posted: Mon 10 Dec, 2012, 11:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please provide full example indicator which replicates the case.


 
 Post subject: Re: indicator calculation Post rating: 0   New post Posted: Mon 10 Dec, 2012, 14:02 

User rating: 1
Joined: Sun 22 Jul, 2012, 13:35
Posts: 40
Attachment:
SAMPLEIndicator.java [10.59 KiB]
Downloaded 301 times


 
 Post subject: Re: indicator calculation Post rating: 0   New post Posted: Mon 10 Dec, 2012, 16:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Try:


Attachments:
SAMPLEIndicator_2.java [10.35 KiB]
Downloaded 318 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: indicator calculation Post rating: 0   New post Posted: Tue 11 Dec, 2012, 08:02 

User rating: 1
Joined: Sun 22 Jul, 2012, 13:35
Posts: 40
Thanks a lot.

But output[0] (maInput) in not shown. Please add this output.

Thank you.


 
 Post subject: Re: indicator calculation Post rating: 0   New post Posted: Tue 11 Dec, 2012, 08:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It is shown, but its value does not get assign, hence it's an array of zeroes.


 
 Post subject: Re: indicator calculation Post rating: 0   New post Posted: Tue 11 Dec, 2012, 08:53 

User rating: 1
Joined: Sun 22 Jul, 2012, 13:35
Posts: 40
I understand, but I need get both values (maInput with moving average) if i call method indicators.calculateIndicator(instrument, period, offerSides, indName, inputTypes, optParams, shift) in my strategy.


 
 Post subject: Re: indicator calculation Post rating: 0   New post Posted: Tue 11 Dec, 2012, 08:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
So what problems do you have with assigning the values to the 0th output array?


 
 Post subject: Re: indicator calculation Post rating: 0   New post Posted: Tue 11 Dec, 2012, 09:21 

User rating: 1
Joined: Sun 22 Jul, 2012, 13:35
Posts: 40
No problem of course ;)
Attachment:
sampleIndicator.png [16.06 KiB]
Downloaded 367 times


Thanks for your help.


 

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