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 accessing both currencies of current charts pair?
 Post subject: Indicator accessing both currencies of current charts pair? Post rating: 0   New post Posted: Fri 12 May, 2017, 05:37 
User avatar

User rating: 0
Joined: Fri 12 May, 2017, 05:29
Posts: 2
Location: Germany,
Hello Dukascopy community!

I'm trying to code an indicator that'll calculate an overall currency strength of each currency of the current charts pair.
I.e. if you add it to a EURUSD chart, it will calculate an index / basket value for EUR and one for USD, if you add it to AUDGBP chart, one for AUD and one for GBP etc.

I do have experience in Java but am new to the JForex API.
I haven't found the way yet to access the current charts currencies (or even pair to then .substr() it), but I'm sure there has to be a way?!
Unfortunately the wiki and javadocs are not quite as helpful in this regard as I'd like them to be.

Any help would be much appreciated!


 
 Post subject: Re: Indicator accessing both currencies of current charts pair? Post rating: 0   New post Posted: Sat 20 May, 2017, 12:26 
User avatar

User rating: 0
Joined: Fri 12 May, 2017, 05:29
Posts: 2
Location: Germany,
Turns out it does work via the FeedDescriptor:
IFeedDescriptor feed = context.getFeedDescriptor();

        if (feed != null)
        {
            Instrument instrument = feed.getInstrument();
            this.base = instrument.getPrimaryJFCurrency();
            this.counter = instrument.getSecondaryJFCurrency();
        }


 
 Post subject: Re: Indicator accessing both currencies of current charts pair? Post rating: 0   New post Posted: Tue 23 May, 2017, 14:22 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Indicator can receive data from different instruments:
        inputParameterInfos = new InputParameterInfo[] { new InputParameterInfo("USD", InputParameterInfo.Type.DOUBLE) {
            {
                setInstrument(Instrument.EURUSD);
            }
        }, new InputParameterInfo("GBP", InputParameterInfo.Type.DOUBLE) {
            {
                setInstrument(Instrument.EURGBP);
            }
        }, new InputParameterInfo("AUD", InputParameterInfo.Type.DOUBLE) {
            {
                setInstrument(Instrument.EURAUD);
            }
        } };

This data would allow to compare relative strength of different currencies.


 

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