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.

Accessing an indictor with multiple inputs from a strategy
 Post subject: Accessing an indictor with multiple inputs from a strategy Post rating: 0   New post Posted: Tue 12 Feb, 2013, 10:32 

User rating: 0
Joined: Sat 22 Dec, 2012, 12:15
Posts: 2
Location: United KingdomUnited Kingdom
I'm very interested in developing a custom indicator which takes as its input a DOUBLE and PRICE. I would like to access this indictor from a stratgey. The nearest equivalent on the Dukascopy wiki is STDDEVATR (see https://www.dukascopy.com/wiki/#Indicato ... nput_types). However, I am struggling to access this indicator from a strategy. Please could you provide a code snippet that shows how this indicator can be called from a strategy.

Many thanks in advance.


 
 Post subject: Re: Accessing an indictor with multiple inputs from a strategy Post rating: 0   New post Posted: Tue 12 Feb, 2013, 10:41 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Launch the following strategy (mind to choose your indicator's .jfx file and set indName as it appears in the in your IndicatorInfo):
https://www.dukascopy.com/wiki/#Calculate_arbitrary_indicator/Calculate_by_shift
Here you will find out all necessary parameters you need - then you will need to adjust the code in a similar way that of:
https://www.dukascopy.com/wiki/#Calculate_arbitrary_indicator/Apply_to_particular_indicator
Note the inputTypes and offerSides arrays - you will need them to be of the length 2 - each for every input.


 
 Post subject: Re: Accessing an indictor with multiple inputs from a strategy Post rating: 0   New post Posted: Wed 13 Feb, 2013, 22:03 

User rating: 0
Joined: Sat 22 Dec, 2012, 12:15
Posts: 2
Location: United KingdomUnited Kingdom
Many thanks for the information - that's worked! To call an indicator with two inputs there needs to be two values for the offerside and two values for the AppliedPrice. According to the dukascopy wiki you pass a null for the PRICE and AppliedPrice.CLOSE for the double. Please see below for code snippet to call STDDEVATR.


indicators.registerCustomIndicator(new File(context.getFilesDir() + System.getProperty("file.separator") + "STDDEVATRIndicator.jfx"));
Object[] testIndicatorValues = indicators.calculateIndicator(Instrument.EURUSD, Period.ONE_HOUR, new OfferSide[] {OfferSide.BID, OfferSide.BID}, "ATRSTDDEV",
new AppliedPrice[]{null, AppliedPrice.CLOSE}, new Object[]{2, 5, 1.0}, 0);
console.getOut().println("test indicator value: " +","+ ((Object[])testIndicatorValues)[0]);


 

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